aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h514
1 files changed, 274 insertions, 240 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 762d34abb9c..bd19da55b2a 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1,5 +1,5 @@
1/* Fundamental definitions for GNU Emacs Lisp interpreter. 1/* Fundamental definitions for GNU Emacs Lisp interpreter.
2 Copyright (C) 1985-1987, 1993-1995, 1997-2011 2 Copyright (C) 1985-1987, 1993-1995, 1997-2012
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -61,6 +61,23 @@ extern void check_cons_list (void);
61# define EMACS_UINT unsigned EMACS_INT 61# define EMACS_UINT unsigned EMACS_INT
62#endif 62#endif
63 63
64/* printmax_t and uprintmax_t are types for printing large integers.
65 These are the widest integers that are supported for printing.
66 pMd etc. are conversions for printing them.
67 On C99 hosts, there's no problem, as even the widest integers work.
68 Fall back on EMACS_INT on pre-C99 hosts. */
69#ifdef PRIdMAX
70typedef intmax_t printmax_t;
71typedef uintmax_t uprintmax_t;
72# define pMd PRIdMAX
73# define pMu PRIuMAX
74#else
75typedef EMACS_INT printmax_t;
76typedef EMACS_UINT uprintmax_t;
77# define pMd pI"d"
78# define pMu pI"u"
79#endif
80
64/* Use pD to format ptrdiff_t values, which suffice for indexes into 81/* Use pD to format ptrdiff_t values, which suffice for indexes into
65 buffers and strings. Emacs never allocates objects larger than 82 buffers and strings. Emacs never allocates objects larger than
66 PTRDIFF_MAX bytes, as they cause problems with pointer subtraction. 83 PTRDIFF_MAX bytes, as they cause problems with pointer subtraction.
@@ -115,9 +132,9 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
115#define eassert(X) ((void) (0 && (X))) /* Check that X compiles. */ 132#define eassert(X) ((void) (0 && (X))) /* Check that X compiles. */
116#else /* ENABLE_CHECKING */ 133#else /* ENABLE_CHECKING */
117#if defined (__GNUC__) && __GNUC__ >= 2 && defined (__STDC__) 134#if defined (__GNUC__) && __GNUC__ >= 2 && defined (__STDC__)
118#define eassert(cond) CHECK(cond,"assertion failed: " #cond) 135#define eassert(cond) CHECK (cond, "assertion failed: " #cond)
119#else 136#else
120#define eassert(cond) CHECK(cond,"assertion failed") 137#define eassert(cond) CHECK (cond, "assertion failed")
121#endif 138#endif
122#endif /* ENABLE_CHECKING */ 139#endif /* ENABLE_CHECKING */
123 140
@@ -145,12 +162,28 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
145 162
146/* First, try and define DECL_ALIGN(type,var) which declares a static 163/* First, try and define DECL_ALIGN(type,var) which declares a static
147 variable VAR of type TYPE with the added requirement that it be 164 variable VAR of type TYPE with the added requirement that it be
148 TYPEBITS-aligned. */ 165 TYPEBITS-aligned. */
166
167#ifndef GCTYPEBITS
168#define GCTYPEBITS 3
169#endif
170
171#ifndef VALBITS
172#define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS)
173#endif
174
149#ifndef NO_DECL_ALIGN 175#ifndef NO_DECL_ALIGN
150# ifndef DECL_ALIGN 176# ifndef DECL_ALIGN
151# if HAVE_ATTRIBUTE_ALIGNED 177# if HAVE_ATTRIBUTE_ALIGNED
152# define DECL_ALIGN(type, var) \ 178# define DECL_ALIGN(type, var) \
153 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var 179 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
180# elif defined(_MSC_VER)
181# define ALIGN_GCTYPEBITS 8
182# if (1 << GCTYPEBITS) != ALIGN_GCTYPEBITS
183# error ALIGN_GCTYPEBITS is wrong!
184# endif
185# define DECL_ALIGN(type, var) \
186 type __declspec(align(ALIGN_GCTYPEBITS)) var
154# else 187# else
155 /* What directives do other compilers use? */ 188 /* What directives do other compilers use? */
156# endif 189# endif
@@ -162,7 +195,14 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
162 || defined DARWIN_OS || defined __sun) 195 || defined DARWIN_OS || defined __sun)
163/* We also need to be able to specify mult-of-8 alignment on static vars. */ 196/* We also need to be able to specify mult-of-8 alignment on static vars. */
164# if defined DECL_ALIGN 197# if defined DECL_ALIGN
165# define USE_LSB_TAG 198/* On hosts where VALBITS is greater than the pointer width in bits,
199 USE_LSB_TAG is:
200 a. unnecessary, because the top bits of an EMACS_INT are unused, and
201 b. slower, because it typically requires extra masking.
202 So, define USE_LSB_TAG only on hosts where it might be useful. */
203# if UINTPTR_MAX >> VALBITS != 0
204# define USE_LSB_TAG
205# endif
166# endif 206# endif
167#endif 207#endif
168 208
@@ -208,6 +248,15 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
208# endif 248# endif
209#endif 249#endif
210 250
251/* Stolen from GDB. The only known compiler that doesn't support
252 enums in bitfields is MSVC. */
253#ifdef _MSC_VER
254#define ENUM_BF(TYPE) unsigned int
255#else
256#define ENUM_BF(TYPE) enum TYPE
257#endif
258
259
211enum Lisp_Type 260enum Lisp_Type
212 { 261 {
213 /* Integer. XINT (obj) is the integer value. */ 262 /* Integer. XINT (obj) is the integer value. */
@@ -271,15 +320,6 @@ enum Lisp_Fwd_Type
271 Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */ 320 Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */
272 }; 321 };
273 322
274#ifndef GCTYPEBITS
275#define GCTYPEBITS 3
276#endif
277
278/* These values are overridden by the m- file on some machines. */
279#ifndef VALBITS
280#define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS)
281#endif
282
283#ifdef USE_LISP_UNION_TYPE 323#ifdef USE_LISP_UNION_TYPE
284 324
285#ifndef WORDS_BIGENDIAN 325#ifndef WORDS_BIGENDIAN
@@ -295,15 +335,15 @@ union Lisp_Object
295 335
296 struct 336 struct
297 { 337 {
298 /* Use explict signed, the signedness of a bit-field of type 338 /* Use explicit signed, the signedness of a bit-field of type
299 int is implementation defined. */ 339 int is implementation defined. */
300 signed EMACS_INT val : VALBITS; 340 signed EMACS_INT val : VALBITS;
301 enum Lisp_Type type : GCTYPEBITS; 341 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
302 } s; 342 } s;
303 struct 343 struct
304 { 344 {
305 EMACS_UINT val : VALBITS; 345 EMACS_UINT val : VALBITS;
306 enum Lisp_Type type : GCTYPEBITS; 346 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
307 } u; 347 } u;
308 } 348 }
309Lisp_Object; 349Lisp_Object;
@@ -319,14 +359,14 @@ union Lisp_Object
319 359
320 struct 360 struct
321 { 361 {
322 enum Lisp_Type type : GCTYPEBITS; 362 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
323 /* Use explict signed, the signedness of a bit-field of type 363 /* Use explicit signed, the signedness of a bit-field of type
324 int is implementation defined. */ 364 int is implementation defined. */
325 signed EMACS_INT val : VALBITS; 365 signed EMACS_INT val : VALBITS;
326 } s; 366 } s;
327 struct 367 struct
328 { 368 {
329 enum Lisp_Type type : GCTYPEBITS; 369 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
330 EMACS_UINT val : VALBITS; 370 EMACS_UINT val : VALBITS;
331 } u; 371 } u;
332 } 372 }
@@ -567,20 +607,20 @@ extern Lisp_Object make_number (EMACS_INT);
567 607
568/* Extract a value or address from a Lisp_Object. */ 608/* Extract a value or address from a Lisp_Object. */
569 609
570#define XCONS(a) (eassert (CONSP(a)),(struct Lisp_Cons *) XPNTR(a)) 610#define XCONS(a) (eassert (CONSP (a)), (struct Lisp_Cons *) XPNTR (a))
571#define XVECTOR(a) (eassert (VECTORLIKEP(a)),(struct Lisp_Vector *) XPNTR(a)) 611#define XVECTOR(a) (eassert (VECTORLIKEP (a)), (struct Lisp_Vector *) XPNTR (a))
572#define XSTRING(a) (eassert (STRINGP(a)),(struct Lisp_String *) XPNTR(a)) 612#define XSTRING(a) (eassert (STRINGP (a)), (struct Lisp_String *) XPNTR (a))
573#define XSYMBOL(a) (eassert (SYMBOLP(a)),(struct Lisp_Symbol *) XPNTR(a)) 613#define XSYMBOL(a) (eassert (SYMBOLP (a)), (struct Lisp_Symbol *) XPNTR (a))
574#define XFLOAT(a) (eassert (FLOATP(a)),(struct Lisp_Float *) XPNTR(a)) 614#define XFLOAT(a) (eassert (FLOATP (a)), (struct Lisp_Float *) XPNTR (a))
575 615
576/* Misc types. */ 616/* Misc types. */
577 617
578#define XMISC(a) ((union Lisp_Misc *) XPNTR(a)) 618#define XMISC(a) ((union Lisp_Misc *) XPNTR (a))
579#define XMISCANY(a) (eassert (MISCP (a)), &(XMISC(a)->u_any)) 619#define XMISCANY(a) (eassert (MISCP (a)), &(XMISC (a)->u_any))
580#define XMISCTYPE(a) (XMISCANY (a)->type) 620#define XMISCTYPE(a) (XMISCANY (a)->type)
581#define XMARKER(a) (eassert (MARKERP (a)), &(XMISC(a)->u_marker)) 621#define XMARKER(a) (eassert (MARKERP (a)), &(XMISC (a)->u_marker))
582#define XOVERLAY(a) (eassert (OVERLAYP (a)), &(XMISC(a)->u_overlay)) 622#define XOVERLAY(a) (eassert (OVERLAYP (a)), &(XMISC (a)->u_overlay))
583#define XSAVE_VALUE(a) (eassert (SAVE_VALUEP (a)), &(XMISC(a)->u_save_value)) 623#define XSAVE_VALUE(a) (eassert (SAVE_VALUEP (a)), &(XMISC (a)->u_save_value))
584 624
585/* Forwarding object types. */ 625/* Forwarding object types. */
586 626
@@ -595,14 +635,14 @@ extern Lisp_Object make_number (EMACS_INT);
595 635
596/* Pseudovector types. */ 636/* Pseudovector types. */
597 637
598#define XPROCESS(a) (eassert (PROCESSP(a)),(struct Lisp_Process *) XPNTR(a)) 638#define XPROCESS(a) (eassert (PROCESSP (a)), (struct Lisp_Process *) XPNTR (a))
599#define XWINDOW(a) (eassert (WINDOWP(a)),(struct window *) XPNTR(a)) 639#define XWINDOW(a) (eassert (WINDOWP (a)), (struct window *) XPNTR (a))
600#define XTERMINAL(a) (eassert (TERMINALP(a)),(struct terminal *) XPNTR(a)) 640#define XTERMINAL(a) (eassert (TERMINALP (a)), (struct terminal *) XPNTR (a))
601#define XSUBR(a) (eassert (SUBRP(a)),(struct Lisp_Subr *) XPNTR(a)) 641#define XSUBR(a) (eassert (SUBRP (a)), (struct Lisp_Subr *) XPNTR (a))
602#define XBUFFER(a) (eassert (BUFFERP(a)),(struct buffer *) XPNTR(a)) 642#define XBUFFER(a) (eassert (BUFFERP (a)), (struct buffer *) XPNTR (a))
603#define XCHAR_TABLE(a) (eassert (CHAR_TABLE_P (a)), (struct Lisp_Char_Table *) XPNTR(a)) 643#define XCHAR_TABLE(a) (eassert (CHAR_TABLE_P (a)), (struct Lisp_Char_Table *) XPNTR (a))
604#define XSUB_CHAR_TABLE(a) (eassert (SUB_CHAR_TABLE_P (a)), (struct Lisp_Sub_Char_Table *) XPNTR(a)) 644#define XSUB_CHAR_TABLE(a) (eassert (SUB_CHAR_TABLE_P (a)), (struct Lisp_Sub_Char_Table *) XPNTR (a))
605#define XBOOL_VECTOR(a) (eassert (BOOL_VECTOR_P (a)), (struct Lisp_Bool_Vector *) XPNTR(a)) 645#define XBOOL_VECTOR(a) (eassert (BOOL_VECTOR_P (a)), (struct Lisp_Bool_Vector *) XPNTR (a))
606 646
607/* Construct a Lisp_Object from a value or address. */ 647/* Construct a Lisp_Object from a value or address. */
608 648
@@ -620,7 +660,7 @@ extern Lisp_Object make_number (EMACS_INT);
620 660
621/* Pseudovector types. */ 661/* Pseudovector types. */
622 662
623#define XSETPVECTYPE(v, code) XSETTYPED_PVECTYPE(v, header.size, code) 663#define XSETPVECTYPE(v, code) XSETTYPED_PVECTYPE (v, header.size, code)
624#define XSETTYPED_PVECTYPE(v, size_member, code) \ 664#define XSETTYPED_PVECTYPE(v, size_member, code) \
625 ((v)->size_member |= PSEUDOVECTOR_FLAG | (code)) 665 ((v)->size_member |= PSEUDOVECTOR_FLAG | (code))
626#define XSETPVECTYPESIZE(v, code, sizeval) \ 666#define XSETPVECTYPESIZE(v, code, sizeval) \
@@ -732,8 +772,8 @@ struct Lisp_Cons
732#endif 772#endif
733 773
734/* Use these from normal code. */ 774/* Use these from normal code. */
735#define XCAR(c) LISP_MAKE_RVALUE(XCAR_AS_LVALUE(c)) 775#define XCAR(c) LISP_MAKE_RVALUE (XCAR_AS_LVALUE (c))
736#define XCDR(c) LISP_MAKE_RVALUE(XCDR_AS_LVALUE(c)) 776#define XCDR(c) LISP_MAKE_RVALUE (XCDR_AS_LVALUE (c))
737 777
738/* Use these to set the fields of a cons cell. 778/* Use these to set the fields of a cons cell.
739 779
@@ -741,8 +781,8 @@ struct Lisp_Cons
741 should not be read after 'c' is first modified. Also, neither 781 should not be read after 'c' is first modified. Also, neither
742 argument should be evaluated more than once; side effects are 782 argument should be evaluated more than once; side effects are
743 especially common in the second argument. */ 783 especially common in the second argument. */
744#define XSETCAR(c,n) (XCAR_AS_LVALUE(c) = (n)) 784#define XSETCAR(c,n) (XCAR_AS_LVALUE (c) = (n))
745#define XSETCDR(c,n) (XCDR_AS_LVALUE(c) = (n)) 785#define XSETCDR(c,n) (XCDR_AS_LVALUE (c) = (n))
746 786
747/* Take the car or cdr of something whose type is not known. */ 787/* Take the car or cdr of something whose type is not known. */
748#define CAR(c) \ 788#define CAR(c) \
@@ -833,7 +873,7 @@ struct Lisp_String
833 <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8546>. */ 873 <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8546>. */
834struct vectorlike_header 874struct vectorlike_header
835 { 875 {
836 EMACS_UINT size; 876 EMACS_INT size;
837 877
838 /* Pointer to the next vector-like object. It is generally a buffer or a 878 /* Pointer to the next vector-like object. It is generally a buffer or a
839 Lisp_Vector alias, so for convenience it is a union instead of a 879 Lisp_Vector alias, so for convenience it is a union instead of a
@@ -855,14 +895,14 @@ struct Lisp_Vector
855 of the shortest vector that would hold that struct. */ 895 of the shortest vector that would hold that struct. */
856#define VECSIZE(type) ((sizeof (type) \ 896#define VECSIZE(type) ((sizeof (type) \
857 - offsetof (struct Lisp_Vector, contents[0]) \ 897 - offsetof (struct Lisp_Vector, contents[0]) \
858 + sizeof(Lisp_Object) - 1) /* round up */ \ 898 + sizeof (Lisp_Object) - 1) /* round up */ \
859 / sizeof (Lisp_Object)) 899 / sizeof (Lisp_Object))
860 900
861/* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields 901/* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields
862 at the end and we need to compute the number of Lisp_Object fields (the 902 at the end and we need to compute the number of Lisp_Object fields (the
863 ones that the GC needs to trace). */ 903 ones that the GC needs to trace). */
864#define PSEUDOVECSIZE(type, nonlispfield) \ 904#define PSEUDOVECSIZE(type, nonlispfield) \
865 ((offsetof(type, nonlispfield) - offsetof(struct Lisp_Vector, contents[0])) \ 905 ((offsetof (type, nonlispfield) - offsetof (struct Lisp_Vector, contents[0])) \
866 / sizeof (Lisp_Object)) 906 / sizeof (Lisp_Object))
867 907
868/* A char-table is a kind of vectorlike, with contents are like a 908/* A char-table is a kind of vectorlike, with contents are like a
@@ -914,7 +954,7 @@ struct Lisp_Vector
914 954
915/* Compute A OP B, using the unsigned comparison operator OP. A and B 955/* Compute A OP B, using the unsigned comparison operator OP. A and B
916 should be integer expressions. This is not the same as 956 should be integer expressions. This is not the same as
917 mathemeatical comparison; for example, UNSIGNED_CMP (0, <, -1) 957 mathematical comparison; for example, UNSIGNED_CMP (0, <, -1)
918 returns 1. For efficiency, prefer plain unsigned comparison if A 958 returns 1. For efficiency, prefer plain unsigned comparison if A
919 and B's sizes both fit (after integer promotion). */ 959 and B's sizes both fit (after integer promotion). */
920#define UNSIGNED_CMP(a, op, b) \ 960#define UNSIGNED_CMP(a, op, b) \
@@ -1028,7 +1068,7 @@ struct Lisp_Bool_Vector
1028 1068
1029struct Lisp_Subr 1069struct Lisp_Subr
1030 { 1070 {
1031 EMACS_UINT size; 1071 EMACS_INT size;
1032 union { 1072 union {
1033 Lisp_Object (*a0) (void); 1073 Lisp_Object (*a0) (void);
1034 Lisp_Object (*a1) (Lisp_Object); 1074 Lisp_Object (*a1) (Lisp_Object);
@@ -1067,11 +1107,9 @@ enum symbol_redirect
1067 SYMBOL_PLAINVAL = 4, 1107 SYMBOL_PLAINVAL = 4,
1068 SYMBOL_VARALIAS = 1, 1108 SYMBOL_VARALIAS = 1,
1069 SYMBOL_LOCALIZED = 2, 1109 SYMBOL_LOCALIZED = 2,
1070 SYMBOL_FORWARDED = 3 1110 SYMBOL_FORWARDED = 3
1071}; 1111};
1072 1112
1073/* In a symbol, the markbit of the plist is used as the gc mark bit */
1074
1075struct Lisp_Symbol 1113struct Lisp_Symbol
1076{ 1114{
1077 unsigned gcmarkbit : 1; 1115 unsigned gcmarkbit : 1;
@@ -1080,9 +1118,8 @@ struct Lisp_Symbol
1080 0 : it's a plain var, the value is in the `value' field. 1118 0 : it's a plain var, the value is in the `value' field.
1081 1 : it's a varalias, the value is really in the `alias' symbol. 1119 1 : it's a varalias, the value is really in the `alias' symbol.
1082 2 : it's a localized var, the value is in the `blv' object. 1120 2 : it's a localized var, the value is in the `blv' object.
1083 3 : it's a forwarding variable, the value is in `forward'. 1121 3 : it's a forwarding variable, the value is in `forward'. */
1084 */ 1122 ENUM_BF (symbol_redirect) redirect : 3;
1085 enum symbol_redirect redirect : 3;
1086 1123
1087 /* Non-zero means symbol is constant, i.e. changing its value 1124 /* Non-zero means symbol is constant, i.e. changing its value
1088 should signal an error. If the value is 3, then the var 1125 should signal an error. If the value is 3, then the var
@@ -1098,15 +1135,12 @@ struct Lisp_Symbol
1098 unsigned declared_special : 1; 1135 unsigned declared_special : 1;
1099 1136
1100 /* The symbol's name, as a Lisp string. 1137 /* The symbol's name, as a Lisp string.
1101
1102 The name "xname" is used to intentionally break code referring to 1138 The name "xname" is used to intentionally break code referring to
1103 the old field "name" of type pointer to struct Lisp_String. */ 1139 the old field "name" of type pointer to struct Lisp_String. */
1104 Lisp_Object xname; 1140 Lisp_Object xname;
1105 1141
1106 /* Value of the symbol or Qunbound if unbound. If this symbol is a 1142 /* Value of the symbol or Qunbound if unbound. Which alternative of the
1107 defvaralias, `alias' contains the symbol for which it is an 1143 union is used depends on the `redirect' field above. */
1108 alias. Use the SYMBOL_VALUE and SET_SYMBOL_VALUE macros to get
1109 and set a symbol's value, to take defvaralias into account. */
1110 union { 1144 union {
1111 Lisp_Object value; 1145 Lisp_Object value;
1112 struct Lisp_Symbol *alias; 1146 struct Lisp_Symbol *alias;
@@ -1298,16 +1332,16 @@ struct Lisp_Hash_Table
1298 1332
1299struct Lisp_Misc_Any /* Supertype of all Misc types. */ 1333struct Lisp_Misc_Any /* Supertype of all Misc types. */
1300{ 1334{
1301 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_??? */ 1335 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_??? */
1302 unsigned gcmarkbit : 1; 1336 unsigned gcmarkbit : 1;
1303 int spacer : 15; 1337 int spacer : 15;
1304 /* Make it as long as "Lisp_Free without padding". */ 1338 /* Make it as long as "Lisp_Free without padding". */
1305 void *fill; 1339 void *fill;
1306}; 1340};
1307 1341
1308struct Lisp_Marker 1342struct Lisp_Marker
1309{ 1343{
1310 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Marker */ 1344 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Marker */
1311 unsigned gcmarkbit : 1; 1345 unsigned gcmarkbit : 1;
1312 int spacer : 13; 1346 int spacer : 13;
1313 /* This flag is temporarily used in the functions 1347 /* This flag is temporarily used in the functions
@@ -1457,7 +1491,7 @@ struct Lisp_Overlay
1457 I.e. 9words plus 2 bits, 3words of which are for external linked lists. 1491 I.e. 9words plus 2 bits, 3words of which are for external linked lists.
1458*/ 1492*/
1459 { 1493 {
1460 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Overlay */ 1494 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */
1461 unsigned gcmarkbit : 1; 1495 unsigned gcmarkbit : 1;
1462 int spacer : 15; 1496 int spacer : 15;
1463 struct Lisp_Overlay *next; 1497 struct Lisp_Overlay *next;
@@ -1476,7 +1510,7 @@ struct Lisp_Kboard_Objfwd
1476 This type of object is used in the arg to record_unwind_protect. */ 1510 This type of object is used in the arg to record_unwind_protect. */
1477struct Lisp_Save_Value 1511struct Lisp_Save_Value
1478 { 1512 {
1479 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Save_Value */ 1513 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Save_Value */
1480 unsigned gcmarkbit : 1; 1514 unsigned gcmarkbit : 1;
1481 int spacer : 14; 1515 int spacer : 14;
1482 /* If DOGC is set, POINTER is the address of a memory 1516 /* If DOGC is set, POINTER is the address of a memory
@@ -1490,7 +1524,7 @@ struct Lisp_Save_Value
1490/* A miscellaneous object, when it's on the free list. */ 1524/* A miscellaneous object, when it's on the free list. */
1491struct Lisp_Free 1525struct Lisp_Free
1492 { 1526 {
1493 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Free */ 1527 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Free */
1494 unsigned gcmarkbit : 1; 1528 unsigned gcmarkbit : 1;
1495 int spacer : 15; 1529 int spacer : 15;
1496 union Lisp_Misc *chain; 1530 union Lisp_Misc *chain;
@@ -1582,16 +1616,6 @@ typedef unsigned char UCHAR;
1582 itself. */ 1616 itself. */
1583#define CHARACTERBITS 22 1617#define CHARACTERBITS 22
1584 1618
1585/* The maximum byte size consumed by push_key_description.
1586 All callers should assure that at least this size of memory is
1587 allocated at the place pointed by the second argument.
1588
1589 There are 6 modifiers, each consumes 2 chars.
1590 The octal form of a character code consumes
1591 (1 + CHARACTERBITS / 3 + 1) chars (including backslash at the head).
1592 We need one more byte for string terminator `\0'. */
1593#define KEY_DESCRIPTION_SIZE ((2 * 6) + 1 + (CHARACTERBITS / 3) + 1 + 1)
1594
1595 1619
1596/* The glyph datatype, used to represent characters on the display. 1620/* The glyph datatype, used to represent characters on the display.
1597 It consists of a char code and a face id. */ 1621 It consists of a char code and a face id. */
@@ -1687,6 +1711,11 @@ typedef struct {
1687#define NUMBERP(x) (INTEGERP (x) || FLOATP (x)) 1711#define NUMBERP(x) (INTEGERP (x) || FLOATP (x))
1688#define NATNUMP(x) (INTEGERP (x) && XINT (x) >= 0) 1712#define NATNUMP(x) (INTEGERP (x) && XINT (x) >= 0)
1689 1713
1714#define RANGED_INTEGERP(lo, x, hi) \
1715 (INTEGERP (x) && (lo) <= XINT (x) && XINT (x) <= (hi))
1716#define TYPE_RANGED_INTEGERP(type, x) \
1717 RANGED_INTEGERP (TYPE_MINIMUM (type), x, TYPE_MAXIMUM (type))
1718
1690#define INTEGERP(x) (LISP_INT_TAG_P (XTYPE ((x)))) 1719#define INTEGERP(x) (LISP_INT_TAG_P (XTYPE ((x))))
1691#define SYMBOLP(x) (XTYPE ((x)) == Lisp_Symbol) 1720#define SYMBOLP(x) (XTYPE ((x)) == Lisp_Symbol)
1692#define MISCP(x) (XTYPE ((x)) == Lisp_Misc) 1721#define MISCP(x) (XTYPE ((x)) == Lisp_Misc)
@@ -1859,9 +1888,6 @@ typedef struct {
1859 CHECK_NATNUM (tmp); \ 1888 CHECK_NATNUM (tmp); \
1860 XSETCDR ((x), tmp); \ 1889 XSETCDR ((x), tmp); \
1861 } while (0) 1890 } while (0)
1862
1863/* Cast pointers to this type to compare them. */
1864#define PNTR_COMPARISON_TYPE uintptr_t
1865 1891
1866/* Define a built-in function for calling from Lisp. 1892/* Define a built-in function for calling from Lisp.
1867 `lname' should be the name to give the function in Lisp, 1893 `lname' should be the name to give the function in Lisp,
@@ -1890,13 +1916,23 @@ typedef struct {
1890 1916
1891/* This version of DEFUN declares a function prototype with the right 1917/* This version of DEFUN declares a function prototype with the right
1892 arguments, so we can catch errors with maxargs at compile-time. */ 1918 arguments, so we can catch errors with maxargs at compile-time. */
1893#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 1919#ifdef _MSC_VER
1894 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 1920#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1895 static DECL_ALIGN (struct Lisp_Subr, sname) = \ 1921 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1896 { PVEC_SUBR, \ 1922 static DECL_ALIGN (struct Lisp_Subr, sname) = \
1897 { .a ## maxargs = fnname }, \ 1923 { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \
1898 minargs, maxargs, lname, intspec, 0}; \ 1924 { (Lisp_Object (__cdecl *)(void))fnname }, \
1899 Lisp_Object fnname 1925 minargs, maxargs, lname, intspec, 0}; \
1926 Lisp_Object fnname
1927#else /* not _MSC_VER */
1928#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1929 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1930 static DECL_ALIGN (struct Lisp_Subr, sname) = \
1931 { PVEC_SUBR, \
1932 { .a ## maxargs = fnname }, \
1933 minargs, maxargs, lname, intspec, 0}; \
1934 Lisp_Object fnname
1935#endif
1900 1936
1901/* Note that the weird token-substitution semantics of ANSI C makes 1937/* Note that the weird token-substitution semantics of ANSI C makes
1902 this work for MANY and UNEVALLED. */ 1938 this work for MANY and UNEVALLED. */
@@ -2098,7 +2134,10 @@ extern char *stack_bottom;
2098 Exception: if you set immediate_quit to nonzero, 2134 Exception: if you set immediate_quit to nonzero,
2099 then the handler that responds to the C-g does the quit itself. 2135 then the handler that responds to the C-g does the quit itself.
2100 This is a good thing to do around a loop that has no side effects 2136 This is a good thing to do around a loop that has no side effects
2101 and (in particular) cannot call arbitrary Lisp code. */ 2137 and (in particular) cannot call arbitrary Lisp code.
2138
2139 If quit-flag is set to `kill-emacs' the SIGINT handler has received
2140 a request to exit Emacs when it is safe to do. */
2102 2141
2103#ifdef SYNC_INPUT 2142#ifdef SYNC_INPUT
2104extern void process_pending_signals (void); 2143extern void process_pending_signals (void);
@@ -2110,16 +2149,11 @@ extern int pending_signals;
2110#define ELSE_PENDING_SIGNALS 2149#define ELSE_PENDING_SIGNALS
2111#endif /* not SYNC_INPUT */ 2150#endif /* not SYNC_INPUT */
2112 2151
2152extern void process_quit_flag (void);
2113#define QUIT \ 2153#define QUIT \
2114 do { \ 2154 do { \
2115 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ 2155 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
2116 { \ 2156 process_quit_flag (); \
2117 Lisp_Object flag = Vquit_flag; \
2118 Vquit_flag = Qnil; \
2119 if (EQ (Vthrow_on_input, flag)) \
2120 Fthrow (Vthrow_on_input, Qt); \
2121 Fsignal (Qquit, Qnil); \
2122 } \
2123 ELSE_PENDING_SIGNALS \ 2157 ELSE_PENDING_SIGNALS \
2124 } while (0) 2158 } while (0)
2125 2159
@@ -2193,143 +2227,127 @@ struct gcpro
2193 || GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS) 2227 || GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS)
2194 2228
2195 2229
2196#define GCPRO1(var) \
2197 GCPRO1_VAR (var, gcpro)
2198#define GCPRO2(var1, var2) \
2199 GCPRO2_VAR (var1, var2, gcpro)
2200#define GCPRO3(var1, var2, var3) \
2201 GCPRO3_VAR (var1, var2, var3, gcpro)
2202#define GCPRO4(var1, var2, var3, var4) \
2203 GCPRO4_VAR (var1, var2, var3, var4, gcpro)
2204#define GCPRO5(var1, var2, var3, var4, var5) \
2205 GCPRO5_VAR (var1, var2, var3, var4, var5, gcpro)
2206#define GCPRO6(var1, var2, var3, var4, var5, var6) \
2207 GCPRO6_VAR (var1, var2, var3, var4, var5, var6, gcpro)
2208#define UNGCPRO UNGCPRO_VAR (gcpro)
2209
2210#if GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS 2230#if GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS
2211 2231
2212/* Do something silly with gcproN vars just so gcc shuts up. */ 2232/* Do something silly with gcproN vars just so gcc shuts up. */
2213/* You get warnings from MIPSPro... */ 2233/* You get warnings from MIPSPro... */
2214 2234
2215#define GCPRO1_VAR(var, gcpro) ((void) gcpro##1) 2235#define GCPRO1(varname) ((void) gcpro1)
2216#define GCPRO2_VAR(var1, var2, gcpro) \ 2236#define GCPRO2(varname1, varname2) ((void) gcpro2, (void) gcpro1)
2217 ((void) gcpro##2, (void) gcpro##1) 2237#define GCPRO3(varname1, varname2, varname3) \
2218#define GCPRO3_VAR(var1, var2, var3, gcpro) \ 2238 ((void) gcpro3, (void) gcpro2, (void) gcpro1)
2219 ((void) gcpro##3, (void) gcpro##2, (void) gcpro##1) 2239#define GCPRO4(varname1, varname2, varname3, varname4) \
2220#define GCPRO4_VAR(var1, var2, var3, var4, gcpro) \ 2240 ((void) gcpro4, (void) gcpro3, (void) gcpro2, (void) gcpro1)
2221 ((void) gcpro##4, (void) gcpro##3, (void) gcpro##2, (void) gcpro##1) 2241#define GCPRO5(varname1, varname2, varname3, varname4, varname5) \
2222#define GCPRO5_VAR(var1, var2, var3, var4, var5, gcpro) \ 2242 ((void) gcpro5, (void) gcpro4, (void) gcpro3, (void) gcpro2, (void) gcpro1)
2223 ((void) gcpro##5, (void) gcpro##4, (void) gcpro##3, (void) gcpro##2, \ 2243#define GCPRO6(varname1, varname2, varname3, varname4, varname5, varname6) \
2224 (void) gcpro##1) 2244 ((void) gcpro6, (void) gcpro5, (void) gcpro4, (void) gcpro3, (void) gcpro2, \
2225#define GCPRO6_VAR(var1, var2, var3, var4, var5, var6, gcpro) \ 2245 (void) gcpro1)
2226 ((void) gcpro##6, (void) gcpro##5, (void) gcpro##4, (void) gcpro##3, \ 2246#define UNGCPRO ((void) 0)
2227 (void) gcpro##2, (void) gcpro##1)
2228#define UNGCPRO_VAR(gcpro) ((void) 0)
2229 2247
2230#else /* GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS */ 2248#else /* GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS */
2231 2249
2232#ifndef DEBUG_GCPRO 2250#ifndef DEBUG_GCPRO
2233 2251
2234#define GCPRO1_VAR(var, gcpro) \ 2252#define GCPRO1(varname) \
2235 {gcpro##1.next = gcprolist; gcpro##1.var = &var; gcpro##1.nvars = 1; \ 2253 {gcpro1.next = gcprolist; gcpro1.var = &varname; gcpro1.nvars = 1; \
2236 gcprolist = &gcpro##1; } 2254 gcprolist = &gcpro1; }
2237 2255
2238#define GCPRO2_VAR(var1, var2, gcpro) \ 2256#define GCPRO2(varname1, varname2) \
2239 {gcpro##1.next = gcprolist; gcpro##1.var = &var1; gcpro##1.nvars = 1; \ 2257 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
2240 gcpro##2.next = &gcpro##1; gcpro##2.var = &var2; gcpro##2.nvars = 1; \ 2258 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
2241 gcprolist = &gcpro##2; } 2259 gcprolist = &gcpro2; }
2242 2260
2243#define GCPRO3_VAR(var1, var2, var3, gcpro) \ 2261#define GCPRO3(varname1, varname2, varname3) \
2244 {gcpro##1.next = gcprolist; gcpro##1.var = &var1; gcpro##1.nvars = 1; \ 2262 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
2245 gcpro##2.next = &gcpro##1; gcpro##2.var = &var2; gcpro##2.nvars = 1; \ 2263 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
2246 gcpro##3.next = &gcpro##2; gcpro##3.var = &var3; gcpro##3.nvars = 1; \ 2264 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
2247 gcprolist = &gcpro##3; } 2265 gcprolist = &gcpro3; }
2248 2266
2249#define GCPRO4_VAR(var1, var2, var3, var4, gcpro) \ 2267#define GCPRO4(varname1, varname2, varname3, varname4) \
2250 {gcpro##1.next = gcprolist; gcpro##1.var = &var1; gcpro##1.nvars = 1; \ 2268 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
2251 gcpro##2.next = &gcpro##1; gcpro##2.var = &var2; gcpro##2.nvars = 1; \ 2269 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
2252 gcpro##3.next = &gcpro##2; gcpro##3.var = &var3; gcpro##3.nvars = 1; \ 2270 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
2253 gcpro##4.next = &gcpro##3; gcpro##4.var = &var4; gcpro##4.nvars = 1; \ 2271 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
2254 gcprolist = &gcpro##4; } 2272 gcprolist = &gcpro4; }
2255 2273
2256#define GCPRO5_VAR(var1, var2, var3, var4, var5, gcpro) \ 2274#define GCPRO5(varname1, varname2, varname3, varname4, varname5) \
2257 {gcpro##1.next = gcprolist; gcpro##1.var = &var1; gcpro##1.nvars = 1; \ 2275 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
2258 gcpro##2.next = &gcpro##1; gcpro##2.var = &var2; gcpro##2.nvars = 1; \ 2276 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
2259 gcpro##3.next = &gcpro##2; gcpro##3.var = &var3; gcpro##3.nvars = 1; \ 2277 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
2260 gcpro##4.next = &gcpro##3; gcpro##4.var = &var4; gcpro##4.nvars = 1; \ 2278 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
2261 gcpro##5.next = &gcpro##4; gcpro##5.var = &var5; gcpro##5.nvars = 1; \ 2279 gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \
2262 gcprolist = &gcpro##5; } 2280 gcprolist = &gcpro5; }
2263 2281
2264#define GCPRO6_VAR(var1, var2, var3, var4, var5, var6, gcpro) \ 2282#define GCPRO6(varname1, varname2, varname3, varname4, varname5, varname6) \
2265 {gcpro##1.next = gcprolist; gcpro##1.var = &var1; gcpro##1.nvars = 1; \ 2283 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
2266 gcpro##2.next = &gcpro##1; gcpro##2.var = &var2; gcpro##2.nvars = 1; \ 2284 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
2267 gcpro##3.next = &gcpro##2; gcpro##3.var = &var3; gcpro##3.nvars = 1; \ 2285 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
2268 gcpro##4.next = &gcpro##3; gcpro##4.var = &var4; gcpro##4.nvars = 1; \ 2286 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
2269 gcpro##5.next = &gcpro##4; gcpro##5.var = &var5; gcpro##5.nvars = 1; \ 2287 gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \
2270 gcpro##6.next = &gcpro##5; gcpro##6.var = &var6; gcpro##6.nvars = 1; \ 2288 gcpro6.next = &gcpro5; gcpro6.var = &varname6; gcpro6.nvars = 1; \
2271 gcprolist = &gcpro##6; } 2289 gcprolist = &gcpro6; }
2272 2290
2273#define UNGCPRO_VAR(gcpro) (gcprolist = gcpro##1.next) 2291#define UNGCPRO (gcprolist = gcpro1.next)
2274 2292
2275#else 2293#else
2276 2294
2277extern int gcpro_level; 2295extern int gcpro_level;
2278 2296
2279#define GCPRO1_VAR(var, gcpro) \ 2297#define GCPRO1(varname) \
2280 {gcpro##1.next = gcprolist; gcpro##1.var = &var; gcpro##1.nvars = 1; \ 2298 {gcpro1.next = gcprolist; gcpro1.var = &varname; gcpro1.nvars = 1; \
2281 gcpro##1.level = gcpro_level++; \ 2299 gcpro1.level = gcpro_level++; \
2282 gcprolist = &gcpro##1; } 2300 gcprolist = &gcpro1; }
2283 2301
2284#define GCPRO2_VAR(var1, var2, gcpro) \ 2302#define GCPRO2(varname1, varname2) \
2285 {gcpro##1.next = gcprolist; gcpro##1.var = &var1; gcpro##1.nvars = 1; \ 2303 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
2286 gcpro##1.level = gcpro_level; \ 2304 gcpro1.level = gcpro_level; \
2287 gcpro##2.next = &gcpro##1; gcpro##2.var = &var2; gcpro##2.nvars = 1; \ 2305 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
2288 gcpro##2.level = gcpro_level++; \ 2306 gcpro2.level = gcpro_level++; \
2289 gcprolist = &gcpro##2; } 2307 gcprolist = &gcpro2; }
2290 2308
2291#define GCPRO3_VAR(var1, var2, var3, gcpro) \ 2309#define GCPRO3(varname1, varname2, varname3) \
2292 {gcpro##1.next = gcprolist; gcpro##1.var = &var1; gcpro##1.nvars = 1; \ 2310 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
2293 gcpro##1.level = gcpro_level; \ 2311 gcpro1.level = gcpro_level; \
2294 gcpro##2.next = &gcpro##1; gcpro##2.var = &var2; gcpro##2.nvars = 1; \ 2312 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
2295 gcpro##3.next = &gcpro##2; gcpro##3.var = &var3; gcpro##3.nvars = 1; \ 2313 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
2296 gcpro##3.level = gcpro_level++; \ 2314 gcpro3.level = gcpro_level++; \
2297 gcprolist = &gcpro##3; } 2315 gcprolist = &gcpro3; }
2298 2316
2299#define GCPRO4_VAR(var1, var2, var3, var4, gcpro) \ 2317#define GCPRO4(varname1, varname2, varname3, varname4) \
2300 {gcpro##1.next = gcprolist; gcpro##1.var = &var1; gcpro##1.nvars = 1; \ 2318 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
2301 gcpro##1.level = gcpro_level; \ 2319 gcpro1.level = gcpro_level; \
2302 gcpro##2.next = &gcpro##1; gcpro##2.var = &var2; gcpro##2.nvars = 1; \ 2320 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
2303 gcpro##3.next = &gcpro##2; gcpro##3.var = &var3; gcpro##3.nvars = 1; \ 2321 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
2304 gcpro##4.next = &gcpro##3; gcpro##4.var = &var4; gcpro##4.nvars = 1; \ 2322 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
2305 gcpro##4.level = gcpro_level++; \ 2323 gcpro4.level = gcpro_level++; \
2306 gcprolist = &gcpro##4; } 2324 gcprolist = &gcpro4; }
2307 2325
2308#define GCPRO5_VAR(var1, var2, var3, var4, var5, gcpro) \ 2326#define GCPRO5(varname1, varname2, varname3, varname4, varname5) \
2309 {gcpro##1.next = gcprolist; gcpro##1.var = &var1; gcpro##1.nvars = 1; \ 2327 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
2310 gcpro##1.level = gcpro_level; \ 2328 gcpro1.level = gcpro_level; \
2311 gcpro##2.next = &gcpro##1; gcpro##2.var = &var2; gcpro##2.nvars = 1; \ 2329 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
2312 gcpro##3.next = &gcpro##2; gcpro##3.var = &var3; gcpro##3.nvars = 1; \ 2330 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
2313 gcpro##4.next = &gcpro##3; gcpro##4.var = &var4; gcpro##4.nvars = 1; \ 2331 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
2314 gcpro##5.next = &gcpro##4; gcpro##5.var = &var5; gcpro##5.nvars = 1; \ 2332 gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \
2315 gcpro##5.level = gcpro_level++; \ 2333 gcpro5.level = gcpro_level++; \
2316 gcprolist = &gcpro##5; } 2334 gcprolist = &gcpro5; }
2317 2335
2318#define GCPRO6_VAR(var1, var2, var3, var4, var5, var6, gcpro) \ 2336#define GCPRO6(varname1, varname2, varname3, varname4, varname5, varname6) \
2319 {gcpro##1.next = gcprolist; gcpro##1.var = &var1; gcpro##1.nvars = 1; \ 2337 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
2320 gcpro##1.level = gcpro_level; \ 2338 gcpro1.level = gcpro_level; \
2321 gcpro##2.next = &gcpro##1; gcpro##2.var = &var2; gcpro##2.nvars = 1; \ 2339 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
2322 gcpro##3.next = &gcpro##2; gcpro##3.var = &var3; gcpro##3.nvars = 1; \ 2340 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
2323 gcpro##4.next = &gcpro##3; gcpro##4.var = &var4; gcpro##4.nvars = 1; \ 2341 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
2324 gcpro##5.next = &gcpro##4; gcpro##5.var = &var5; gcpro##5.nvars = 1; \ 2342 gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \
2325 gcpro##6.next = &gcpro##5; gcpro##6.var = &var6; gcpro##6.nvars = 1; \ 2343 gcpro6.next = &gcpro5; gcpro6.var = &varname6; gcpro6.nvars = 1; \
2326 gcpro##6.level = gcpro_level++; \ 2344 gcpro6.level = gcpro_level++; \
2327 gcprolist = &gcpro##6; } 2345 gcprolist = &gcpro6; }
2328 2346
2329#define UNGCPRO_VAR(gcpro) \ 2347#define UNGCPRO \
2330 ((--gcpro_level != gcpro##1.level) \ 2348 ((--gcpro_level != gcpro1.level) \
2331 ? (abort (), 0) \ 2349 ? (abort (), 0) \
2332 : ((gcprolist = gcpro##1.next), 0)) 2350 : ((gcprolist = gcpro1.next), 0))
2333 2351
2334#endif /* DEBUG_GCPRO */ 2352#endif /* DEBUG_GCPRO */
2335#endif /* GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS */ 2353#endif /* GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS */
@@ -2534,18 +2552,20 @@ extern void syms_of_syntax (void);
2534 2552
2535/* Defined in fns.c */ 2553/* Defined in fns.c */
2536extern Lisp_Object QCrehash_size, QCrehash_threshold; 2554extern Lisp_Object QCrehash_size, QCrehash_threshold;
2555enum { NEXT_ALMOST_PRIME_LIMIT = 11 };
2537extern EMACS_INT next_almost_prime (EMACS_INT); 2556extern EMACS_INT next_almost_prime (EMACS_INT);
2538extern Lisp_Object larger_vector (Lisp_Object, EMACS_INT, Lisp_Object); 2557extern Lisp_Object larger_vector (Lisp_Object, EMACS_INT, Lisp_Object);
2539extern void sweep_weak_hash_tables (void); 2558extern void sweep_weak_hash_tables (void);
2540extern Lisp_Object Qcursor_in_echo_area; 2559extern Lisp_Object Qcursor_in_echo_area;
2541extern Lisp_Object Qstring_lessp; 2560extern Lisp_Object Qstring_lessp;
2542extern Lisp_Object QCsize, QCtest, QCweakness, Qequal, Qeq, Qeql; 2561extern Lisp_Object QCsize, QCtest, QCweakness, Qequal, Qeq, Qeql;
2562EMACS_UINT hash_string (char const *, ptrdiff_t);
2543EMACS_UINT sxhash (Lisp_Object, int); 2563EMACS_UINT sxhash (Lisp_Object, int);
2544Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object, 2564Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object,
2545 Lisp_Object, Lisp_Object, Lisp_Object, 2565 Lisp_Object, Lisp_Object, Lisp_Object,
2546 Lisp_Object); 2566 Lisp_Object);
2547EMACS_INT hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *); 2567ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *);
2548EMACS_INT hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, 2568ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object,
2549 EMACS_UINT); 2569 EMACS_UINT);
2550void init_weak_hash_tables (void); 2570void init_weak_hash_tables (void);
2551extern void init_fns (void); 2571extern void init_fns (void);
@@ -2843,6 +2863,7 @@ extern void map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Ob
2843 Lisp_Object, Lisp_Object, 2863 Lisp_Object, Lisp_Object,
2844 Lisp_Object, struct charset *, 2864 Lisp_Object, struct charset *,
2845 unsigned, unsigned); 2865 unsigned, unsigned);
2866extern Lisp_Object uniprop_table (Lisp_Object);
2846extern void syms_of_chartab (void); 2867extern void syms_of_chartab (void);
2847 2868
2848/* Defined in print.c */ 2869/* Defined in print.c */
@@ -2868,7 +2889,16 @@ extern void float_to_string (char *, double);
2868extern void syms_of_print (void); 2889extern void syms_of_print (void);
2869 2890
2870/* Defined in doprnt.c */ 2891/* Defined in doprnt.c */
2871extern size_t doprnt (char *, size_t, const char *, const char *, va_list); 2892extern ptrdiff_t doprnt (char *, ptrdiff_t, const char *, const char *,
2893 va_list);
2894extern ptrdiff_t esprintf (char *, char const *, ...)
2895 ATTRIBUTE_FORMAT_PRINTF (2, 3);
2896extern ptrdiff_t exprintf (char **, ptrdiff_t *, char const *, ptrdiff_t,
2897 char const *, ...)
2898 ATTRIBUTE_FORMAT_PRINTF (5, 6);
2899extern ptrdiff_t evxprintf (char **, ptrdiff_t *, char const *, ptrdiff_t,
2900 char const *, va_list)
2901 ATTRIBUTE_FORMAT_PRINTF (5, 0);
2872 2902
2873/* Defined in lread.c. */ 2903/* Defined in lread.c. */
2874extern Lisp_Object Qvariable_documentation, Qstandard_input; 2904extern Lisp_Object Qvariable_documentation, Qstandard_input;
@@ -2907,6 +2937,7 @@ extern Lisp_Object Qinhibit_quit, Qclosure;
2907extern Lisp_Object Qand_rest; 2937extern Lisp_Object Qand_rest;
2908extern Lisp_Object Vautoload_queue; 2938extern Lisp_Object Vautoload_queue;
2909extern Lisp_Object Vsignaling_function; 2939extern Lisp_Object Vsignaling_function;
2940extern Lisp_Object inhibit_lisp_code;
2910extern int handling_signal; 2941extern int handling_signal;
2911#if BYTE_MARK_STACK 2942#if BYTE_MARK_STACK
2912extern struct catchtag *catchlist; 2943extern struct catchtag *catchlist;
@@ -3115,10 +3146,6 @@ extern void syms_of_fileio (void);
3115extern Lisp_Object make_temp_name (Lisp_Object, int); 3146extern Lisp_Object make_temp_name (Lisp_Object, int);
3116extern Lisp_Object Qdelete_file; 3147extern Lisp_Object Qdelete_file;
3117 3148
3118/* Defined in abbrev.c */
3119
3120extern void syms_of_abbrev (void);
3121
3122/* Defined in search.c */ 3149/* Defined in search.c */
3123extern void shrink_regexp_cache (void); 3150extern void shrink_regexp_cache (void);
3124EXFUN (Fstring_match, 3); 3151EXFUN (Fstring_match, 3);
@@ -3160,7 +3187,7 @@ EXFUN (Fread_minibuffer, 2);
3160EXFUN (Feval_minibuffer, 2); 3187EXFUN (Feval_minibuffer, 2);
3161EXFUN (Fread_string, 5); 3188EXFUN (Fread_string, 5);
3162EXFUN (Fassoc_string, 3); 3189EXFUN (Fassoc_string, 3);
3163extern Lisp_Object get_minibuffer (int); 3190extern Lisp_Object get_minibuffer (EMACS_INT);
3164extern void init_minibuf_once (void); 3191extern void init_minibuf_once (void);
3165extern void syms_of_minibuf (void); 3192extern void syms_of_minibuf (void);
3166 3193
@@ -3224,8 +3251,6 @@ extern void force_auto_save_soon (void);
3224extern void init_keyboard (void); 3251extern void init_keyboard (void);
3225extern void syms_of_keyboard (void); 3252extern void syms_of_keyboard (void);
3226extern void keys_of_keyboard (void); 3253extern void keys_of_keyboard (void);
3227extern char *push_key_description (unsigned int, char *, int);
3228
3229 3254
3230/* Defined in indent.c */ 3255/* Defined in indent.c */
3231EXFUN (Fvertical_motion, 2); 3256EXFUN (Fvertical_motion, 2);
@@ -3262,7 +3287,7 @@ extern void syms_of_frame (void);
3262/* Defined in emacs.c */ 3287/* Defined in emacs.c */
3263extern char **initial_argv; 3288extern char **initial_argv;
3264extern int initial_argc; 3289extern int initial_argc;
3265#if defined(HAVE_X_WINDOWS) || defined(HAVE_NS) 3290#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
3266extern int display_arg; 3291extern int display_arg;
3267#endif 3292#endif
3268extern Lisp_Object decode_env_path (const char *, const char *); 3293extern Lisp_Object decode_env_path (const char *, const char *);
@@ -3271,6 +3296,7 @@ extern Lisp_Object Qfile_name_handler_alist;
3271#ifdef FLOAT_CATCH_SIGILL 3296#ifdef FLOAT_CATCH_SIGILL
3272extern void fatal_error_signal (int); 3297extern void fatal_error_signal (int);
3273#endif 3298#endif
3299extern Lisp_Object Qkill_emacs;
3274EXFUN (Fkill_emacs, 1) NO_RETURN; 3300EXFUN (Fkill_emacs, 1) NO_RETURN;
3275#if HAVE_SETLOCALE 3301#if HAVE_SETLOCALE
3276void fixup_locale (void); 3302void fixup_locale (void);
@@ -3429,18 +3455,6 @@ extern EMACS_INT emacs_read (int, char *, EMACS_INT);
3429extern EMACS_INT emacs_write (int, const char *, EMACS_INT); 3455extern EMACS_INT emacs_write (int, const char *, EMACS_INT);
3430enum { READLINK_BUFSIZE = 1024 }; 3456enum { READLINK_BUFSIZE = 1024 };
3431extern char *emacs_readlink (const char *, char [READLINK_BUFSIZE]); 3457extern char *emacs_readlink (const char *, char [READLINK_BUFSIZE]);
3432#ifndef HAVE_MEMSET
3433extern void *memset (void *, int, size_t);
3434#endif
3435#ifndef HAVE_MEMCPY
3436extern void *memcpy (void *, void *, size_t);
3437#endif
3438#ifndef HAVE_MEMMOVE
3439extern void *memmove (void *, void *, size_t);
3440#endif
3441#ifndef HAVE_MEMCMP
3442extern int memcmp (void *, void *, size_t);
3443#endif
3444 3458
3445EXFUN (Funlock_buffer, 0); 3459EXFUN (Funlock_buffer, 0);
3446extern void unlock_all_files (void); 3460extern void unlock_all_files (void);
@@ -3561,6 +3575,9 @@ extern int immediate_quit; /* Nonzero means ^G can quit instantly */
3561extern POINTER_TYPE *xmalloc (size_t); 3575extern POINTER_TYPE *xmalloc (size_t);
3562extern POINTER_TYPE *xrealloc (POINTER_TYPE *, size_t); 3576extern POINTER_TYPE *xrealloc (POINTER_TYPE *, size_t);
3563extern void xfree (POINTER_TYPE *); 3577extern void xfree (POINTER_TYPE *);
3578extern void *xnmalloc (ptrdiff_t, ptrdiff_t);
3579extern void *xnrealloc (void *, ptrdiff_t, ptrdiff_t);
3580extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t);
3564 3581
3565extern char *xstrdup (const char *); 3582extern char *xstrdup (const char *);
3566 3583
@@ -3590,7 +3607,7 @@ extern void init_system_name (void);
3590 3607
3591#define SWITCH_ENUM_CAST(x) (x) 3608#define SWITCH_ENUM_CAST(x) (x)
3592 3609
3593/* Use this to suppress gcc's warnings. */ 3610/* Use this to suppress gcc's warnings. */
3594#ifdef lint 3611#ifdef lint
3595 3612
3596/* Use CODE only if lint checking is in effect. */ 3613/* Use CODE only if lint checking is in effect. */
@@ -3617,7 +3634,7 @@ extern void init_system_name (void);
3617/* We used to use `abs', but that clashes with system headers on some 3634/* We used to use `abs', but that clashes with system headers on some
3618 platforms, and using a name reserved by Standard C is a bad idea 3635 platforms, and using a name reserved by Standard C is a bad idea
3619 anyway. */ 3636 anyway. */
3620#if !defined(eabs) 3637#if !defined (eabs)
3621#define eabs(x) ((x) < 0 ? -(x) : (x)) 3638#define eabs(x) ((x) < 0 ? -(x) : (x))
3622#endif 3639#endif
3623 3640
@@ -3678,6 +3695,23 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3678 } \ 3695 } \
3679 } while (0) 3696 } while (0)
3680 3697
3698/* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER *
3699 NITEMS items, each of the same type as *BUF. MULTIPLIER must
3700 positive. The code is tuned for MULTIPLIER being a constant. */
3701
3702#define SAFE_NALLOCA(buf, multiplier, nitems) \
3703 do { \
3704 if ((nitems) <= MAX_ALLOCA / sizeof *(buf) / (multiplier)) \
3705 (buf) = alloca (sizeof *(buf) * (multiplier) * (nitems)); \
3706 else \
3707 { \
3708 (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \
3709 sa_must_free = 1; \
3710 record_unwind_protect (safe_alloca_unwind, \
3711 make_save_value (buf, 0)); \
3712 } \
3713 } while (0)
3714
3681/* SAFE_FREE frees xmalloced memory and enables GC as needed. */ 3715/* SAFE_FREE frees xmalloced memory and enables GC as needed. */
3682 3716
3683#define SAFE_FREE() \ 3717#define SAFE_FREE() \