aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/lisp.h b/src/lisp.h
index ee2e72d32b7..293cf2783c3 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -228,8 +228,8 @@ extern bool suppress_checking EXTERNALLY_VISIBLE;
228 228
229 USE_LSB_TAG not only requires the least 3 bits of pointers returned by 229 USE_LSB_TAG not only requires the least 3 bits of pointers returned by
230 malloc to be 0 but also needs to be able to impose a mult-of-8 alignment 230 malloc to be 0 but also needs to be able to impose a mult-of-8 alignment
231 on the few static Lisp_Objects used, all of which are aligned via 231 on some non-GC Lisp_Objects, all of which are aligned via
232 'char alignas (GCALIGNMENT) gcaligned;' inside a union. */ 232 GCALIGNED_UNION at the end of a union. */
233 233
234enum Lisp_Bits 234enum Lisp_Bits
235 { 235 {
@@ -277,6 +277,12 @@ DEFINE_GDB_SYMBOL_END (VALMASK)
277error !; 277error !;
278#endif 278#endif
279 279
280#if USE_LSB_TAG
281# define GCALIGNED_UNION char alignas (GCALIGNMENT) gcaligned;
282#else
283# define GCALIGNED_UNION
284#endif
285
280/* Lisp_Word is a scalar word suitable for holding a tagged pointer or 286/* Lisp_Word is a scalar word suitable for holding a tagged pointer or
281 integer. Usually it is a pointer to a deliberately-incomplete type 287 integer. Usually it is a pointer to a deliberately-incomplete type
282 'union Lisp_X'. However, it is EMACS_INT when Lisp_Objects and 288 'union Lisp_X'. However, it is EMACS_INT when Lisp_Objects and
@@ -776,10 +782,10 @@ struct Lisp_Symbol
776 /* Next symbol in obarray bucket, if the symbol is interned. */ 782 /* Next symbol in obarray bucket, if the symbol is interned. */
777 struct Lisp_Symbol *next; 783 struct Lisp_Symbol *next;
778 } s; 784 } s;
779 char alignas (GCALIGNMENT) gcaligned; 785 GCALIGNED_UNION
780 } u; 786 } u;
781}; 787};
782verify (alignof (struct Lisp_Symbol) % GCALIGNMENT == 0); 788verify (!USE_LSB_TAG || alignof (struct Lisp_Symbol) % GCALIGNMENT == 0);
783 789
784/* Declare a Lisp-callable function. The MAXARGS parameter has the same 790/* Declare a Lisp-callable function. The MAXARGS parameter has the same
785 meaning as in the DEFUN macro, and is used to construct a prototype. */ 791 meaning as in the DEFUN macro, and is used to construct a prototype. */
@@ -890,9 +896,9 @@ union vectorlike_header
890 Current layout limits the pseudovectors to 63 PVEC_xxx subtypes, 896 Current layout limits the pseudovectors to 63 PVEC_xxx subtypes,
891 4095 Lisp_Objects in GC-ed area and 4095 word-sized other slots. */ 897 4095 Lisp_Objects in GC-ed area and 4095 word-sized other slots. */
892 ptrdiff_t size; 898 ptrdiff_t size;
893 char alignas (GCALIGNMENT) gcaligned; 899 GCALIGNED_UNION
894 }; 900 };
895verify (alignof (union vectorlike_header) % GCALIGNMENT == 0); 901verify (!USE_LSB_TAG || alignof (union vectorlike_header) % GCALIGNMENT == 0);
896 902
897INLINE bool 903INLINE bool
898(SYMBOLP) (Lisp_Object x) 904(SYMBOLP) (Lisp_Object x)
@@ -1250,10 +1256,10 @@ struct Lisp_Cons
1250 struct Lisp_Cons *chain; 1256 struct Lisp_Cons *chain;
1251 } u; 1257 } u;
1252 } s; 1258 } s;
1253 char alignas (GCALIGNMENT) gcaligned; 1259 GCALIGNED_UNION
1254 } u; 1260 } u;
1255}; 1261};
1256verify (alignof (struct Lisp_Cons) % GCALIGNMENT == 0); 1262verify (!USE_LSB_TAG || alignof (struct Lisp_Cons) % GCALIGNMENT == 0);
1257 1263
1258INLINE bool 1264INLINE bool
1259(NILP) (Lisp_Object x) 1265(NILP) (Lisp_Object x)
@@ -1372,10 +1378,10 @@ struct Lisp_String
1372 unsigned char *data; 1378 unsigned char *data;
1373 } s; 1379 } s;
1374 struct Lisp_String *next; 1380 struct Lisp_String *next;
1375 char alignas (GCALIGNMENT) gcaligned; 1381 GCALIGNED_UNION
1376 } u; 1382 } u;
1377}; 1383};
1378verify (alignof (struct Lisp_String) % GCALIGNMENT == 0); 1384verify (!USE_LSB_TAG || alignof (struct Lisp_String) % GCALIGNMENT == 0);
1379 1385
1380INLINE bool 1386INLINE bool
1381STRINGP (Lisp_Object x) 1387STRINGP (Lisp_Object x)
@@ -3977,6 +3983,7 @@ extern void record_unwind_protect (void (*) (Lisp_Object), Lisp_Object);
3977extern void record_unwind_protect_ptr (void (*) (void *), void *); 3983extern void record_unwind_protect_ptr (void (*) (void *), void *);
3978extern void record_unwind_protect_int (void (*) (int), int); 3984extern void record_unwind_protect_int (void (*) (int), int);
3979extern void record_unwind_protect_void (void (*) (void)); 3985extern void record_unwind_protect_void (void (*) (void));
3986extern void record_unwind_protect_excursion (void);
3980extern void record_unwind_protect_nothing (void); 3987extern void record_unwind_protect_nothing (void);
3981extern void clear_unwind_protect (ptrdiff_t); 3988extern void clear_unwind_protect (ptrdiff_t);
3982extern void set_unwind_protect (ptrdiff_t, void (*) (Lisp_Object), Lisp_Object); 3989extern void set_unwind_protect (ptrdiff_t, void (*) (Lisp_Object), Lisp_Object);
@@ -4680,13 +4687,14 @@ extern void *record_xmalloc (size_t) ATTRIBUTE_ALLOC_SIZE ((1));
4680#define SAFE_ALLOCA_LISP(buf, nelt) SAFE_ALLOCA_LISP_EXTRA (buf, nelt, 0) 4687#define SAFE_ALLOCA_LISP(buf, nelt) SAFE_ALLOCA_LISP_EXTRA (buf, nelt, 0)
4681 4688
4682 4689
4683/* If USE_STACK_LISP_OBJECTS, define macros that and functions that allocate 4690/* If USE_STACK_LISP_OBJECTS, define macros and functions that
4684 block-scoped conses and strings. These objects are not 4691 allocate some Lisp objects on the C stack. As the storage is not
4685 managed by the garbage collector, so they are dangerous: passing them 4692 managed by the garbage collector, these objects are dangerous:
4686 out of their scope (e.g., to user code) results in undefined behavior. 4693 passing them to user code could result in undefined behavior if the
4687 Conversely, they have better performance because GC is not involved. 4694 objects are in use after the C function returns. Conversely, these
4695 objects have better performance because GC is not involved.
4688 4696
4689 This feature is experimental and requires careful debugging. 4697 While debugging you may want to disable allocation on the C stack.
4690 Build with CPPFLAGS='-DUSE_STACK_LISP_OBJECTS=0' to disable it. */ 4698 Build with CPPFLAGS='-DUSE_STACK_LISP_OBJECTS=0' to disable it. */
4691 4699
4692#if (!defined USE_STACK_LISP_OBJECTS \ 4700#if (!defined USE_STACK_LISP_OBJECTS \
@@ -4751,7 +4759,8 @@ enum
4751 Take its unibyte value from the null-terminated string STR, 4759 Take its unibyte value from the null-terminated string STR,
4752 an expression that should not have side effects. 4760 an expression that should not have side effects.
4753 STR's value is not necessarily copied. The resulting Lisp string 4761 STR's value is not necessarily copied. The resulting Lisp string
4754 should not be modified or made visible to user code. */ 4762 should not be modified or given text properties or made visible to
4763 user code. */
4755 4764
4756#define AUTO_STRING(name, str) \ 4765#define AUTO_STRING(name, str) \
4757 AUTO_STRING_WITH_LEN (name, str, strlen (str)) 4766 AUTO_STRING_WITH_LEN (name, str, strlen (str))
@@ -4760,7 +4769,8 @@ enum
4760 Take its unibyte value from the null-terminated string STR with length LEN. 4769 Take its unibyte value from the null-terminated string STR with length LEN.
4761 STR may have side effects and may contain null bytes. 4770 STR may have side effects and may contain null bytes.
4762 STR's value is not necessarily copied. The resulting Lisp string 4771 STR's value is not necessarily copied. The resulting Lisp string
4763 should not be modified or made visible to user code. */ 4772 should not be modified or given text properties or made visible to
4773 user code. */
4764 4774
4765#define AUTO_STRING_WITH_LEN(name, str, len) \ 4775#define AUTO_STRING_WITH_LEN(name, str, len) \
4766 Lisp_Object name = \ 4776 Lisp_Object name = \