diff options
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 784 |
1 files changed, 461 insertions, 323 deletions
diff --git a/src/lisp.h b/src/lisp.h index 09c504363fa..fb0e44520d6 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -20,47 +20,48 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 20 | #ifndef EMACS_LISP_H | 20 | #ifndef EMACS_LISP_H |
| 21 | #define EMACS_LISP_H | 21 | #define EMACS_LISP_H |
| 22 | 22 | ||
| 23 | #include <stdalign.h> | ||
| 23 | #include <stdarg.h> | 24 | #include <stdarg.h> |
| 25 | #include <stdbool.h> | ||
| 24 | #include <stddef.h> | 26 | #include <stddef.h> |
| 25 | #include <inttypes.h> | 27 | #include <inttypes.h> |
| 26 | #include <limits.h> | 28 | #include <limits.h> |
| 27 | 29 | ||
| 28 | #include <intprops.h> | 30 | #include <intprops.h> |
| 29 | 31 | ||
| 30 | /* Use the configure flag --enable-checking[=LIST] to enable various | 32 | INLINE_HEADER_BEGIN |
| 31 | types of run time checks for Lisp objects. */ | 33 | #ifndef LISP_INLINE |
| 32 | 34 | # define LISP_INLINE INLINE | |
| 33 | #ifdef GC_CHECK_CONS_LIST | ||
| 34 | extern void check_cons_list (void); | ||
| 35 | #define CHECK_CONS_LIST() check_cons_list () | ||
| 36 | #else | ||
| 37 | #define CHECK_CONS_LIST() ((void) 0) | ||
| 38 | #endif | 35 | #endif |
| 39 | 36 | ||
| 40 | /* Temporarily disable wider-than-pointer integers until they're tested more. | 37 | /* The ubiquitous max and min macros. */ |
| 41 | Build with CFLAGS='-DWIDE_EMACS_INT' to try them out. */ | 38 | #undef min |
| 42 | /* #undef WIDE_EMACS_INT */ | 39 | #undef max |
| 40 | #define max(a, b) ((a) > (b) ? (a) : (b)) | ||
| 41 | #define min(a, b) ((a) < (b) ? (a) : (b)) | ||
| 43 | 42 | ||
| 44 | /* EMACS_INT - signed integer wide enough to hold an Emacs value | 43 | /* EMACS_INT - signed integer wide enough to hold an Emacs value |
| 45 | EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if | 44 | EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if |
| 46 | pI - printf length modifier for EMACS_INT | 45 | pI - printf length modifier for EMACS_INT |
| 47 | EMACS_UINT - unsigned variant of EMACS_INT */ | 46 | EMACS_UINT - unsigned variant of EMACS_INT */ |
| 48 | #ifndef EMACS_INT | 47 | #ifndef EMACS_INT_MAX |
| 49 | # if LONG_MAX < LLONG_MAX && defined WIDE_EMACS_INT | 48 | # if LONG_MAX < LLONG_MAX && defined WIDE_EMACS_INT |
| 50 | # define EMACS_INT long long | 49 | typedef long long int EMACS_INT; |
| 50 | typedef unsigned long long int EMACS_UINT; | ||
| 51 | # define EMACS_INT_MAX LLONG_MAX | 51 | # define EMACS_INT_MAX LLONG_MAX |
| 52 | # define pI "ll" | 52 | # define pI "ll" |
| 53 | # elif INT_MAX < LONG_MAX | 53 | # elif INT_MAX < LONG_MAX |
| 54 | # define EMACS_INT long | 54 | typedef long int EMACS_INT; |
| 55 | typedef unsigned long int EMACS_UINT; | ||
| 55 | # define EMACS_INT_MAX LONG_MAX | 56 | # define EMACS_INT_MAX LONG_MAX |
| 56 | # define pI "l" | 57 | # define pI "l" |
| 57 | # else | 58 | # else |
| 58 | # define EMACS_INT int | 59 | typedef int EMACS_INT; |
| 60 | typedef unsigned int EMACS_UINT; | ||
| 59 | # define EMACS_INT_MAX INT_MAX | 61 | # define EMACS_INT_MAX INT_MAX |
| 60 | # define pI "" | 62 | # define pI "" |
| 61 | # endif | 63 | # endif |
| 62 | #endif | 64 | #endif |
| 63 | #define EMACS_UINT unsigned EMACS_INT | ||
| 64 | 65 | ||
| 65 | /* Number of bits in some machine integer types. */ | 66 | /* Number of bits in some machine integer types. */ |
| 66 | enum | 67 | enum |
| @@ -149,43 +150,46 @@ extern int suppress_checking EXTERNALLY_VISIBLE; | |||
| 149 | on the few static Lisp_Objects used: all the defsubr as well | 150 | on the few static Lisp_Objects used: all the defsubr as well |
| 150 | as the two special buffers buffer_defaults and buffer_local_symbols. */ | 151 | as the two special buffers buffer_defaults and buffer_local_symbols. */ |
| 151 | 152 | ||
| 152 | /* First, try and define DECL_ALIGN(type,var) which declares a static | 153 | enum Lisp_Bits |
| 153 | variable VAR of type TYPE with the added requirement that it be | 154 | { |
| 154 | TYPEBITS-aligned. */ | 155 | /* Number of bits in a Lisp_Object tag. This can be used in #if, |
| 155 | 156 | and for GDB's sake also as a regular symbol. */ | |
| 157 | GCTYPEBITS = | ||
| 156 | #define GCTYPEBITS 3 | 158 | #define GCTYPEBITS 3 |
| 157 | #define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS) | 159 | GCTYPEBITS, |
| 160 | |||
| 161 | /* 2**GCTYPEBITS. This must also be a macro that expands to a | ||
| 162 | literal integer constant, for MSVC. */ | ||
| 163 | GCALIGNMENT = | ||
| 164 | #define GCALIGNMENT 8 | ||
| 165 | GCALIGNMENT, | ||
| 166 | |||
| 167 | /* Number of bits in a Lisp_Object value, not counting the tag. */ | ||
| 168 | VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS, | ||
| 169 | |||
| 170 | /* Number of bits in a Lisp fixnum tag. */ | ||
| 171 | INTTYPEBITS = GCTYPEBITS - 1, | ||
| 172 | |||
| 173 | /* Number of bits in a Lisp fixnum value, not counting the tag. */ | ||
| 174 | FIXNUM_BITS = VALBITS + 1 | ||
| 175 | }; | ||
| 176 | |||
| 177 | #if GCALIGNMENT != 1 << GCTYPEBITS | ||
| 178 | # error "GCALIGNMENT and GCTYPEBITS are inconsistent" | ||
| 179 | #endif | ||
| 158 | 180 | ||
| 159 | /* The maximum value that can be stored in a EMACS_INT, assuming all | 181 | /* The maximum value that can be stored in a EMACS_INT, assuming all |
| 160 | bits other than the type bits contribute to a nonnegative signed value. | 182 | bits other than the type bits contribute to a nonnegative signed value. |
| 161 | This can be used in #if, e.g., '#if VAL_MAX < UINTPTR_MAX' below. */ | 183 | This can be used in #if, e.g., '#if VAL_MAX < UINTPTR_MAX' below. */ |
| 162 | #define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1)) | 184 | #define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1)) |
| 163 | 185 | ||
| 164 | #ifndef NO_DECL_ALIGN | ||
| 165 | # ifndef DECL_ALIGN | ||
| 166 | # if HAVE_ATTRIBUTE_ALIGNED | ||
| 167 | # define DECL_ALIGN(type, var) \ | ||
| 168 | type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var | ||
| 169 | # elif defined(_MSC_VER) | ||
| 170 | # define ALIGN_GCTYPEBITS 8 | ||
| 171 | # if (1 << GCTYPEBITS) != ALIGN_GCTYPEBITS | ||
| 172 | # error ALIGN_GCTYPEBITS is wrong! | ||
| 173 | # endif | ||
| 174 | # define DECL_ALIGN(type, var) \ | ||
| 175 | type __declspec(align(ALIGN_GCTYPEBITS)) var | ||
| 176 | # else | ||
| 177 | /* What directives do other compilers use? */ | ||
| 178 | # endif | ||
| 179 | # endif | ||
| 180 | #endif | ||
| 181 | |||
| 182 | /* Unless otherwise specified, use USE_LSB_TAG on systems where: */ | 186 | /* Unless otherwise specified, use USE_LSB_TAG on systems where: */ |
| 183 | #ifndef USE_LSB_TAG | 187 | #ifndef USE_LSB_TAG |
| 184 | /* 1. We know malloc returns a multiple of 8. */ | 188 | /* 1. We know malloc returns a multiple of 8. */ |
| 185 | # if (defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ \ | 189 | # if (defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ \ |
| 186 | || defined DARWIN_OS || defined __sun) | 190 | || defined DARWIN_OS || defined __sun) |
| 187 | /* 2. We can specify multiple-of-8 alignment on static variables. */ | 191 | /* 2. We can specify multiple-of-8 alignment on static variables. */ |
| 188 | # ifdef DECL_ALIGN | 192 | # ifdef alignas |
| 189 | /* 3. Pointers-as-ints exceed VAL_MAX. | 193 | /* 3. Pointers-as-ints exceed VAL_MAX. |
| 190 | On hosts where pointers-as-ints do not exceed VAL_MAX, USE_LSB_TAG is: | 194 | On hosts where pointers-as-ints do not exceed VAL_MAX, USE_LSB_TAG is: |
| 191 | a. unnecessary, because the top bits of an EMACS_INT are unused, and | 195 | a. unnecessary, because the top bits of an EMACS_INT are unused, and |
| @@ -197,16 +201,20 @@ extern int suppress_checking EXTERNALLY_VISIBLE; | |||
| 197 | # endif | 201 | # endif |
| 198 | # endif | 202 | # endif |
| 199 | #endif | 203 | #endif |
| 200 | #ifndef USE_LSB_TAG | 204 | #ifdef USE_LSB_TAG |
| 205 | # undef USE_LSB_TAG | ||
| 206 | enum enum_USE_LSB_TAG { USE_LSB_TAG = 1 }; | ||
| 207 | # define USE_LSB_TAG 1 | ||
| 208 | #else | ||
| 209 | enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 }; | ||
| 201 | # define USE_LSB_TAG 0 | 210 | # define USE_LSB_TAG 0 |
| 202 | #endif | 211 | #endif |
| 203 | 212 | ||
| 204 | /* If we cannot use 8-byte alignment, make DECL_ALIGN a no-op. */ | 213 | #ifndef alignas |
| 205 | #ifndef DECL_ALIGN | 214 | # define alignas(alignment) /* empty */ |
| 206 | # if USE_LSB_TAG | 215 | # if USE_LSB_TAG |
| 207 | # error "USE_LSB_TAG used without defining DECL_ALIGN" | 216 | # error "USE_LSB_TAG requires alignas" |
| 208 | # endif | 217 | # endif |
| 209 | # define DECL_ALIGN(type, var) type var | ||
| 210 | #endif | 218 | #endif |
| 211 | 219 | ||
| 212 | 220 | ||
| @@ -216,14 +224,9 @@ extern int suppress_checking EXTERNALLY_VISIBLE; | |||
| 216 | 224 | ||
| 217 | /* Lisp integers use 2 tags, to give them one extra bit, thus | 225 | /* Lisp integers use 2 tags, to give them one extra bit, thus |
| 218 | extending their range from, e.g., -2^28..2^28-1 to -2^29..2^29-1. */ | 226 | extending their range from, e.g., -2^28..2^28-1 to -2^29..2^29-1. */ |
| 219 | #define INTTYPEBITS (GCTYPEBITS - 1) | 227 | static EMACS_INT const INTMASK = EMACS_INT_MAX >> (INTTYPEBITS - 1); |
| 220 | #define FIXNUM_BITS (VALBITS + 1) | ||
| 221 | #define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1)) | ||
| 222 | #define LISP_INT_TAG Lisp_Int0 | ||
| 223 | #define case_Lisp_Int case Lisp_Int0: case Lisp_Int1 | 228 | #define case_Lisp_Int case Lisp_Int0: case Lisp_Int1 |
| 224 | #define LISP_INT1_TAG (USE_LSB_TAG ? 1 << INTTYPEBITS : 1) | 229 | #define LISP_INT_TAG_P(x) (((x) & ~Lisp_Int1) == 0) |
| 225 | #define LISP_STRING_TAG (5 - LISP_INT1_TAG) | ||
| 226 | #define LISP_INT_TAG_P(x) (((x) & ~LISP_INT1_TAG) == 0) | ||
| 227 | 230 | ||
| 228 | /* Stolen from GDB. The only known compiler that doesn't support | 231 | /* Stolen from GDB. The only known compiler that doesn't support |
| 229 | enums in bitfields is MSVC. */ | 232 | enums in bitfields is MSVC. */ |
| @@ -238,7 +241,7 @@ enum Lisp_Type | |||
| 238 | { | 241 | { |
| 239 | /* Integer. XINT (obj) is the integer value. */ | 242 | /* Integer. XINT (obj) is the integer value. */ |
| 240 | Lisp_Int0 = 0, | 243 | Lisp_Int0 = 0, |
| 241 | Lisp_Int1 = LISP_INT1_TAG, | 244 | Lisp_Int1 = USE_LSB_TAG ? 1 << INTTYPEBITS : 1, |
| 242 | 245 | ||
| 243 | /* Symbol. XSYMBOL (object) points to a struct Lisp_Symbol. */ | 246 | /* Symbol. XSYMBOL (object) points to a struct Lisp_Symbol. */ |
| 244 | Lisp_Symbol = 2, | 247 | Lisp_Symbol = 2, |
| @@ -249,7 +252,7 @@ enum Lisp_Type | |||
| 249 | 252 | ||
| 250 | /* String. XSTRING (object) points to a struct Lisp_String. | 253 | /* String. XSTRING (object) points to a struct Lisp_String. |
| 251 | The length of the string, and its contents, are stored therein. */ | 254 | The length of the string, and its contents, are stored therein. */ |
| 252 | Lisp_String = LISP_STRING_TAG, | 255 | Lisp_String = USE_LSB_TAG ? 1 : 1 << INTTYPEBITS, |
| 253 | 256 | ||
| 254 | /* Vector of Lisp objects, or something resembling it. | 257 | /* Vector of Lisp objects, or something resembling it. |
| 255 | XVECTOR (object) points to a struct Lisp_Vector, which contains | 258 | XVECTOR (object) points to a struct Lisp_Vector, which contains |
| @@ -298,14 +301,14 @@ enum Lisp_Fwd_Type | |||
| 298 | typedef struct { EMACS_INT i; } Lisp_Object; | 301 | typedef struct { EMACS_INT i; } Lisp_Object; |
| 299 | 302 | ||
| 300 | #define XLI(o) (o).i | 303 | #define XLI(o) (o).i |
| 301 | static inline Lisp_Object | 304 | LISP_INLINE Lisp_Object |
| 302 | XIL (EMACS_INT i) | 305 | XIL (EMACS_INT i) |
| 303 | { | 306 | { |
| 304 | Lisp_Object o = { i }; | 307 | Lisp_Object o = { i }; |
| 305 | return o; | 308 | return o; |
| 306 | } | 309 | } |
| 307 | 310 | ||
| 308 | static inline Lisp_Object | 311 | LISP_INLINE Lisp_Object |
| 309 | LISP_MAKE_RVALUE (Lisp_Object o) | 312 | LISP_MAKE_RVALUE (Lisp_Object o) |
| 310 | { | 313 | { |
| 311 | return o; | 314 | return o; |
| @@ -313,6 +316,8 @@ LISP_MAKE_RVALUE (Lisp_Object o) | |||
| 313 | 316 | ||
| 314 | #define LISP_INITIALLY_ZERO {0} | 317 | #define LISP_INITIALLY_ZERO {0} |
| 315 | 318 | ||
| 319 | #undef CHECK_LISP_OBJECT_TYPE | ||
| 320 | enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 1 }; | ||
| 316 | #else /* CHECK_LISP_OBJECT_TYPE */ | 321 | #else /* CHECK_LISP_OBJECT_TYPE */ |
| 317 | 322 | ||
| 318 | /* If a struct type is not wanted, define Lisp_Object as just a number. */ | 323 | /* If a struct type is not wanted, define Lisp_Object as just a number. */ |
| @@ -322,15 +327,20 @@ typedef EMACS_INT Lisp_Object; | |||
| 322 | #define XIL(i) (i) | 327 | #define XIL(i) (i) |
| 323 | #define LISP_MAKE_RVALUE(o) (0+(o)) | 328 | #define LISP_MAKE_RVALUE(o) (0+(o)) |
| 324 | #define LISP_INITIALLY_ZERO 0 | 329 | #define LISP_INITIALLY_ZERO 0 |
| 330 | enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 0 }; | ||
| 325 | #endif /* CHECK_LISP_OBJECT_TYPE */ | 331 | #endif /* CHECK_LISP_OBJECT_TYPE */ |
| 326 | 332 | ||
| 327 | /* In the size word of a vector, this bit means the vector has been marked. */ | 333 | /* In the size word of a vector, this bit means the vector has been marked. */ |
| 328 | 334 | ||
| 335 | static ptrdiff_t const ARRAY_MARK_FLAG | ||
| 329 | #define ARRAY_MARK_FLAG PTRDIFF_MIN | 336 | #define ARRAY_MARK_FLAG PTRDIFF_MIN |
| 337 | = ARRAY_MARK_FLAG; | ||
| 330 | 338 | ||
| 331 | /* In the size word of a struct Lisp_Vector, this bit means it's really | 339 | /* In the size word of a struct Lisp_Vector, this bit means it's really |
| 332 | some other vector-like object. */ | 340 | some other vector-like object. */ |
| 341 | static ptrdiff_t const PSEUDOVECTOR_FLAG | ||
| 333 | #define PSEUDOVECTOR_FLAG (PTRDIFF_MAX - PTRDIFF_MAX / 2) | 342 | #define PSEUDOVECTOR_FLAG (PTRDIFF_MAX - PTRDIFF_MAX / 2) |
| 343 | = PSEUDOVECTOR_FLAG; | ||
| 334 | 344 | ||
| 335 | /* In a pseudovector, the size field actually contains a word with one | 345 | /* In a pseudovector, the size field actually contains a word with one |
| 336 | PSEUDOVECTOR_FLAG bit set, and exactly one of the following bits to | 346 | PSEUDOVECTOR_FLAG bit set, and exactly one of the following bits to |
| @@ -363,18 +373,31 @@ enum pvec_type | |||
| 363 | PVEC_FONT = 0x40 | 373 | PVEC_FONT = 0x40 |
| 364 | }; | 374 | }; |
| 365 | 375 | ||
| 366 | /* For convenience, we also store the number of elements in these bits. | 376 | /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers |
| 367 | Note that this size is not necessarily the memory-footprint size, but | 377 | which were stored in a Lisp_Object. */ |
| 368 | only the number of Lisp_Object fields (that need to be traced by the GC). | 378 | #ifndef DATA_SEG_BITS |
| 369 | The distinction is used e.g. by Lisp_Process which places extra | 379 | # define DATA_SEG_BITS 0 |
| 370 | non-Lisp_Object fields at the end of the structure. */ | 380 | #endif |
| 371 | #define PSEUDOVECTOR_SIZE_BITS 16 | 381 | enum { gdb_DATA_SEG_BITS = DATA_SEG_BITS }; |
| 372 | #define PSEUDOVECTOR_SIZE_MASK ((1 << PSEUDOVECTOR_SIZE_BITS) - 1) | 382 | #undef DATA_SEG_BITS |
| 373 | #define PVEC_TYPE_MASK (0x0fff << PSEUDOVECTOR_SIZE_BITS) | 383 | |
| 374 | 384 | enum More_Lisp_Bits | |
| 375 | /* Number of bits to put in each character in the internal representation | 385 | { |
| 376 | of bool vectors. This should not vary across implementations. */ | 386 | DATA_SEG_BITS = gdb_DATA_SEG_BITS, |
| 377 | #define BOOL_VECTOR_BITS_PER_CHAR 8 | 387 | |
| 388 | /* For convenience, we also store the number of elements in these bits. | ||
| 389 | Note that this size is not necessarily the memory-footprint size, but | ||
| 390 | only the number of Lisp_Object fields (that need to be traced by GC). | ||
| 391 | The distinction is used, e.g., by Lisp_Process, which places extra | ||
| 392 | non-Lisp_Object fields at the end of the structure. */ | ||
| 393 | PSEUDOVECTOR_SIZE_BITS = 16, | ||
| 394 | PSEUDOVECTOR_SIZE_MASK = (1 << PSEUDOVECTOR_SIZE_BITS) - 1, | ||
| 395 | PVEC_TYPE_MASK = 0x0fff << PSEUDOVECTOR_SIZE_BITS, | ||
| 396 | |||
| 397 | /* Number of bits to put in each character in the internal representation | ||
| 398 | of bool vectors. This should not vary across implementations. */ | ||
| 399 | BOOL_VECTOR_BITS_PER_CHAR = 8 | ||
| 400 | }; | ||
| 378 | 401 | ||
| 379 | /* These macros extract various sorts of values from a Lisp_Object. | 402 | /* These macros extract various sorts of values from a Lisp_Object. |
| 380 | For example, if tem is a Lisp_Object whose type is Lisp_Cons, | 403 | For example, if tem is a Lisp_Object whose type is Lisp_Cons, |
| @@ -385,7 +408,11 @@ enum pvec_type | |||
| 385 | 408 | ||
| 386 | #if USE_LSB_TAG | 409 | #if USE_LSB_TAG |
| 387 | 410 | ||
| 388 | #define TYPEMASK ((1 << GCTYPEBITS) - 1) | 411 | enum lsb_bits |
| 412 | { | ||
| 413 | TYPEMASK = (1 << GCTYPEBITS) - 1, | ||
| 414 | VALMASK = ~ TYPEMASK | ||
| 415 | }; | ||
| 389 | #define XTYPE(a) ((enum Lisp_Type) (XLI (a) & TYPEMASK)) | 416 | #define XTYPE(a) ((enum Lisp_Type) (XLI (a) & TYPEMASK)) |
| 390 | #define XINT(a) (XLI (a) >> INTTYPEBITS) | 417 | #define XINT(a) (XLI (a) >> INTTYPEBITS) |
| 391 | #define XUINT(a) ((EMACS_UINT) XLI (a) >> INTTYPEBITS) | 418 | #define XUINT(a) ((EMACS_UINT) XLI (a) >> INTTYPEBITS) |
| @@ -399,7 +426,9 @@ enum pvec_type | |||
| 399 | 426 | ||
| 400 | #else /* not USE_LSB_TAG */ | 427 | #else /* not USE_LSB_TAG */ |
| 401 | 428 | ||
| 429 | static EMACS_INT const VALMASK | ||
| 402 | #define VALMASK VAL_MAX | 430 | #define VALMASK VAL_MAX |
| 431 | = VALMASK; | ||
| 403 | 432 | ||
| 404 | #define XTYPE(a) ((enum Lisp_Type) ((EMACS_UINT) XLI (a) >> VALBITS)) | 433 | #define XTYPE(a) ((enum Lisp_Type) ((EMACS_UINT) XLI (a) >> VALBITS)) |
| 405 | 434 | ||
| @@ -419,7 +448,7 @@ enum pvec_type | |||
| 419 | ((var) = XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ | 448 | ((var) = XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ |
| 420 | + ((intptr_t) (ptr) & VALMASK))) | 449 | + ((intptr_t) (ptr) & VALMASK))) |
| 421 | 450 | ||
| 422 | #ifdef DATA_SEG_BITS | 451 | #if DATA_SEG_BITS |
| 423 | /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers | 452 | /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers |
| 424 | which were stored in a Lisp_Object */ | 453 | which were stored in a Lisp_Object */ |
| 425 | #define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS)) | 454 | #define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS)) |
| @@ -447,9 +476,14 @@ enum pvec_type | |||
| 447 | #define EQ(x, y) (XHASH (x) == XHASH (y)) | 476 | #define EQ(x, y) (XHASH (x) == XHASH (y)) |
| 448 | 477 | ||
| 449 | /* Largest and smallest representable fixnum values. These are the C | 478 | /* Largest and smallest representable fixnum values. These are the C |
| 450 | values. */ | 479 | values. They are macros for use in static initializers, and |
| 480 | constants for visibility to GDB. */ | ||
| 481 | static EMACS_INT const MOST_POSITIVE_FIXNUM = | ||
| 451 | #define MOST_POSITIVE_FIXNUM (EMACS_INT_MAX >> INTTYPEBITS) | 482 | #define MOST_POSITIVE_FIXNUM (EMACS_INT_MAX >> INTTYPEBITS) |
| 483 | MOST_POSITIVE_FIXNUM; | ||
| 484 | static EMACS_INT const MOST_NEGATIVE_FIXNUM = | ||
| 452 | #define MOST_NEGATIVE_FIXNUM (-1 - MOST_POSITIVE_FIXNUM) | 485 | #define MOST_NEGATIVE_FIXNUM (-1 - MOST_POSITIVE_FIXNUM) |
| 486 | MOST_NEGATIVE_FIXNUM; | ||
| 453 | 487 | ||
| 454 | /* Value is non-zero if I doesn't fit into a Lisp fixnum. It is | 488 | /* Value is non-zero if I doesn't fit into a Lisp fixnum. It is |
| 455 | written this way so that it also works if I is of unsigned | 489 | written this way so that it also works if I is of unsigned |
| @@ -458,7 +492,7 @@ enum pvec_type | |||
| 458 | #define FIXNUM_OVERFLOW_P(i) \ | 492 | #define FIXNUM_OVERFLOW_P(i) \ |
| 459 | (! ((0 <= (i) || MOST_NEGATIVE_FIXNUM <= (i)) && (i) <= MOST_POSITIVE_FIXNUM)) | 493 | (! ((0 <= (i) || MOST_NEGATIVE_FIXNUM <= (i)) && (i) <= MOST_POSITIVE_FIXNUM)) |
| 460 | 494 | ||
| 461 | static inline ptrdiff_t | 495 | LISP_INLINE ptrdiff_t |
| 462 | clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | 496 | clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) |
| 463 | { | 497 | { |
| 464 | return num < lower ? lower : num <= upper ? num : upper; | 498 | return num < lower ? lower : num <= upper ? num : upper; |
| @@ -576,7 +610,7 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | |||
| 576 | #define ASET(ARRAY, IDX, VAL) \ | 610 | #define ASET(ARRAY, IDX, VAL) \ |
| 577 | (eassert ((IDX) == (IDX)), \ | 611 | (eassert ((IDX) == (IDX)), \ |
| 578 | eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)), \ | 612 | eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)), \ |
| 579 | AREF ((ARRAY), (IDX)) = (VAL)) | 613 | XVECTOR (ARRAY)->contents[IDX] = (VAL)) |
| 580 | 614 | ||
| 581 | /* Convenience macros for dealing with Lisp strings. */ | 615 | /* Convenience macros for dealing with Lisp strings. */ |
| 582 | 616 | ||
| @@ -600,38 +634,31 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | |||
| 600 | #define CHECK_TYPE(ok, Qxxxp, x) \ | 634 | #define CHECK_TYPE(ok, Qxxxp, x) \ |
| 601 | do { if (!(ok)) wrong_type_argument (Qxxxp, (x)); } while (0) | 635 | do { if (!(ok)) wrong_type_argument (Qxxxp, (x)); } while (0) |
| 602 | 636 | ||
| 637 | /* Deprecated and will be removed soon. */ | ||
| 638 | |||
| 639 | #define INTERNAL_FIELD(field) field ## _ | ||
| 603 | 640 | ||
| 604 | |||
| 605 | /* See the macros in intervals.h. */ | 641 | /* See the macros in intervals.h. */ |
| 606 | 642 | ||
| 607 | typedef struct interval *INTERVAL; | 643 | typedef struct interval *INTERVAL; |
| 608 | 644 | ||
| 609 | /* Complain if object is not string or buffer type */ | 645 | /* Complain if object is not string or buffer type. */ |
| 610 | #define CHECK_STRING_OR_BUFFER(x) \ | 646 | #define CHECK_STRING_OR_BUFFER(x) \ |
| 611 | CHECK_TYPE (STRINGP (x) || BUFFERP (x), Qbuffer_or_string_p, x) | 647 | CHECK_TYPE (STRINGP (x) || BUFFERP (x), Qbuffer_or_string_p, x) |
| 612 | 648 | ||
| 613 | |||
| 614 | /* In a cons, the markbit of the car is the gc mark bit */ | ||
| 615 | |||
| 616 | struct Lisp_Cons | 649 | struct Lisp_Cons |
| 617 | { | 650 | { |
| 618 | /* Please do not use the names of these elements in code other | 651 | /* Car of this cons cell. */ |
| 619 | than the core lisp implementation. Use XCAR and XCDR below. */ | ||
| 620 | #ifdef HIDE_LISP_IMPLEMENTATION | ||
| 621 | Lisp_Object car_; | ||
| 622 | union | ||
| 623 | { | ||
| 624 | Lisp_Object cdr_; | ||
| 625 | struct Lisp_Cons *chain; | ||
| 626 | } u; | ||
| 627 | #else | ||
| 628 | Lisp_Object car; | 652 | Lisp_Object car; |
| 653 | |||
| 629 | union | 654 | union |
| 630 | { | 655 | { |
| 656 | /* Cdr of this cons cell. */ | ||
| 631 | Lisp_Object cdr; | 657 | Lisp_Object cdr; |
| 658 | |||
| 659 | /* Used to chain conses on a free list. */ | ||
| 632 | struct Lisp_Cons *chain; | 660 | struct Lisp_Cons *chain; |
| 633 | } u; | 661 | } u; |
| 634 | #endif | ||
| 635 | }; | 662 | }; |
| 636 | 663 | ||
| 637 | /* Take the car or cdr of something known to be a cons cell. */ | 664 | /* Take the car or cdr of something known to be a cons cell. */ |
| @@ -641,13 +668,8 @@ struct Lisp_Cons | |||
| 641 | fields are not accessible as lvalues. (What if we want to switch to | 668 | fields are not accessible as lvalues. (What if we want to switch to |
| 642 | a copying collector someday? Cached cons cell field addresses may be | 669 | a copying collector someday? Cached cons cell field addresses may be |
| 643 | invalidated at arbitrary points.) */ | 670 | invalidated at arbitrary points.) */ |
| 644 | #ifdef HIDE_LISP_IMPLEMENTATION | 671 | #define XCAR_AS_LVALUE(c) (XCONS (c)->car) |
| 645 | #define XCAR_AS_LVALUE(c) (XCONS ((c))->car_) | 672 | #define XCDR_AS_LVALUE(c) (XCONS (c)->u.cdr) |
| 646 | #define XCDR_AS_LVALUE(c) (XCONS ((c))->u.cdr_) | ||
| 647 | #else | ||
| 648 | #define XCAR_AS_LVALUE(c) (XCONS ((c))->car) | ||
| 649 | #define XCDR_AS_LVALUE(c) (XCONS ((c))->u.cdr) | ||
| 650 | #endif | ||
| 651 | 673 | ||
| 652 | /* Use these from normal code. */ | 674 | /* Use these from normal code. */ |
| 653 | #define XCAR(c) LISP_MAKE_RVALUE (XCAR_AS_LVALUE (c)) | 675 | #define XCAR(c) LISP_MAKE_RVALUE (XCAR_AS_LVALUE (c)) |
| @@ -708,10 +730,15 @@ extern ptrdiff_t string_bytes (struct Lisp_String *); | |||
| 708 | Although the actual size limit (see STRING_BYTES_MAX in alloc.c) | 730 | Although the actual size limit (see STRING_BYTES_MAX in alloc.c) |
| 709 | may be a bit smaller than STRING_BYTES_BOUND, calculating it here | 731 | may be a bit smaller than STRING_BYTES_BOUND, calculating it here |
| 710 | would expose alloc.c internal details that we'd rather keep | 732 | would expose alloc.c internal details that we'd rather keep |
| 711 | private. The cast to ptrdiff_t ensures that STRING_BYTES_BOUND is | 733 | private. |
| 712 | signed. */ | 734 | |
| 735 | This is a macro for use in static initializers, and a constant for | ||
| 736 | visibility to GDB. The cast to ptrdiff_t ensures that | ||
| 737 | the macro is signed. */ | ||
| 738 | static ptrdiff_t const STRING_BYTES_BOUND = | ||
| 713 | #define STRING_BYTES_BOUND \ | 739 | #define STRING_BYTES_BOUND \ |
| 714 | min (MOST_POSITIVE_FIXNUM, (ptrdiff_t) min (SIZE_MAX, PTRDIFF_MAX) - 1) | 740 | ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, min (SIZE_MAX, PTRDIFF_MAX) - 1)) |
| 741 | STRING_BYTES_BOUND; | ||
| 715 | 742 | ||
| 716 | /* Mark STR as a unibyte string. */ | 743 | /* Mark STR as a unibyte string. */ |
| 717 | #define STRING_SET_UNIBYTE(STR) \ | 744 | #define STRING_SET_UNIBYTE(STR) \ |
| @@ -726,12 +753,6 @@ extern ptrdiff_t string_bytes (struct Lisp_String *); | |||
| 726 | (STR) = empty_multibyte_string; \ | 753 | (STR) = empty_multibyte_string; \ |
| 727 | else XSTRING (STR)->size_byte = XSTRING (STR)->size; } while (0) | 754 | else XSTRING (STR)->size_byte = XSTRING (STR)->size; } while (0) |
| 728 | 755 | ||
| 729 | /* Get text properties. */ | ||
| 730 | #define STRING_INTERVALS(STR) (XSTRING (STR)->intervals + 0) | ||
| 731 | |||
| 732 | /* Set text properties. */ | ||
| 733 | #define STRING_SET_INTERVALS(STR, INT) (XSTRING (STR)->intervals = (INT)) | ||
| 734 | |||
| 735 | /* In a string or vector, the sign bit of the `size' is the gc mark bit. */ | 756 | /* In a string or vector, the sign bit of the `size' is the gc mark bit. */ |
| 736 | 757 | ||
| 737 | struct Lisp_String | 758 | struct Lisp_String |
| @@ -790,25 +811,49 @@ struct vectorlike_header | |||
| 790 | } next; | 811 | } next; |
| 791 | }; | 812 | }; |
| 792 | 813 | ||
| 814 | /* Regular vector is just a header plus array of Lisp_Objects. */ | ||
| 815 | |||
| 793 | struct Lisp_Vector | 816 | struct Lisp_Vector |
| 794 | { | 817 | { |
| 795 | struct vectorlike_header header; | 818 | struct vectorlike_header header; |
| 796 | Lisp_Object contents[1]; | 819 | Lisp_Object contents[1]; |
| 797 | }; | 820 | }; |
| 798 | 821 | ||
| 822 | /* A boolvector is a kind of vectorlike, with contents are like a string. */ | ||
| 823 | |||
| 824 | struct Lisp_Bool_Vector | ||
| 825 | { | ||
| 826 | /* HEADER.SIZE is the vector's size field. It doesn't have the real size, | ||
| 827 | just the subtype information. */ | ||
| 828 | struct vectorlike_header header; | ||
| 829 | /* This is the size in bits. */ | ||
| 830 | EMACS_INT size; | ||
| 831 | /* This contains the actual bits, packed into bytes. */ | ||
| 832 | unsigned char data[1]; | ||
| 833 | }; | ||
| 834 | |||
| 835 | /* Some handy constants for calculating sizes | ||
| 836 | and offsets, mostly of vectorlike objects. */ | ||
| 837 | |||
| 838 | enum | ||
| 839 | { | ||
| 840 | header_size = offsetof (struct Lisp_Vector, contents), | ||
| 841 | bool_header_size = offsetof (struct Lisp_Bool_Vector, data), | ||
| 842 | word_size = sizeof (Lisp_Object) | ||
| 843 | }; | ||
| 844 | |||
| 799 | /* If a struct is made to look like a vector, this macro returns the length | 845 | /* If a struct is made to look like a vector, this macro returns the length |
| 800 | of the shortest vector that would hold that struct. */ | 846 | of the shortest vector that would hold that struct. */ |
| 801 | #define VECSIZE(type) ((sizeof (type) \ | 847 | |
| 802 | - offsetof (struct Lisp_Vector, contents[0]) \ | 848 | #define VECSIZE(type) \ |
| 803 | + sizeof (Lisp_Object) - 1) /* Round up. */ \ | 849 | ((sizeof (type) - header_size + word_size - 1) / word_size) |
| 804 | / sizeof (Lisp_Object)) | ||
| 805 | 850 | ||
| 806 | /* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields | 851 | /* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields |
| 807 | at the end and we need to compute the number of Lisp_Object fields (the | 852 | at the end and we need to compute the number of Lisp_Object fields (the |
| 808 | ones that the GC needs to trace). */ | 853 | ones that the GC needs to trace). */ |
| 809 | #define PSEUDOVECSIZE(type, nonlispfield) \ | 854 | |
| 810 | ((offsetof (type, nonlispfield) - offsetof (struct Lisp_Vector, contents[0])) \ | 855 | #define PSEUDOVECSIZE(type, nonlispfield) \ |
| 811 | / sizeof (Lisp_Object)) | 856 | ((offsetof (type, nonlispfield) - header_size) / word_size) |
| 812 | 857 | ||
| 813 | /* A char-table is a kind of vectorlike, with contents are like a | 858 | /* A char-table is a kind of vectorlike, with contents are like a |
| 814 | vector but with a few other slots. For some purposes, it makes | 859 | vector but with a few other slots. For some purposes, it makes |
| @@ -820,16 +865,6 @@ struct Lisp_Vector | |||
| 820 | of a char-table, and there's no way to access it directly from | 865 | of a char-table, and there's no way to access it directly from |
| 821 | Emacs Lisp program. */ | 866 | Emacs Lisp program. */ |
| 822 | 867 | ||
| 823 | /* This is the number of slots that every char table must have. This | ||
| 824 | counts the ordinary slots and the top, defalt, parent, and purpose | ||
| 825 | slots. */ | ||
| 826 | #define CHAR_TABLE_STANDARD_SLOTS (VECSIZE (struct Lisp_Char_Table) - 1) | ||
| 827 | |||
| 828 | /* Return the number of "extra" slots in the char table CT. */ | ||
| 829 | |||
| 830 | #define CHAR_TABLE_EXTRA_SLOTS(CT) \ | ||
| 831 | (((CT)->header.size & PSEUDOVECTOR_SIZE_MASK) - CHAR_TABLE_STANDARD_SLOTS) | ||
| 832 | |||
| 833 | #ifdef __GNUC__ | 868 | #ifdef __GNUC__ |
| 834 | 869 | ||
| 835 | #define CHAR_TABLE_REF_ASCII(CT, IDX) \ | 870 | #define CHAR_TABLE_REF_ASCII(CT, IDX) \ |
| @@ -888,17 +923,24 @@ struct Lisp_Vector | |||
| 888 | 8-bit European characters. Do not check validity of CT. */ | 923 | 8-bit European characters. Do not check validity of CT. */ |
| 889 | #define CHAR_TABLE_SET(CT, IDX, VAL) \ | 924 | #define CHAR_TABLE_SET(CT, IDX, VAL) \ |
| 890 | (ASCII_CHAR_P (IDX) && SUB_CHAR_TABLE_P (XCHAR_TABLE (CT)->ascii) \ | 925 | (ASCII_CHAR_P (IDX) && SUB_CHAR_TABLE_P (XCHAR_TABLE (CT)->ascii) \ |
| 891 | ? XSUB_CHAR_TABLE (XCHAR_TABLE (CT)->ascii)->contents[IDX] = VAL \ | 926 | ? sub_char_table_set_contents (XCHAR_TABLE (CT)->ascii, IDX, VAL) \ |
| 892 | : char_table_set (CT, IDX, VAL)) | 927 | : char_table_set (CT, IDX, VAL)) |
| 893 | 928 | ||
| 894 | #define CHARTAB_SIZE_BITS_0 6 | 929 | enum CHARTAB_SIZE_BITS |
| 895 | #define CHARTAB_SIZE_BITS_1 4 | 930 | { |
| 896 | #define CHARTAB_SIZE_BITS_2 5 | 931 | CHARTAB_SIZE_BITS_0 = 6, |
| 897 | #define CHARTAB_SIZE_BITS_3 7 | 932 | CHARTAB_SIZE_BITS_1 = 4, |
| 933 | CHARTAB_SIZE_BITS_2 = 5, | ||
| 934 | CHARTAB_SIZE_BITS_3 = 7 | ||
| 935 | }; | ||
| 898 | 936 | ||
| 899 | extern const int chartab_size[4]; | 937 | extern const int chartab_size[4]; |
| 900 | 938 | ||
| 901 | struct Lisp_Sub_Char_Table; | 939 | /* Most code should use this macro to set non-array Lisp fields in struct |
| 940 | Lisp_Char_Table. For CONTENTS and EXTRAS, use char_table_set_contents | ||
| 941 | and char_table_set_extras, respectively. */ | ||
| 942 | |||
| 943 | #define CSET(c, field, value) ((c)->field = (value)) | ||
| 902 | 944 | ||
| 903 | struct Lisp_Char_Table | 945 | struct Lisp_Char_Table |
| 904 | { | 946 | { |
| @@ -948,21 +990,10 @@ struct Lisp_Sub_Char_Table | |||
| 948 | /* Minimum character covered by the sub char-table. */ | 990 | /* Minimum character covered by the sub char-table. */ |
| 949 | Lisp_Object min_char; | 991 | Lisp_Object min_char; |
| 950 | 992 | ||
| 993 | /* Use sub_char_table_set_contents to set this. */ | ||
| 951 | Lisp_Object contents[1]; | 994 | Lisp_Object contents[1]; |
| 952 | }; | 995 | }; |
| 953 | 996 | ||
| 954 | /* A boolvector is a kind of vectorlike, with contents are like a string. */ | ||
| 955 | struct Lisp_Bool_Vector | ||
| 956 | { | ||
| 957 | /* HEADER.SIZE is the vector's size field. It doesn't have the real size, | ||
| 958 | just the subtype information. */ | ||
| 959 | struct vectorlike_header header; | ||
| 960 | /* This is the size in bits. */ | ||
| 961 | EMACS_INT size; | ||
| 962 | /* This contains the actual bits, packed into bytes. */ | ||
| 963 | unsigned char data[1]; | ||
| 964 | }; | ||
| 965 | |||
| 966 | /* This structure describes a built-in function. | 997 | /* This structure describes a built-in function. |
| 967 | It is generated by the DEFUN macro only. | 998 | It is generated by the DEFUN macro only. |
| 968 | defsubr makes it into a Lisp object. | 999 | defsubr makes it into a Lisp object. |
| @@ -993,6 +1024,19 @@ struct Lisp_Subr | |||
| 993 | const char *doc; | 1024 | const char *doc; |
| 994 | }; | 1025 | }; |
| 995 | 1026 | ||
| 1027 | /* This is the number of slots that every char table must have. This | ||
| 1028 | counts the ordinary slots and the top, defalt, parent, and purpose | ||
| 1029 | slots. */ | ||
| 1030 | enum CHAR_TABLE_STANDARD_SLOTS | ||
| 1031 | { | ||
| 1032 | CHAR_TABLE_STANDARD_SLOTS = VECSIZE (struct Lisp_Char_Table) - 1 | ||
| 1033 | }; | ||
| 1034 | |||
| 1035 | /* Return the number of "extra" slots in the char table CT. */ | ||
| 1036 | |||
| 1037 | #define CHAR_TABLE_EXTRA_SLOTS(CT) \ | ||
| 1038 | (((CT)->header.size & PSEUDOVECTOR_SIZE_MASK) - CHAR_TABLE_STANDARD_SLOTS) | ||
| 1039 | |||
| 996 | 1040 | ||
| 997 | /*********************************************************************** | 1041 | /*********************************************************************** |
| 998 | Symbols | 1042 | Symbols |
| @@ -1039,10 +1083,8 @@ struct Lisp_Symbol | |||
| 1039 | special (with `defvar' etc), and shouldn't be lexically bound. */ | 1083 | special (with `defvar' etc), and shouldn't be lexically bound. */ |
| 1040 | unsigned declared_special : 1; | 1084 | unsigned declared_special : 1; |
| 1041 | 1085 | ||
| 1042 | /* The symbol's name, as a Lisp string. | 1086 | /* The symbol's name, as a Lisp string. */ |
| 1043 | The name "xname" is used to intentionally break code referring to | 1087 | Lisp_Object name; |
| 1044 | the old field "name" of type pointer to struct Lisp_String. */ | ||
| 1045 | Lisp_Object xname; | ||
| 1046 | 1088 | ||
| 1047 | /* Value of the symbol or Qunbound if unbound. Which alternative of the | 1089 | /* Value of the symbol or Qunbound if unbound. Which alternative of the |
| 1048 | union is used depends on the `redirect' field above. */ | 1090 | union is used depends on the `redirect' field above. */ |
| @@ -1065,43 +1107,42 @@ struct Lisp_Symbol | |||
| 1065 | 1107 | ||
| 1066 | /* Value is name of symbol. */ | 1108 | /* Value is name of symbol. */ |
| 1067 | 1109 | ||
| 1068 | #define SYMBOL_VAL(sym) \ | 1110 | #define SYMBOL_VAL(sym) \ |
| 1069 | (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value) | 1111 | (eassert ((sym)->redirect == SYMBOL_PLAINVAL), sym->val.value) |
| 1070 | #define SYMBOL_ALIAS(sym) \ | 1112 | #define SYMBOL_ALIAS(sym) \ |
| 1071 | (eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias) | 1113 | (eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias) |
| 1072 | #define SYMBOL_BLV(sym) \ | 1114 | #define SYMBOL_BLV(sym) \ |
| 1073 | (eassert ((sym)->redirect == SYMBOL_LOCALIZED), (sym)->val.blv) | 1115 | (eassert ((sym)->redirect == SYMBOL_LOCALIZED), (sym)->val.blv) |
| 1074 | #define SYMBOL_FWD(sym) \ | 1116 | #define SYMBOL_FWD(sym) \ |
| 1075 | (eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd) | 1117 | (eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd) |
| 1076 | #define SET_SYMBOL_VAL(sym, v) \ | 1118 | #define SET_SYMBOL_VAL(sym, v) \ |
| 1077 | (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v)) | 1119 | (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v)) |
| 1078 | #define SET_SYMBOL_ALIAS(sym, v) \ | 1120 | #define SET_SYMBOL_ALIAS(sym, v) \ |
| 1079 | (eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias = (v)) | 1121 | (eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias = (v)) |
| 1080 | #define SET_SYMBOL_BLV(sym, v) \ | 1122 | #define SET_SYMBOL_BLV(sym, v) \ |
| 1081 | (eassert ((sym)->redirect == SYMBOL_LOCALIZED), (sym)->val.blv = (v)) | 1123 | (eassert ((sym)->redirect == SYMBOL_LOCALIZED), (sym)->val.blv = (v)) |
| 1082 | #define SET_SYMBOL_FWD(sym, v) \ | 1124 | #define SET_SYMBOL_FWD(sym, v) \ |
| 1083 | (eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd = (v)) | 1125 | (eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd = (v)) |
| 1084 | 1126 | ||
| 1085 | #define SYMBOL_NAME(sym) \ | 1127 | #define SYMBOL_NAME(sym) XSYMBOL (sym)->name |
| 1086 | LISP_MAKE_RVALUE (XSYMBOL (sym)->xname) | ||
| 1087 | 1128 | ||
| 1088 | /* Value is non-zero if SYM is an interned symbol. */ | 1129 | /* Value is non-zero if SYM is an interned symbol. */ |
| 1089 | 1130 | ||
| 1090 | #define SYMBOL_INTERNED_P(sym) \ | 1131 | #define SYMBOL_INTERNED_P(sym) \ |
| 1091 | (XSYMBOL (sym)->interned != SYMBOL_UNINTERNED) | 1132 | (XSYMBOL (sym)->interned != SYMBOL_UNINTERNED) |
| 1092 | 1133 | ||
| 1093 | /* Value is non-zero if SYM is interned in initial_obarray. */ | 1134 | /* Value is non-zero if SYM is interned in initial_obarray. */ |
| 1094 | 1135 | ||
| 1095 | #define SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P(sym) \ | 1136 | #define SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P(sym) \ |
| 1096 | (XSYMBOL (sym)->interned == SYMBOL_INTERNED_IN_INITIAL_OBARRAY) | 1137 | (XSYMBOL (sym)->interned == SYMBOL_INTERNED_IN_INITIAL_OBARRAY) |
| 1097 | 1138 | ||
| 1098 | /* Value is non-zero if symbol is considered a constant, i.e. its | 1139 | /* Value is non-zero if symbol is considered a constant, i.e. its |
| 1099 | value cannot be changed (there is an exception for keyword symbols, | 1140 | value cannot be changed (there is an exception for keyword symbols, |
| 1100 | whose value can be set to the keyword symbol itself). */ | 1141 | whose value can be set to the keyword symbol itself). */ |
| 1101 | 1142 | ||
| 1102 | #define SYMBOL_CONSTANT_P(sym) XSYMBOL (sym)->constant | 1143 | #define SYMBOL_CONSTANT_P(sym) XSYMBOL (sym)->constant |
| 1103 | 1144 | ||
| 1104 | #define DEFSYM(sym, name) \ | 1145 | #define DEFSYM(sym, name) \ |
| 1105 | do { (sym) = intern_c_string ((name)); staticpro (&(sym)); } while (0) | 1146 | do { (sym) = intern_c_string ((name)); staticpro (&(sym)); } while (0) |
| 1106 | 1147 | ||
| 1107 | 1148 | ||
| @@ -1220,19 +1261,18 @@ struct Lisp_Hash_Table | |||
| 1220 | 1261 | ||
| 1221 | /* Default size for hash tables if not specified. */ | 1262 | /* Default size for hash tables if not specified. */ |
| 1222 | 1263 | ||
| 1223 | #define DEFAULT_HASH_SIZE 65 | 1264 | enum DEFAULT_HASH_SIZE { DEFAULT_HASH_SIZE = 65 }; |
| 1224 | 1265 | ||
| 1225 | /* Default threshold specifying when to resize a hash table. The | 1266 | /* Default threshold specifying when to resize a hash table. The |
| 1226 | value gives the ratio of current entries in the hash table and the | 1267 | value gives the ratio of current entries in the hash table and the |
| 1227 | size of the hash table. */ | 1268 | size of the hash table. */ |
| 1228 | 1269 | ||
| 1229 | #define DEFAULT_REHASH_THRESHOLD 0.8 | 1270 | static double const DEFAULT_REHASH_THRESHOLD = 0.8; |
| 1230 | 1271 | ||
| 1231 | /* Default factor by which to increase the size of a hash table. */ | 1272 | /* Default factor by which to increase the size of a hash table. */ |
| 1232 | 1273 | ||
| 1233 | #define DEFAULT_REHASH_SIZE 1.5 | 1274 | static double const DEFAULT_REHASH_SIZE = 1.5; |
| 1234 | 1275 | ||
| 1235 | |||
| 1236 | /* These structures are used for various misc types. */ | 1276 | /* These structures are used for various misc types. */ |
| 1237 | 1277 | ||
| 1238 | struct Lisp_Misc_Any /* Supertype of all Misc types. */ | 1278 | struct Lisp_Misc_Any /* Supertype of all Misc types. */ |
| @@ -1288,12 +1328,13 @@ struct Lisp_Marker | |||
| 1288 | struct Lisp_Overlay | 1328 | struct Lisp_Overlay |
| 1289 | /* An overlay's real data content is: | 1329 | /* An overlay's real data content is: |
| 1290 | - plist | 1330 | - plist |
| 1291 | - buffer | 1331 | - buffer (really there are two buffer pointers, one per marker, |
| 1292 | - insertion type of both ends | 1332 | and both points to the same buffer) |
| 1293 | - start & start_byte | 1333 | - insertion type of both ends (per-marker fields) |
| 1294 | - end & end_byte | 1334 | - start & start byte (of start marker) |
| 1295 | - next (singly linked list of overlays). | 1335 | - end & end byte (of end marker) |
| 1296 | - start_next and end_next (singly linked list of markers). | 1336 | - next (singly linked list of overlays) |
| 1337 | - next fields of start and end markers (singly linked list of markers). | ||
| 1297 | I.e. 9words plus 2 bits, 3words of which are for external linked lists. | 1338 | I.e. 9words plus 2 bits, 3words of which are for external linked lists. |
| 1298 | */ | 1339 | */ |
| 1299 | { | 1340 | { |
| @@ -1301,7 +1342,9 @@ struct Lisp_Overlay | |||
| 1301 | unsigned gcmarkbit : 1; | 1342 | unsigned gcmarkbit : 1; |
| 1302 | int spacer : 15; | 1343 | int spacer : 15; |
| 1303 | struct Lisp_Overlay *next; | 1344 | struct Lisp_Overlay *next; |
| 1304 | Lisp_Object start, end, plist; | 1345 | Lisp_Object start; |
| 1346 | Lisp_Object end; | ||
| 1347 | Lisp_Object plist; | ||
| 1305 | }; | 1348 | }; |
| 1306 | 1349 | ||
| 1307 | /* Hold a C pointer for later use. | 1350 | /* Hold a C pointer for later use. |
| @@ -1357,7 +1400,7 @@ struct Lisp_Intfwd | |||
| 1357 | struct Lisp_Boolfwd | 1400 | struct Lisp_Boolfwd |
| 1358 | { | 1401 | { |
| 1359 | enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Bool */ | 1402 | enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Bool */ |
| 1360 | int *boolvar; | 1403 | bool *boolvar; |
| 1361 | }; | 1404 | }; |
| 1362 | 1405 | ||
| 1363 | /* Forwarding pointer to a Lisp_Object variable. | 1406 | /* Forwarding pointer to a Lisp_Object variable. |
| @@ -1459,23 +1502,13 @@ struct Lisp_Float | |||
| 1459 | { | 1502 | { |
| 1460 | union | 1503 | union |
| 1461 | { | 1504 | { |
| 1462 | #ifdef HIDE_LISP_IMPLEMENTATION | ||
| 1463 | double data_; | ||
| 1464 | #else | ||
| 1465 | double data; | 1505 | double data; |
| 1466 | #endif | ||
| 1467 | struct Lisp_Float *chain; | 1506 | struct Lisp_Float *chain; |
| 1468 | } u; | 1507 | } u; |
| 1469 | }; | 1508 | }; |
| 1470 | 1509 | ||
| 1471 | #ifdef HIDE_LISP_IMPLEMENTATION | 1510 | #define XFLOAT_DATA(f) (0 ? XFLOAT (f)->u.data : XFLOAT (f)->u.data) |
| 1472 | #define XFLOAT_DATA(f) (0 ? XFLOAT (f)->u.data_ : XFLOAT (f)->u.data_) | 1511 | #define XFLOAT_INIT(f, n) (XFLOAT (f)->u.data = (n)) |
| 1473 | #else | ||
| 1474 | #define XFLOAT_DATA(f) (0 ? XFLOAT (f)->u.data : XFLOAT (f)->u.data) | ||
| 1475 | /* This should be used only in alloc.c, which always disables | ||
| 1476 | HIDE_LISP_IMPLEMENTATION. */ | ||
| 1477 | #define XFLOAT_INIT(f,n) (XFLOAT (f)->u.data = (n)) | ||
| 1478 | #endif | ||
| 1479 | 1512 | ||
| 1480 | /* A character, declared with the following typedef, is a member | 1513 | /* A character, declared with the following typedef, is a member |
| 1481 | of some character set associated with the current buffer. */ | 1514 | of some character set associated with the current buffer. */ |
| @@ -1486,31 +1519,38 @@ typedef unsigned char UCHAR; | |||
| 1486 | 1519 | ||
| 1487 | /* Meanings of slots in a Lisp_Compiled: */ | 1520 | /* Meanings of slots in a Lisp_Compiled: */ |
| 1488 | 1521 | ||
| 1489 | #define COMPILED_ARGLIST 0 | 1522 | enum Lisp_Compiled |
| 1490 | #define COMPILED_BYTECODE 1 | 1523 | { |
| 1491 | #define COMPILED_CONSTANTS 2 | 1524 | COMPILED_ARGLIST = 0, |
| 1492 | #define COMPILED_STACK_DEPTH 3 | 1525 | COMPILED_BYTECODE = 1, |
| 1493 | #define COMPILED_DOC_STRING 4 | 1526 | COMPILED_CONSTANTS = 2, |
| 1494 | #define COMPILED_INTERACTIVE 5 | 1527 | COMPILED_STACK_DEPTH = 3, |
| 1528 | COMPILED_DOC_STRING = 4, | ||
| 1529 | COMPILED_INTERACTIVE = 5 | ||
| 1530 | }; | ||
| 1495 | 1531 | ||
| 1496 | /* Flag bits in a character. These also get used in termhooks.h. | 1532 | /* Flag bits in a character. These also get used in termhooks.h. |
| 1497 | Richard Stallman <rms@gnu.ai.mit.edu> thinks that MULE | 1533 | Richard Stallman <rms@gnu.ai.mit.edu> thinks that MULE |
| 1498 | (MUlti-Lingual Emacs) might need 22 bits for the character value | 1534 | (MUlti-Lingual Emacs) might need 22 bits for the character value |
| 1499 | itself, so we probably shouldn't use any bits lower than 0x0400000. */ | 1535 | itself, so we probably shouldn't use any bits lower than 0x0400000. */ |
| 1500 | #define CHAR_ALT (0x0400000) | 1536 | enum char_bits |
| 1501 | #define CHAR_SUPER (0x0800000) | 1537 | { |
| 1502 | #define CHAR_HYPER (0x1000000) | 1538 | CHAR_ALT = 0x0400000, |
| 1503 | #define CHAR_SHIFT (0x2000000) | 1539 | CHAR_SUPER = 0x0800000, |
| 1504 | #define CHAR_CTL (0x4000000) | 1540 | CHAR_HYPER = 0x1000000, |
| 1505 | #define CHAR_META (0x8000000) | 1541 | CHAR_SHIFT = 0x2000000, |
| 1506 | 1542 | CHAR_CTL = 0x4000000, | |
| 1507 | #define CHAR_MODIFIER_MASK \ | 1543 | CHAR_META = 0x8000000, |
| 1508 | (CHAR_ALT | CHAR_SUPER | CHAR_HYPER | CHAR_SHIFT | CHAR_CTL | CHAR_META) | 1544 | |
| 1545 | CHAR_MODIFIER_MASK = | ||
| 1546 | CHAR_ALT | CHAR_SUPER | CHAR_HYPER | CHAR_SHIFT | CHAR_CTL | CHAR_META, | ||
| 1547 | |||
| 1548 | /* Actually, the current Emacs uses 22 bits for the character value | ||
| 1549 | itself. */ | ||
| 1550 | CHARACTERBITS = 22 | ||
| 1551 | }; | ||
| 1509 | 1552 | ||
| 1510 | 1553 | ||
| 1511 | /* Actually, the current Emacs uses 22 bits for the character value | ||
| 1512 | itself. */ | ||
| 1513 | #define CHARACTERBITS 22 | ||
| 1514 | 1554 | ||
| 1515 | 1555 | ||
| 1516 | /* The glyph datatype, used to represent characters on the display. | 1556 | /* The glyph datatype, used to represent characters on the display. |
| @@ -1567,9 +1607,6 @@ typedef struct { | |||
| 1567 | (XINT (gc) >> CHARACTERBITS)); \ | 1607 | (XINT (gc) >> CHARACTERBITS)); \ |
| 1568 | } \ | 1608 | } \ |
| 1569 | while (0) | 1609 | while (0) |
| 1570 | |||
| 1571 | /* The ID of the mode line highlighting face. */ | ||
| 1572 | #define GLYPH_MODE_LINE_FACE 1 | ||
| 1573 | 1610 | ||
| 1574 | /* Structure to hold mouse highlight data. This is here because other | 1611 | /* Structure to hold mouse highlight data. This is here because other |
| 1575 | header files need it for defining struct x_output etc. */ | 1612 | header files need it for defining struct x_output etc. */ |
| @@ -1721,15 +1758,19 @@ typedef struct { | |||
| 1721 | #define CHECK_WINDOW_CONFIGURATION(x) \ | 1758 | #define CHECK_WINDOW_CONFIGURATION(x) \ |
| 1722 | CHECK_TYPE (WINDOW_CONFIGURATIONP (x), Qwindow_configuration_p, x) | 1759 | CHECK_TYPE (WINDOW_CONFIGURATIONP (x), Qwindow_configuration_p, x) |
| 1723 | 1760 | ||
| 1724 | /* This macro rejects windows on the interior of the window tree as | 1761 | /* A window of any sort, leaf or interior, is "valid" if one of its |
| 1725 | "dead", which is what we want; this is an argument-checking macro, and | 1762 | buffer, vchild, or hchild members is non-nil. */ |
| 1726 | the user should never get access to interior windows. | 1763 | #define CHECK_VALID_WINDOW(x) \ |
| 1764 | CHECK_TYPE (WINDOWP (x) \ | ||
| 1765 | && (!NILP (XWINDOW (x)->buffer) \ | ||
| 1766 | || !NILP (XWINDOW (x)->vchild) \ | ||
| 1767 | || !NILP (XWINDOW (x)->hchild)), \ | ||
| 1768 | Qwindow_valid_p, x) | ||
| 1727 | 1769 | ||
| 1728 | A window of any sort, leaf or interior, is dead if the buffer, | 1770 | /* A window is "live" if and only if it shows a buffer. */ |
| 1729 | vchild, and hchild members are all nil. */ | 1771 | #define CHECK_LIVE_WINDOW(x) \ |
| 1730 | 1772 | CHECK_TYPE (WINDOWP (x) && !NILP (XWINDOW (x)->buffer), \ | |
| 1731 | #define CHECK_LIVE_WINDOW(x) \ | 1773 | Qwindow_live_p, x) |
| 1732 | CHECK_TYPE (WINDOWP (x) && !NILP (XWINDOW (x)->buffer), Qwindow_live_p, x) | ||
| 1733 | 1774 | ||
| 1734 | #define CHECK_PROCESS(x) \ | 1775 | #define CHECK_PROCESS(x) \ |
| 1735 | CHECK_TYPE (PROCESSP (x), Qprocessp, x) | 1776 | CHECK_TYPE (PROCESSP (x), Qprocessp, x) |
| @@ -1844,7 +1885,7 @@ typedef struct { | |||
| 1844 | #ifdef _MSC_VER | 1885 | #ifdef _MSC_VER |
| 1845 | #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ | 1886 | #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ |
| 1846 | Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ | 1887 | Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ |
| 1847 | static DECL_ALIGN (struct Lisp_Subr, sname) = \ | 1888 | static struct Lisp_Subr alignas (GCALIGNMENT) sname = \ |
| 1848 | { (PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS) \ | 1889 | { (PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS) \ |
| 1849 | | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \ | 1890 | | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \ |
| 1850 | { (Lisp_Object (__cdecl *)(void))fnname }, \ | 1891 | { (Lisp_Object (__cdecl *)(void))fnname }, \ |
| @@ -1853,7 +1894,7 @@ typedef struct { | |||
| 1853 | #else /* not _MSC_VER */ | 1894 | #else /* not _MSC_VER */ |
| 1854 | #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ | 1895 | #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ |
| 1855 | Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ | 1896 | Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ |
| 1856 | static DECL_ALIGN (struct Lisp_Subr, sname) = \ | 1897 | static struct Lisp_Subr alignas (GCALIGNMENT) sname = \ |
| 1857 | { PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS, \ | 1898 | { PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS, \ |
| 1858 | { .a ## maxargs = fnname }, \ | 1899 | { .a ## maxargs = fnname }, \ |
| 1859 | minargs, maxargs, lname, intspec, 0}; \ | 1900 | minargs, maxargs, lname, intspec, 0}; \ |
| @@ -1889,12 +1930,15 @@ typedef struct { | |||
| 1889 | is how we define the symbol for function `name' at start-up time. */ | 1930 | is how we define the symbol for function `name' at start-up time. */ |
| 1890 | extern void defsubr (struct Lisp_Subr *); | 1931 | extern void defsubr (struct Lisp_Subr *); |
| 1891 | 1932 | ||
| 1892 | #define MANY -2 | 1933 | enum maxargs |
| 1893 | #define UNEVALLED -1 | 1934 | { |
| 1935 | MANY = -2, | ||
| 1936 | UNEVALLED = -1 | ||
| 1937 | }; | ||
| 1894 | 1938 | ||
| 1895 | extern void defvar_lisp (struct Lisp_Objfwd *, const char *, Lisp_Object *); | 1939 | extern void defvar_lisp (struct Lisp_Objfwd *, const char *, Lisp_Object *); |
| 1896 | extern void defvar_lisp_nopro (struct Lisp_Objfwd *, const char *, Lisp_Object *); | 1940 | extern void defvar_lisp_nopro (struct Lisp_Objfwd *, const char *, Lisp_Object *); |
| 1897 | extern void defvar_bool (struct Lisp_Boolfwd *, const char *, int *); | 1941 | extern void defvar_bool (struct Lisp_Boolfwd *, const char *, bool *); |
| 1898 | extern void defvar_int (struct Lisp_Intfwd *, const char *, EMACS_INT *); | 1942 | extern void defvar_int (struct Lisp_Intfwd *, const char *, EMACS_INT *); |
| 1899 | extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int); | 1943 | extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int); |
| 1900 | 1944 | ||
| @@ -2091,14 +2135,6 @@ extern void process_quit_flag (void); | |||
| 2091 | extern Lisp_Object Vascii_downcase_table; | 2135 | extern Lisp_Object Vascii_downcase_table; |
| 2092 | extern Lisp_Object Vascii_canon_table; | 2136 | extern Lisp_Object Vascii_canon_table; |
| 2093 | 2137 | ||
| 2094 | /* Number of bytes of structure consed since last GC. */ | ||
| 2095 | |||
| 2096 | extern EMACS_INT consing_since_gc; | ||
| 2097 | |||
| 2098 | extern EMACS_INT gc_relative_threshold; | ||
| 2099 | |||
| 2100 | extern EMACS_INT memory_full_cons_threshold; | ||
| 2101 | |||
| 2102 | /* Structure for recording stack slots that need marking. */ | 2138 | /* Structure for recording stack slots that need marking. */ |
| 2103 | 2139 | ||
| 2104 | /* This is a chain of structures, each of which points at a Lisp_Object | 2140 | /* This is a chain of structures, each of which points at a Lisp_Object |
| @@ -2305,6 +2341,126 @@ void staticpro (Lisp_Object *); | |||
| 2305 | struct window; | 2341 | struct window; |
| 2306 | struct frame; | 2342 | struct frame; |
| 2307 | 2343 | ||
| 2344 | /* Simple access functions. */ | ||
| 2345 | |||
| 2346 | LISP_INLINE Lisp_Object * | ||
| 2347 | aref_addr (Lisp_Object array, ptrdiff_t idx) | ||
| 2348 | { | ||
| 2349 | return & XVECTOR (array)->contents[idx]; | ||
| 2350 | } | ||
| 2351 | |||
| 2352 | LISP_INLINE void | ||
| 2353 | gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val) | ||
| 2354 | { | ||
| 2355 | /* Like ASET, but also can be used in the garbage collector: | ||
| 2356 | sweep_weak_table calls set_hash_key etc. while the table is marked. */ | ||
| 2357 | eassert (0 <= idx && idx < (ASIZE (array) & ~ARRAY_MARK_FLAG)); | ||
| 2358 | XVECTOR (array)->contents[idx] = val; | ||
| 2359 | } | ||
| 2360 | |||
| 2361 | LISP_INLINE void | ||
| 2362 | set_hash_key (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) | ||
| 2363 | { | ||
| 2364 | gc_aset (h->key_and_value, 2 * idx, val); | ||
| 2365 | } | ||
| 2366 | |||
| 2367 | LISP_INLINE void | ||
| 2368 | set_hash_value (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) | ||
| 2369 | { | ||
| 2370 | gc_aset (h->key_and_value, 2 * idx + 1, val); | ||
| 2371 | } | ||
| 2372 | |||
| 2373 | LISP_INLINE void | ||
| 2374 | set_hash_next (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) | ||
| 2375 | { | ||
| 2376 | gc_aset (h->next, idx, val); | ||
| 2377 | } | ||
| 2378 | |||
| 2379 | LISP_INLINE void | ||
| 2380 | set_hash_hash (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) | ||
| 2381 | { | ||
| 2382 | gc_aset (h->hash, idx, val); | ||
| 2383 | } | ||
| 2384 | |||
| 2385 | LISP_INLINE void | ||
| 2386 | set_hash_index (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) | ||
| 2387 | { | ||
| 2388 | gc_aset (h->index, idx, val); | ||
| 2389 | } | ||
| 2390 | |||
| 2391 | /* Use these functions to set Lisp_Object | ||
| 2392 | or pointer slots of struct Lisp_Symbol. */ | ||
| 2393 | |||
| 2394 | LISP_INLINE void | ||
| 2395 | set_symbol_name (Lisp_Object sym, Lisp_Object name) | ||
| 2396 | { | ||
| 2397 | XSYMBOL (sym)->name = name; | ||
| 2398 | } | ||
| 2399 | |||
| 2400 | LISP_INLINE void | ||
| 2401 | set_symbol_function (Lisp_Object sym, Lisp_Object function) | ||
| 2402 | { | ||
| 2403 | XSYMBOL (sym)->function = function; | ||
| 2404 | } | ||
| 2405 | |||
| 2406 | LISP_INLINE void | ||
| 2407 | set_symbol_plist (Lisp_Object sym, Lisp_Object plist) | ||
| 2408 | { | ||
| 2409 | XSYMBOL (sym)->plist = plist; | ||
| 2410 | } | ||
| 2411 | |||
| 2412 | LISP_INLINE void | ||
| 2413 | set_symbol_next (Lisp_Object sym, struct Lisp_Symbol *next) | ||
| 2414 | { | ||
| 2415 | XSYMBOL (sym)->next = next; | ||
| 2416 | } | ||
| 2417 | |||
| 2418 | /* Set overlay's property list. */ | ||
| 2419 | |||
| 2420 | LISP_INLINE void | ||
| 2421 | set_overlay_plist (Lisp_Object overlay, Lisp_Object plist) | ||
| 2422 | { | ||
| 2423 | XOVERLAY (overlay)->plist = plist; | ||
| 2424 | } | ||
| 2425 | |||
| 2426 | /* Get text properties of S. */ | ||
| 2427 | |||
| 2428 | LISP_INLINE INTERVAL | ||
| 2429 | string_get_intervals (Lisp_Object s) | ||
| 2430 | { | ||
| 2431 | return XSTRING (s)->intervals; | ||
| 2432 | } | ||
| 2433 | |||
| 2434 | /* Set text properties of S to I. */ | ||
| 2435 | |||
| 2436 | LISP_INLINE void | ||
| 2437 | string_set_intervals (Lisp_Object s, INTERVAL i) | ||
| 2438 | { | ||
| 2439 | XSTRING (s)->intervals = i; | ||
| 2440 | } | ||
| 2441 | |||
| 2442 | /* Set different slots in (sub)character tables. */ | ||
| 2443 | |||
| 2444 | LISP_INLINE void | ||
| 2445 | char_table_set_extras (Lisp_Object table, ptrdiff_t idx, Lisp_Object val) | ||
| 2446 | { | ||
| 2447 | eassert (0 <= idx && idx < CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (table))); | ||
| 2448 | XCHAR_TABLE (table)->extras[idx] = val; | ||
| 2449 | } | ||
| 2450 | |||
| 2451 | LISP_INLINE void | ||
| 2452 | char_table_set_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val) | ||
| 2453 | { | ||
| 2454 | eassert (0 <= idx && idx < (1 << CHARTAB_SIZE_BITS_0)); | ||
| 2455 | XCHAR_TABLE (table)->contents[idx] = val; | ||
| 2456 | } | ||
| 2457 | |||
| 2458 | LISP_INLINE void | ||
| 2459 | sub_char_table_set_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val) | ||
| 2460 | { | ||
| 2461 | XSUB_CHAR_TABLE (table)->contents[idx] = val; | ||
| 2462 | } | ||
| 2463 | |||
| 2308 | /* Defined in data.c. */ | 2464 | /* Defined in data.c. */ |
| 2309 | extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; | 2465 | extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; |
| 2310 | extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; | 2466 | extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; |
| @@ -2332,7 +2488,8 @@ extern Lisp_Object Qoverflow_error, Qunderflow_error; | |||
| 2332 | extern Lisp_Object Qfloatp; | 2488 | extern Lisp_Object Qfloatp; |
| 2333 | extern Lisp_Object Qnumberp, Qnumber_or_marker_p; | 2489 | extern Lisp_Object Qnumberp, Qnumber_or_marker_p; |
| 2334 | 2490 | ||
| 2335 | extern Lisp_Object Qinteger; | 2491 | extern Lisp_Object Qinteger, Qinterval, Qsymbol, Qstring; |
| 2492 | extern Lisp_Object Qmisc, Qvector, Qfloat, Qcons, Qbuffer; | ||
| 2336 | 2493 | ||
| 2337 | extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; | 2494 | extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; |
| 2338 | 2495 | ||
| @@ -2603,18 +2760,31 @@ extern void refill_memory_reserve (void); | |||
| 2603 | extern const char *pending_malloc_warning; | 2760 | extern const char *pending_malloc_warning; |
| 2604 | extern Lisp_Object zero_vector; | 2761 | extern Lisp_Object zero_vector; |
| 2605 | extern Lisp_Object *stack_base; | 2762 | extern Lisp_Object *stack_base; |
| 2763 | extern EMACS_INT consing_since_gc; | ||
| 2764 | extern EMACS_INT gc_relative_threshold; | ||
| 2765 | extern EMACS_INT memory_full_cons_threshold; | ||
| 2606 | extern Lisp_Object list1 (Lisp_Object); | 2766 | extern Lisp_Object list1 (Lisp_Object); |
| 2607 | extern Lisp_Object list2 (Lisp_Object, Lisp_Object); | 2767 | extern Lisp_Object list2 (Lisp_Object, Lisp_Object); |
| 2608 | extern Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object); | 2768 | extern Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object); |
| 2609 | extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); | 2769 | extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); |
| 2610 | extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, | 2770 | extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, |
| 2611 | Lisp_Object); | 2771 | Lisp_Object); |
| 2612 | extern Lisp_Object allocate_misc (void); | 2772 | enum constype {CONSTYPE_HEAP, CONSTYPE_PURE}; |
| 2773 | extern Lisp_Object listn (enum constype, ptrdiff_t, Lisp_Object, ...); | ||
| 2613 | extern _Noreturn void string_overflow (void); | 2774 | extern _Noreturn void string_overflow (void); |
| 2614 | extern Lisp_Object make_string (const char *, ptrdiff_t); | 2775 | extern Lisp_Object make_string (const char *, ptrdiff_t); |
| 2615 | extern Lisp_Object make_formatted_string (char *, const char *, ...) | 2776 | extern Lisp_Object make_formatted_string (char *, const char *, ...) |
| 2616 | ATTRIBUTE_FORMAT_PRINTF (2, 3); | 2777 | ATTRIBUTE_FORMAT_PRINTF (2, 3); |
| 2617 | extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t); | 2778 | extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t); |
| 2779 | |||
| 2780 | /* Make unibyte string from C string when the length isn't known. */ | ||
| 2781 | |||
| 2782 | LISP_INLINE Lisp_Object | ||
| 2783 | build_unibyte_string (const char *str) | ||
| 2784 | { | ||
| 2785 | return make_unibyte_string (str, strlen (str)); | ||
| 2786 | } | ||
| 2787 | |||
| 2618 | extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t); | 2788 | extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t); |
| 2619 | extern Lisp_Object make_event_array (int, Lisp_Object *); | 2789 | extern Lisp_Object make_event_array (int, Lisp_Object *); |
| 2620 | extern Lisp_Object make_uninit_string (EMACS_INT); | 2790 | extern Lisp_Object make_uninit_string (EMACS_INT); |
| @@ -2627,7 +2797,7 @@ extern Lisp_Object make_pure_c_string (const char *, ptrdiff_t); | |||
| 2627 | 2797 | ||
| 2628 | /* Make a string allocated in pure space, use STR as string data. */ | 2798 | /* Make a string allocated in pure space, use STR as string data. */ |
| 2629 | 2799 | ||
| 2630 | static inline Lisp_Object | 2800 | LISP_INLINE Lisp_Object |
| 2631 | build_pure_c_string (const char *str) | 2801 | build_pure_c_string (const char *str) |
| 2632 | { | 2802 | { |
| 2633 | return make_pure_c_string (str, strlen (str)); | 2803 | return make_pure_c_string (str, strlen (str)); |
| @@ -2636,7 +2806,7 @@ build_pure_c_string (const char *str) | |||
| 2636 | /* Make a string from the data at STR, treating it as multibyte if the | 2806 | /* Make a string from the data at STR, treating it as multibyte if the |
| 2637 | data warrants. */ | 2807 | data warrants. */ |
| 2638 | 2808 | ||
| 2639 | static inline Lisp_Object | 2809 | LISP_INLINE Lisp_Object |
| 2640 | build_string (const char *str) | 2810 | build_string (const char *str) |
| 2641 | { | 2811 | { |
| 2642 | return make_string (str, strlen (str)); | 2812 | return make_string (str, strlen (str)); |
| @@ -2662,6 +2832,7 @@ extern Lisp_Object make_float (double); | |||
| 2662 | extern void display_malloc_warning (void); | 2832 | extern void display_malloc_warning (void); |
| 2663 | extern ptrdiff_t inhibit_garbage_collection (void); | 2833 | extern ptrdiff_t inhibit_garbage_collection (void); |
| 2664 | extern Lisp_Object make_save_value (void *, ptrdiff_t); | 2834 | extern Lisp_Object make_save_value (void *, ptrdiff_t); |
| 2835 | extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); | ||
| 2665 | extern void free_marker (Lisp_Object); | 2836 | extern void free_marker (Lisp_Object); |
| 2666 | extern void free_cons (struct Lisp_Cons *); | 2837 | extern void free_cons (struct Lisp_Cons *); |
| 2667 | extern void init_alloc_once (void); | 2838 | extern void init_alloc_once (void); |
| @@ -2669,6 +2840,11 @@ extern void init_alloc (void); | |||
| 2669 | extern void syms_of_alloc (void); | 2840 | extern void syms_of_alloc (void); |
| 2670 | extern struct buffer * allocate_buffer (void); | 2841 | extern struct buffer * allocate_buffer (void); |
| 2671 | extern int valid_lisp_object_p (Lisp_Object); | 2842 | extern int valid_lisp_object_p (Lisp_Object); |
| 2843 | #ifdef GC_CHECK_CONS_LIST | ||
| 2844 | extern void check_cons_list (void); | ||
| 2845 | #else | ||
| 2846 | #define check_cons_list() ((void) 0) | ||
| 2847 | #endif | ||
| 2672 | 2848 | ||
| 2673 | #ifdef REL_ALLOC | 2849 | #ifdef REL_ALLOC |
| 2674 | /* Defined in ralloc.c */ | 2850 | /* Defined in ralloc.c */ |
| @@ -2711,7 +2887,7 @@ extern void print_error_message (Lisp_Object, Lisp_Object, const char *, | |||
| 2711 | Lisp_Object); | 2887 | Lisp_Object); |
| 2712 | extern Lisp_Object internal_with_output_to_temp_buffer | 2888 | extern Lisp_Object internal_with_output_to_temp_buffer |
| 2713 | (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object); | 2889 | (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object); |
| 2714 | #define FLOAT_TO_STRING_BUFSIZE 350 | 2890 | enum FLOAT_TO_STRING_BUFSIZE { FLOAT_TO_STRING_BUFSIZE = 350 }; |
| 2715 | extern int float_to_string (char *, double); | 2891 | extern int float_to_string (char *, double); |
| 2716 | extern void syms_of_print (void); | 2892 | extern void syms_of_print (void); |
| 2717 | 2893 | ||
| @@ -2749,13 +2925,13 @@ extern void init_obarray (void); | |||
| 2749 | extern void init_lread (void); | 2925 | extern void init_lread (void); |
| 2750 | extern void syms_of_lread (void); | 2926 | extern void syms_of_lread (void); |
| 2751 | 2927 | ||
| 2752 | static inline Lisp_Object | 2928 | LISP_INLINE Lisp_Object |
| 2753 | intern (const char *str) | 2929 | intern (const char *str) |
| 2754 | { | 2930 | { |
| 2755 | return intern_1 (str, strlen (str)); | 2931 | return intern_1 (str, strlen (str)); |
| 2756 | } | 2932 | } |
| 2757 | 2933 | ||
| 2758 | static inline Lisp_Object | 2934 | LISP_INLINE Lisp_Object |
| 2759 | intern_c_string (const char *str) | 2935 | intern_c_string (const char *str) |
| 2760 | { | 2936 | { |
| 2761 | return intern_c_string_1 (str, strlen (str)); | 2937 | return intern_c_string_1 (str, strlen (str)); |
| @@ -2807,17 +2983,18 @@ extern Lisp_Object internal_lisp_condition_case (Lisp_Object, Lisp_Object, Lisp_ | |||
| 2807 | extern Lisp_Object internal_condition_case (Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object)); | 2983 | extern Lisp_Object internal_condition_case (Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object)); |
| 2808 | extern Lisp_Object internal_condition_case_1 (Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); | 2984 | extern Lisp_Object internal_condition_case_1 (Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); |
| 2809 | extern Lisp_Object internal_condition_case_2 (Lisp_Object (*) (Lisp_Object, Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); | 2985 | extern Lisp_Object internal_condition_case_2 (Lisp_Object (*) (Lisp_Object, Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); |
| 2810 | extern Lisp_Object internal_condition_case_n (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object)); | 2986 | extern Lisp_Object internal_condition_case_n |
| 2987 | (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *, | ||
| 2988 | Lisp_Object, Lisp_Object (*) (Lisp_Object, ptrdiff_t, Lisp_Object *)); | ||
| 2811 | extern void specbind (Lisp_Object, Lisp_Object); | 2989 | extern void specbind (Lisp_Object, Lisp_Object); |
| 2812 | extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); | 2990 | extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); |
| 2813 | extern Lisp_Object unbind_to (ptrdiff_t, Lisp_Object); | 2991 | extern Lisp_Object unbind_to (ptrdiff_t, Lisp_Object); |
| 2814 | extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); | 2992 | extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); |
| 2815 | extern _Noreturn void verror (const char *, va_list) | 2993 | extern _Noreturn void verror (const char *, va_list) |
| 2816 | ATTRIBUTE_FORMAT_PRINTF (1, 0); | 2994 | ATTRIBUTE_FORMAT_PRINTF (1, 0); |
| 2817 | extern void do_autoload (Lisp_Object, Lisp_Object); | ||
| 2818 | extern Lisp_Object un_autoload (Lisp_Object); | 2995 | extern Lisp_Object un_autoload (Lisp_Object); |
| 2819 | extern void init_eval_once (void); | 2996 | extern void init_eval_once (void); |
| 2820 | extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object *); | 2997 | extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); |
| 2821 | extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); | 2998 | extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); |
| 2822 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); | 2999 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); |
| 2823 | extern void init_eval (void); | 3000 | extern void init_eval (void); |
| @@ -2826,7 +3003,7 @@ extern void mark_backtrace (void); | |||
| 2826 | #endif | 3003 | #endif |
| 2827 | extern void syms_of_eval (void); | 3004 | extern void syms_of_eval (void); |
| 2828 | 3005 | ||
| 2829 | /* Defined in editfns.c */ | 3006 | /* Defined in editfns.c. */ |
| 2830 | extern Lisp_Object Qfield; | 3007 | extern Lisp_Object Qfield; |
| 2831 | extern void insert1 (Lisp_Object); | 3008 | extern void insert1 (Lisp_Object); |
| 2832 | extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object); | 3009 | extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object); |
| @@ -2843,7 +3020,7 @@ const char *get_system_name (void); | |||
| 2843 | extern void syms_of_editfns (void); | 3020 | extern void syms_of_editfns (void); |
| 2844 | extern void set_time_zone_rule (const char *); | 3021 | extern void set_time_zone_rule (const char *); |
| 2845 | 3022 | ||
| 2846 | /* Defined in buffer.c */ | 3023 | /* Defined in buffer.c. */ |
| 2847 | extern int mouse_face_overlay_overlaps (Lisp_Object); | 3024 | extern int mouse_face_overlay_overlaps (Lisp_Object); |
| 2848 | extern _Noreturn void nsberror (Lisp_Object); | 3025 | extern _Noreturn void nsberror (Lisp_Object); |
| 2849 | extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t); | 3026 | extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t); |
| @@ -2857,13 +3034,12 @@ extern Lisp_Object set_buffer_if_live (Lisp_Object); | |||
| 2857 | extern Lisp_Object other_buffer_safely (Lisp_Object); | 3034 | extern Lisp_Object other_buffer_safely (Lisp_Object); |
| 2858 | extern Lisp_Object Qpriority, Qwindow, Qbefore_string, Qafter_string; | 3035 | extern Lisp_Object Qpriority, Qwindow, Qbefore_string, Qafter_string; |
| 2859 | extern Lisp_Object get_truename_buffer (Lisp_Object); | 3036 | extern Lisp_Object get_truename_buffer (Lisp_Object); |
| 2860 | extern struct buffer *all_buffers; | ||
| 2861 | extern void init_buffer_once (void); | 3037 | extern void init_buffer_once (void); |
| 2862 | extern void init_buffer (void); | 3038 | extern void init_buffer (void); |
| 2863 | extern void syms_of_buffer (void); | 3039 | extern void syms_of_buffer (void); |
| 2864 | extern void keys_of_buffer (void); | 3040 | extern void keys_of_buffer (void); |
| 2865 | 3041 | ||
| 2866 | /* Defined in marker.c */ | 3042 | /* Defined in marker.c. */ |
| 2867 | 3043 | ||
| 2868 | extern ptrdiff_t marker_position (Lisp_Object); | 3044 | extern ptrdiff_t marker_position (Lisp_Object); |
| 2869 | extern ptrdiff_t marker_byte_position (Lisp_Object); | 3045 | extern ptrdiff_t marker_byte_position (Lisp_Object); |
| @@ -2920,7 +3096,7 @@ extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t); | |||
| 2920 | extern void syms_of_search (void); | 3096 | extern void syms_of_search (void); |
| 2921 | extern void clear_regexp_cache (void); | 3097 | extern void clear_regexp_cache (void); |
| 2922 | 3098 | ||
| 2923 | /* Defined in minibuf.c */ | 3099 | /* Defined in minibuf.c. */ |
| 2924 | 3100 | ||
| 2925 | extern Lisp_Object Qcompletion_ignore_case; | 3101 | extern Lisp_Object Qcompletion_ignore_case; |
| 2926 | extern Lisp_Object Vminibuffer_list; | 3102 | extern Lisp_Object Vminibuffer_list; |
| @@ -2929,25 +3105,25 @@ extern Lisp_Object get_minibuffer (EMACS_INT); | |||
| 2929 | extern void init_minibuf_once (void); | 3105 | extern void init_minibuf_once (void); |
| 2930 | extern void syms_of_minibuf (void); | 3106 | extern void syms_of_minibuf (void); |
| 2931 | 3107 | ||
| 2932 | /* Defined in callint.c */ | 3108 | /* Defined in callint.c. */ |
| 2933 | 3109 | ||
| 2934 | extern Lisp_Object Qminus, Qplus; | 3110 | extern Lisp_Object Qminus, Qplus; |
| 2935 | extern Lisp_Object Qwhen; | 3111 | extern Lisp_Object Qwhen; |
| 2936 | extern Lisp_Object Qcall_interactively, Qmouse_leave_buffer_hook; | 3112 | extern Lisp_Object Qcall_interactively, Qmouse_leave_buffer_hook; |
| 2937 | extern void syms_of_callint (void); | 3113 | extern void syms_of_callint (void); |
| 2938 | 3114 | ||
| 2939 | /* Defined in casefiddle.c */ | 3115 | /* Defined in casefiddle.c. */ |
| 2940 | 3116 | ||
| 2941 | extern Lisp_Object Qidentity; | 3117 | extern Lisp_Object Qidentity; |
| 2942 | extern void syms_of_casefiddle (void); | 3118 | extern void syms_of_casefiddle (void); |
| 2943 | extern void keys_of_casefiddle (void); | 3119 | extern void keys_of_casefiddle (void); |
| 2944 | 3120 | ||
| 2945 | /* Defined in casetab.c */ | 3121 | /* Defined in casetab.c. */ |
| 2946 | 3122 | ||
| 2947 | extern void init_casetab_once (void); | 3123 | extern void init_casetab_once (void); |
| 2948 | extern void syms_of_casetab (void); | 3124 | extern void syms_of_casetab (void); |
| 2949 | 3125 | ||
| 2950 | /* Defined in keyboard.c */ | 3126 | /* Defined in keyboard.c. */ |
| 2951 | 3127 | ||
| 2952 | extern Lisp_Object echo_message_buffer; | 3128 | extern Lisp_Object echo_message_buffer; |
| 2953 | extern struct kboard *echo_kboard; | 3129 | extern struct kboard *echo_kboard; |
| @@ -2955,6 +3131,7 @@ extern void cancel_echoing (void); | |||
| 2955 | extern Lisp_Object Qdisabled, QCfilter; | 3131 | extern Lisp_Object Qdisabled, QCfilter; |
| 2956 | extern Lisp_Object Qup, Qdown, Qbottom; | 3132 | extern Lisp_Object Qup, Qdown, Qbottom; |
| 2957 | extern Lisp_Object Qtop; | 3133 | extern Lisp_Object Qtop; |
| 3134 | extern Lisp_Object last_undo_boundary; | ||
| 2958 | extern int input_pending; | 3135 | extern int input_pending; |
| 2959 | extern Lisp_Object menu_bar_items (Lisp_Object); | 3136 | extern Lisp_Object menu_bar_items (Lisp_Object); |
| 2960 | extern Lisp_Object tool_bar_items (Lisp_Object, int *); | 3137 | extern Lisp_Object tool_bar_items (Lisp_Object, int *); |
| @@ -2975,14 +3152,14 @@ extern void init_keyboard (void); | |||
| 2975 | extern void syms_of_keyboard (void); | 3152 | extern void syms_of_keyboard (void); |
| 2976 | extern void keys_of_keyboard (void); | 3153 | extern void keys_of_keyboard (void); |
| 2977 | 3154 | ||
| 2978 | /* Defined in indent.c */ | 3155 | /* Defined in indent.c. */ |
| 2979 | extern ptrdiff_t current_column (void); | 3156 | extern ptrdiff_t current_column (void); |
| 2980 | extern void invalidate_current_column (void); | 3157 | extern void invalidate_current_column (void); |
| 2981 | extern int indented_beyond_p (ptrdiff_t, ptrdiff_t, EMACS_INT); | 3158 | extern int indented_beyond_p (ptrdiff_t, ptrdiff_t, EMACS_INT); |
| 2982 | extern void syms_of_indent (void); | 3159 | extern void syms_of_indent (void); |
| 2983 | 3160 | ||
| 2984 | /* Defined in frame.c */ | 3161 | /* Defined in frame.c. */ |
| 2985 | extern Lisp_Object Qonly; | 3162 | extern Lisp_Object Qonly, Qnone; |
| 2986 | extern Lisp_Object Qvisible; | 3163 | extern Lisp_Object Qvisible; |
| 2987 | extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); | 3164 | extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); |
| 2988 | extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object); | 3165 | extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object); |
| @@ -2994,7 +3171,7 @@ extern Lisp_Object frame_buffer_predicate (Lisp_Object); | |||
| 2994 | extern void frames_discard_buffer (Lisp_Object); | 3171 | extern void frames_discard_buffer (Lisp_Object); |
| 2995 | extern void syms_of_frame (void); | 3172 | extern void syms_of_frame (void); |
| 2996 | 3173 | ||
| 2997 | /* Defined in emacs.c */ | 3174 | /* Defined in emacs.c. */ |
| 2998 | extern char **initial_argv; | 3175 | extern char **initial_argv; |
| 2999 | extern int initial_argc; | 3176 | extern int initial_argc; |
| 3000 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) | 3177 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) |
| @@ -3272,51 +3449,6 @@ extern char *egetenv (const char *); | |||
| 3272 | /* Set up the name of the machine we're running on. */ | 3449 | /* Set up the name of the machine we're running on. */ |
| 3273 | extern void init_system_name (void); | 3450 | extern void init_system_name (void); |
| 3274 | 3451 | ||
| 3275 | /* Some systems (e.g., NT) use a different path separator than Unix, | ||
| 3276 | in addition to a device separator. Set the path separator | ||
| 3277 | to '/', and don't test for a device separator in IS_ANY_SEP. */ | ||
| 3278 | |||
| 3279 | #define DIRECTORY_SEP '/' | ||
| 3280 | #ifndef IS_DIRECTORY_SEP | ||
| 3281 | #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP) | ||
| 3282 | #endif | ||
| 3283 | #ifndef IS_DEVICE_SEP | ||
| 3284 | #ifndef DEVICE_SEP | ||
| 3285 | #define IS_DEVICE_SEP(_c_) 0 | ||
| 3286 | #else | ||
| 3287 | #define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP) | ||
| 3288 | #endif | ||
| 3289 | #endif | ||
| 3290 | #ifndef IS_ANY_SEP | ||
| 3291 | #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_)) | ||
| 3292 | #endif | ||
| 3293 | |||
| 3294 | #define SWITCH_ENUM_CAST(x) (x) | ||
| 3295 | |||
| 3296 | /* Use this to suppress gcc's warnings. */ | ||
| 3297 | #ifdef lint | ||
| 3298 | |||
| 3299 | /* Use CODE only if lint checking is in effect. */ | ||
| 3300 | # define IF_LINT(Code) Code | ||
| 3301 | |||
| 3302 | /* Assume that the expression COND is true. This differs in intent | ||
| 3303 | from 'assert', as it is a message from the programmer to the compiler. */ | ||
| 3304 | # define lint_assume(cond) ((cond) ? (void) 0 : abort ()) | ||
| 3305 | |||
| 3306 | #else | ||
| 3307 | # define IF_LINT(Code) /* empty */ | ||
| 3308 | # define lint_assume(cond) ((void) (0 && (cond))) | ||
| 3309 | #endif | ||
| 3310 | |||
| 3311 | /* The ubiquitous min and max macros. */ | ||
| 3312 | |||
| 3313 | #ifdef max | ||
| 3314 | #undef max | ||
| 3315 | #undef min | ||
| 3316 | #endif | ||
| 3317 | #define min(a, b) ((a) < (b) ? (a) : (b)) | ||
| 3318 | #define max(a, b) ((a) > (b) ? (a) : (b)) | ||
| 3319 | |||
| 3320 | /* We used to use `abs', but that clashes with system headers on some | 3452 | /* We used to use `abs', but that clashes with system headers on some |
| 3321 | platforms, and using a name reserved by Standard C is a bad idea | 3453 | platforms, and using a name reserved by Standard C is a bad idea |
| 3322 | anyway. */ | 3454 | anyway. */ |
| @@ -3359,27 +3491,19 @@ extern void init_system_name (void); | |||
| 3359 | /* SAFE_ALLOCA normally allocates memory on the stack, but if size is | 3491 | /* SAFE_ALLOCA normally allocates memory on the stack, but if size is |
| 3360 | larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack. */ | 3492 | larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack. */ |
| 3361 | 3493 | ||
| 3362 | #define MAX_ALLOCA 16*1024 | 3494 | enum MAX_ALLOCA { MAX_ALLOCA = 16*1024 }; |
| 3363 | 3495 | ||
| 3364 | extern Lisp_Object safe_alloca_unwind (Lisp_Object); | 3496 | extern Lisp_Object safe_alloca_unwind (Lisp_Object); |
| 3497 | extern void *record_xmalloc (size_t); | ||
| 3365 | 3498 | ||
| 3366 | #define USE_SAFE_ALLOCA \ | 3499 | #define USE_SAFE_ALLOCA \ |
| 3367 | ptrdiff_t sa_count = SPECPDL_INDEX (); int sa_must_free = 0 | 3500 | ptrdiff_t sa_count = SPECPDL_INDEX (); int sa_must_free = 0 |
| 3368 | 3501 | ||
| 3369 | /* SAFE_ALLOCA allocates a simple buffer. */ | 3502 | /* SAFE_ALLOCA allocates a simple buffer. */ |
| 3370 | 3503 | ||
| 3371 | #define SAFE_ALLOCA(buf, type, size) \ | 3504 | #define SAFE_ALLOCA(size) ((size) < MAX_ALLOCA \ |
| 3372 | do { \ | 3505 | ? alloca (size) \ |
| 3373 | if ((size) < MAX_ALLOCA) \ | 3506 | : (sa_must_free = 1, record_xmalloc (size))) |
| 3374 | buf = (type) alloca (size); \ | ||
| 3375 | else \ | ||
| 3376 | { \ | ||
| 3377 | buf = xmalloc (size); \ | ||
| 3378 | sa_must_free = 1; \ | ||
| 3379 | record_unwind_protect (safe_alloca_unwind, \ | ||
| 3380 | make_save_value (buf, 0)); \ | ||
| 3381 | } \ | ||
| 3382 | } while (0) | ||
| 3383 | 3507 | ||
| 3384 | /* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER * | 3508 | /* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER * |
| 3385 | NITEMS items, each of the same type as *BUF. MULTIPLIER must | 3509 | NITEMS items, each of the same type as *BUF. MULTIPLIER must |
| @@ -3411,24 +3535,38 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); | |||
| 3411 | 3535 | ||
| 3412 | /* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */ | 3536 | /* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */ |
| 3413 | 3537 | ||
| 3414 | #define SAFE_ALLOCA_LISP(buf, nelt) \ | 3538 | #define SAFE_ALLOCA_LISP(buf, nelt) \ |
| 3415 | do { \ | 3539 | do { \ |
| 3416 | if ((nelt) < MAX_ALLOCA / sizeof (Lisp_Object)) \ | 3540 | if ((nelt) < MAX_ALLOCA / word_size) \ |
| 3417 | buf = (Lisp_Object *) alloca ((nelt) * sizeof (Lisp_Object)); \ | 3541 | buf = alloca ((nelt) * word_size); \ |
| 3418 | else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \ | 3542 | else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / word_size) \ |
| 3419 | { \ | 3543 | { \ |
| 3420 | Lisp_Object arg_; \ | 3544 | Lisp_Object arg_; \ |
| 3421 | buf = xmalloc ((nelt) * sizeof (Lisp_Object)); \ | 3545 | buf = xmalloc ((nelt) * word_size); \ |
| 3422 | arg_ = make_save_value (buf, nelt); \ | 3546 | arg_ = make_save_value (buf, nelt); \ |
| 3423 | XSAVE_VALUE (arg_)->dogc = 1; \ | 3547 | XSAVE_VALUE (arg_)->dogc = 1; \ |
| 3424 | sa_must_free = 1; \ | 3548 | sa_must_free = 1; \ |
| 3425 | record_unwind_protect (safe_alloca_unwind, arg_); \ | 3549 | record_unwind_protect (safe_alloca_unwind, arg_); \ |
| 3426 | } \ | 3550 | } \ |
| 3427 | else \ | 3551 | else \ |
| 3428 | memory_full (SIZE_MAX); \ | 3552 | memory_full (SIZE_MAX); \ |
| 3429 | } while (0) | 3553 | } while (0) |
| 3430 | 3554 | ||
| 3431 | 3555 | ||
| 3432 | #include "globals.h" | 3556 | #include "globals.h" |
| 3433 | 3557 | ||
| 3558 | /* Check whether it's time for GC, and run it if so. */ | ||
| 3559 | |||
| 3560 | LISP_INLINE void | ||
| 3561 | maybe_gc (void) | ||
| 3562 | { | ||
| 3563 | if ((consing_since_gc > gc_cons_threshold | ||
| 3564 | && consing_since_gc > gc_relative_threshold) | ||
| 3565 | || (!NILP (Vmemory_full) | ||
| 3566 | && consing_since_gc > memory_full_cons_threshold)) | ||
| 3567 | Fgarbage_collect (); | ||
| 3568 | } | ||
| 3569 | |||
| 3570 | INLINE_HEADER_END | ||
| 3571 | |||
| 3434 | #endif /* EMACS_LISP_H */ | 3572 | #endif /* EMACS_LISP_H */ |