X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Flisp.h;h=0db53785f6b8e516399e912e08fc6aa3f5fe0c14;hb=499b5ad5e2308fd04e3654aaa462d099f1769fd1;hp=2963e991a0ea7829f71fdc0af78fb74cd73c3863;hpb=571a24e2bfea15d37c3503414674f59e89ec9652;p=chise%2Fxemacs-chise.git diff --git a/src/lisp.h b/src/lisp.h index 2963e99..0db5378 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -71,7 +71,7 @@ void Dynarr_free (void *d); #define Dynarr_at(d, pos) ((d)->base[pos]) #define Dynarr_atp(d, pos) (&Dynarr_at (d, pos)) #define Dynarr_begin(d) Dynarr_atp (d, 0) -#define Dynarr_end(d) Dynarr_atp (d, Dynarr_length (d)) +#define Dynarr_end(d) Dynarr_atp (d, Dynarr_length (d) - 1) #define Dynarr_sizeof(d) ((d)->cur * (d)->elsize) #define Dynarr_length(d) ((d)->cur) #define Dynarr_largest(d) ((d)->largest) @@ -136,7 +136,7 @@ char *xstrdup (const char *); least NEEDED_SIZE objects. The reallocing is done by doubling, which ensures constant amortized time per element. */ #define DO_REALLOC(basevar, sizevar, needed_size, type) do { \ - size_t do_realloc_needed_size = (needed_size); \ + EMACS_INT do_realloc_needed_size = (needed_size); \ if ((sizevar) < do_realloc_needed_size) \ { \ if ((sizevar) < 32) \ @@ -216,13 +216,10 @@ typedef union "Types must be declared in declarations, not in expressions." */ # define ALIGNOF(type) offsetof (struct { char c; type member; }, member) # else -/* The following should be completely portable, but might give values - that are larger than necessary. But never larger than the maximum - possible alignment. */ -# define ALIGNOF(type) \ -((sizeof (type) % sizeof (max_align_t)) == 0 ? \ - sizeof (max_align_t) : \ - (sizeof (type) % sizeof (max_align_t))) +/* C++ is annoying, but it has a big bag of tricks. + The following doesn't have the "inside out" declaration bug C does. */ +template struct alignment_trick { char c; T member; }; +# define ALIGNOF(type) offsetof (alignment_trick, member) # endif #endif /* ALIGNOF */ @@ -270,7 +267,11 @@ void assert_failed (const char *, int, const char *); /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit. In particular, it must be large enough to contain a pointer. - config.h can override this, e.g. to use `long long' for bigger lisp ints. */ + config.h can override this, e.g. to use `long long' for bigger lisp ints. + + #### In point of fact, it would NOT be a good idea for config.h to mess + with EMACS_INT. A lot of code makes the basic assumption that EMACS_INT + is the size of a pointer. */ #ifndef SIZEOF_EMACS_INT # define SIZEOF_EMACS_INT SIZEOF_VOID_P @@ -357,7 +358,7 @@ typedef UChar UChar_ASCII; typedef int Emchar; /* Different ways of referring to a position in a buffer. We use - the typedefs in preference to 'int' to make it clearer what + the typedefs in preference to 'EMACS_INT' to make it clearer what sort of position is being used. See extents.c for a description of the different positions. We put them here instead of in buffer.h (where they rightfully belong) to avoid syntax errors @@ -379,6 +380,10 @@ typedef EMACS_INT Extcount; /* structure/other typedefs */ /* ------------------------------- */ +/* Counts of bytes or array elements */ +typedef EMACS_INT Memory_count; +typedef EMACS_INT Element_count; + typedef struct lstream Lstream; typedef unsigned int face_index; @@ -580,7 +585,7 @@ enum Lisp_Type #define INT_VALBITS (BITS_PER_EMACS_INT - INT_GCBITS) #define VALBITS (BITS_PER_EMACS_INT - GCBITS) -#define EMACS_INT_MAX ((EMACS_INT) ((1UL << INT_VALBITS) -1UL)) +#define EMACS_INT_MAX ((EMACS_INT) ((1UL << (INT_VALBITS - 1)) -1UL)) #define EMACS_INT_MIN (-(EMACS_INT_MAX) - 1) #ifdef USE_UNION_TYPE @@ -1203,14 +1208,28 @@ void set_string_char (Lisp_String *s, Charcount i, Emchar c); #endif /* not MULE */ -/* Return the true size of a struct with a variable-length array field. */ -#define FLEXIBLE_ARRAY_STRUCT_SIZEOF(flexible_array_structtype, \ - flexible_array_field, \ - flexible_array_length) \ - (offsetof (flexible_array_structtype, flexible_array_field) + \ - (offsetof (flexible_array_structtype, flexible_array_field[1]) - \ - offsetof (flexible_array_structtype, flexible_array_field[0])) * \ - (flexible_array_length)) +/* Return the true aligned size of a struct whose last member is a + variable-length array field. (this is known as the "struct hack") */ +/* Implementation: in practice, structtype and fieldtype usually have + the same alignment, but we can't be sure. We need to use + ALIGN_SIZE to be absolutely sure of getting the correct alignment. + To help the compiler's optimizer, we use a ternary expression that + only a very stupid compiler would fail to correctly simplify. */ +#define FLEXIBLE_ARRAY_STRUCT_SIZEOF(structtype, \ + fieldtype, \ + fieldname, \ + array_length) \ +(ALIGNOF (structtype) == ALIGNOF (fieldtype) \ + ? (offsetof (structtype, fieldname) + \ + (offsetof (structtype, fieldname[1]) - \ + offsetof (structtype, fieldname[0])) * \ + (array_length)) \ + : (ALIGN_SIZE \ + ((offsetof (structtype, fieldname) + \ + (offsetof (structtype, fieldname[1]) - \ + offsetof (structtype, fieldname[0])) * \ + (array_length)), \ + ALIGNOF (structtype)))) /*------------------------------ vector --------------------------------*/ @@ -1258,7 +1277,7 @@ struct Lisp_Bit_Vector { struct lrecord_header lheader; Lisp_Object next; - size_t size; + EMACS_INT size; unsigned long bits[1]; }; typedef struct Lisp_Bit_Vector Lisp_Bit_Vector; @@ -1568,7 +1587,7 @@ XCHAR_OR_INT (Lisp_Object obj) #define C_READONLY(obj) (C_READONLY_RECORD_HEADER_P(XRECORD_LHEADER (obj))) #define LISP_READONLY(obj) (LISP_READONLY_RECORD_HEADER_P(XRECORD_LHEADER (obj))) -/*----------------------------- structrures ----------------------------*/ +/*----------------------------- structures -----------------------------*/ typedef struct structure_keyword_entry structure_keyword_entry; struct structure_keyword_entry @@ -1892,7 +1911,7 @@ extern EMACS_INT consing_since_gc; /* threshold for doing another gc */ -extern EMACS_INT gc_cons_threshold; +extern Fixnum gc_cons_threshold; /* Structure for recording stack slots that need marking */ @@ -2132,6 +2151,8 @@ void debug_ungcpro(char *, int, struct gcpro *); extern Lisp_Object_ptr_dynarr *staticpros; +void register_post_gc_action (void (*fun) (void *), void *arg); + /* Call staticpro (&var) to protect static variable `var'. */ void staticpro (Lisp_Object *); @@ -2139,20 +2160,40 @@ void staticpro (Lisp_Object *); /* var will not be saved at dump time */ void staticpro_nodump (Lisp_Object *); -/* Call dump_add_root_struct_ptr (&var, &desc) to dump the structure pointed to by `var'. */ +/* dump_add_root_struct_ptr (&var, &desc) dumps the structure pointed to by `var'. */ #ifdef PDUMP void dump_add_root_struct_ptr (void *, const struct struct_description *); #else #define dump_add_root_struct_ptr(varaddr,descaddr) DO_NOTHING #endif -/* Call dump_add_opaque (&var, size) to dump the opaque static structure `var'. */ +/* dump_add_opaque (&var, size) dumps the opaque static structure `var'. */ #ifdef PDUMP void dump_add_opaque (void *, size_t); #else #define dump_add_opaque(varaddr,size) DO_NOTHING #endif +/* Call dump_add_opaque_int (&int_var) to dump `int_var', of type `int'. */ +#ifdef PDUMP +#define dump_add_opaque_int(int_varaddr) do { \ + int *dao_ = (int_varaddr); /* type check */ \ + dump_add_opaque (dao_, sizeof (*dao_)); \ +} while (0) +#else +#define dump_add_opaque_int(int_varaddr) DO_NOTHING +#endif + +/* Call dump_add_opaque_fixnum (&fixnum_var) to dump `fixnum_var', of type `Fixnum'. */ +#ifdef PDUMP +#define dump_add_opaque_fixnum(fixnum_varaddr) do { \ + Fixnum *dao_ = (fixnum_varaddr); /* type check */ \ + dump_add_opaque (dao_, sizeof (*dao_)); \ +} while (0) +#else +#define dump_add_opaque_fixnum(fixnum_varaddr) DO_NOTHING +#endif + /* Call dump_add_root_object (&var) to ensure that var is properly updated after pdump. */ #ifdef PDUMP void dump_add_root_object (Lisp_Object *); @@ -2354,6 +2395,9 @@ enum arith_comparison { arith_grtr_or_equal }; Lisp_Object arithcompare (Lisp_Object, Lisp_Object, enum arith_comparison); +/* Do NOT use word_to_lisp or wasteful_word_to_lisp to decode time_t's + unless you KNOW arg is non-negative. They cannot return negative + values! Use make_time. */ Lisp_Object word_to_lisp (unsigned int); unsigned int lisp_to_word (Lisp_Object); @@ -2392,6 +2436,7 @@ Bytind bytind_clip_to_bounds (Bytind, Bytind, Bytind); void buffer_insert1 (struct buffer *, Lisp_Object); Lisp_Object make_string_from_buffer (struct buffer *, Bufpos, Charcount); Lisp_Object make_string_from_buffer_no_extents (struct buffer *, Bufpos, Charcount); +Lisp_Object make_time (time_t); Lisp_Object save_excursion_save (void); Lisp_Object save_restriction_save (void); Lisp_Object save_excursion_restore (Lisp_Object); @@ -2414,10 +2459,13 @@ Lisp_Object decode_path (const char *); /* Nonzero means don't do interactive redisplay and don't change tty modes */ extern int noninteractive, noninteractive1; extern int fatal_error_in_progress; +extern int inhibit_non_essential_printing_operations; extern int preparing_for_armageddon; -extern int emacs_priority; +extern Fixnum emacs_priority; extern int running_asynch_code; extern int suppress_early_error_handler_backtrace; +void debug_break (void); +int debug_can_access_memory (void *ptr, Bytecount len); /* Defined in eval.c */ DECLARE_DOESNT_RETURN (signal_error (Lisp_Object, Lisp_Object)); @@ -3218,6 +3266,7 @@ extern Lisp_Object Qvariable_documentation, Qvariable_domain; extern Lisp_Object Qvoid_function, Qvoid_variable; extern Lisp_Object Qwindow_live_p, Qwrong_number_of_arguments; extern Lisp_Object Qwrong_type_argument, Qyes_or_no_p; +extern Lisp_Object Qgtk; #define SYMBOL(fou) extern Lisp_Object fou #define SYMBOL_KEYWORD(la_cle_est_fou) extern Lisp_Object la_cle_est_fou