diff options
| author | Paul Eggert | 2024-01-28 00:15:38 -0800 |
|---|---|---|
| committer | Paul Eggert | 2024-01-28 00:26:44 -0800 |
| commit | a3d7092114db09fee392ccc8187fde03376f2089 (patch) | |
| tree | 8181968918b6019154ba24f44d2e714f368f1a6a /src | |
| parent | fcf69960e89b826841a8c6ccc2af4019b5dc5e31 (diff) | |
| download | emacs-a3d7092114db09fee392ccc8187fde03376f2089.tar.gz emacs-a3d7092114db09fee392ccc8187fde03376f2089.zip | |
Rename TAG_PTR to TAG_PTR_INITIALLY
* src/lisp.h (TAG_PTR_INITIALLY): Rename from TAG_PTR, since calls
can be used only as initializers, and the convention elsewhere in
lisp.c is to give these macros names ending in ‘_INITIALLY’.
This should help avoid confusion such as we recently experienced
in make_lisp_symbol_internal. All uses changed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 2 | ||||
| -rw-r--r-- | src/lisp.h | 18 |
2 files changed, 8 insertions, 12 deletions
diff --git a/src/alloc.c b/src/alloc.c index ab31d21fb33..b144396948e 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -6295,7 +6295,7 @@ android_make_lisp_symbol (struct Lisp_Symbol *sym) | |||
| 6295 | &symoffset); | 6295 | &symoffset); |
| 6296 | 6296 | ||
| 6297 | { | 6297 | { |
| 6298 | Lisp_Object a = TAG_PTR (Lisp_Symbol, symoffset); | 6298 | Lisp_Object a = TAG_PTR_INITIALLY (Lisp_Symbol, symoffset); |
| 6299 | return a; | 6299 | return a; |
| 6300 | } | 6300 | } |
| 6301 | } | 6301 | } |
diff --git a/src/lisp.h b/src/lisp.h index db886c65204..75134425a07 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -303,7 +303,7 @@ DEFINE_GDB_SYMBOL_END (VALMASK) | |||
| 303 | 303 | ||
| 304 | #define LISP_WORDS_ARE_POINTERS (EMACS_INT_MAX == INTPTR_MAX) | 304 | #define LISP_WORDS_ARE_POINTERS (EMACS_INT_MAX == INTPTR_MAX) |
| 305 | #if LISP_WORDS_ARE_POINTERS | 305 | #if LISP_WORDS_ARE_POINTERS |
| 306 | /* TAG_PTR casts to Lisp_Word and can be used in static initializers, | 306 | /* TAG_PTR_INITIALLY casts to Lisp_Word and can be used in static initializers |
| 307 | so this typedef assumes static initializers can contain casts to pointers. | 307 | so this typedef assumes static initializers can contain casts to pointers. |
| 308 | All Emacs targets support this extension to the C standard. */ | 308 | All Emacs targets support this extension to the C standard. */ |
| 309 | typedef struct Lisp_X *Lisp_Word; | 309 | typedef struct Lisp_X *Lisp_Word; |
| @@ -937,13 +937,13 @@ typedef EMACS_UINT Lisp_Word_tag; | |||
| 937 | /* An initializer for a Lisp_Object that contains TAG along with P. | 937 | /* An initializer for a Lisp_Object that contains TAG along with P. |
| 938 | P can be a pointer or an integer. The result is usable in a static | 938 | P can be a pointer or an integer. The result is usable in a static |
| 939 | initializer if TAG and P are both integer constant expressions. */ | 939 | initializer if TAG and P are both integer constant expressions. */ |
| 940 | #define TAG_PTR(tag, p) \ | 940 | #define TAG_PTR_INITIALLY(tag, p) \ |
| 941 | LISP_INITIALLY ((Lisp_Word) ((uintptr_t) (p) + LISP_WORD_TAG (tag))) | 941 | LISP_INITIALLY ((Lisp_Word) ((uintptr_t) (p) + LISP_WORD_TAG (tag))) |
| 942 | 942 | ||
| 943 | /* LISPSYM_INITIALLY (Qfoo) is equivalent to Qfoo except it is | 943 | /* LISPSYM_INITIALLY (Qfoo) is equivalent to Qfoo except it is |
| 944 | designed for use as a (possibly static) initializer. */ | 944 | designed for use as a (possibly static) initializer. */ |
| 945 | #define LISPSYM_INITIALLY(name) \ | 945 | #define LISPSYM_INITIALLY(name) \ |
| 946 | TAG_PTR (Lisp_Symbol, (intptr_t) ((i##name) * sizeof *lispsym)) | 946 | TAG_PTR_INITIALLY (Lisp_Symbol, (intptr_t) ((i##name) * sizeof *lispsym)) |
| 947 | 947 | ||
| 948 | /* Declare extern constants for Lisp symbols. These can be helpful | 948 | /* Declare extern constants for Lisp symbols. These can be helpful |
| 949 | when using a debugger like GDB, on older platforms where the debug | 949 | when using a debugger like GDB, on older platforms where the debug |
| @@ -1178,11 +1178,7 @@ make_lisp_symbol_internal (struct Lisp_Symbol *sym) | |||
| 1178 | Do not use eassert here, so that builtin symbols like Qnil compile to | 1178 | Do not use eassert here, so that builtin symbols like Qnil compile to |
| 1179 | constants; this is needed for some circa-2024 GCCs even with -O2. */ | 1179 | constants; this is needed for some circa-2024 GCCs even with -O2. */ |
| 1180 | char *symoffset = (char *) ((char *) sym - (char *) lispsym); | 1180 | char *symoffset = (char *) ((char *) sym - (char *) lispsym); |
| 1181 | /* FIXME: We need this silly `a = ... return` η-redex because otherwise GCC | 1181 | Lisp_Object a = TAG_PTR_INITIALLY (Lisp_Symbol, symoffset); |
| 1182 | complains about: | ||
| 1183 | lisp.h:615:28: error: expected expression before ‘{’ token | ||
| 1184 | 615 | # define LISP_INITIALLY(w) {w} */ | ||
| 1185 | Lisp_Object a = TAG_PTR (Lisp_Symbol, symoffset); | ||
| 1186 | return a; | 1182 | return a; |
| 1187 | } | 1183 | } |
| 1188 | 1184 | ||
| @@ -1383,7 +1379,7 @@ clip_to_bounds (intmax_t lower, intmax_t num, intmax_t upper) | |||
| 1383 | INLINE Lisp_Object | 1379 | INLINE Lisp_Object |
| 1384 | make_lisp_ptr (void *ptr, enum Lisp_Type type) | 1380 | make_lisp_ptr (void *ptr, enum Lisp_Type type) |
| 1385 | { | 1381 | { |
| 1386 | Lisp_Object a = TAG_PTR (type, ptr); | 1382 | Lisp_Object a = TAG_PTR_INITIALLY (type, ptr); |
| 1387 | eassert (TAGGEDP (a, type) && XUNTAG (a, type, char) == ptr); | 1383 | eassert (TAGGEDP (a, type) && XUNTAG (a, type, char) == ptr); |
| 1388 | return a; | 1384 | return a; |
| 1389 | } | 1385 | } |
| @@ -1456,7 +1452,7 @@ XFIXNUMPTR (Lisp_Object a) | |||
| 1456 | INLINE Lisp_Object | 1452 | INLINE Lisp_Object |
| 1457 | make_pointer_integer_unsafe (void *p) | 1453 | make_pointer_integer_unsafe (void *p) |
| 1458 | { | 1454 | { |
| 1459 | Lisp_Object a = TAG_PTR (Lisp_Int0, p); | 1455 | Lisp_Object a = TAG_PTR_INITIALLY (Lisp_Int0, p); |
| 1460 | return a; | 1456 | return a; |
| 1461 | } | 1457 | } |
| 1462 | 1458 | ||
| @@ -2749,7 +2745,7 @@ extern Lisp_Object make_misc_ptr (void *); | |||
| 2749 | INLINE Lisp_Object | 2745 | INLINE Lisp_Object |
| 2750 | make_mint_ptr (void *a) | 2746 | make_mint_ptr (void *a) |
| 2751 | { | 2747 | { |
| 2752 | Lisp_Object val = TAG_PTR (Lisp_Int0, a); | 2748 | Lisp_Object val = TAG_PTR_INITIALLY (Lisp_Int0, a); |
| 2753 | return FIXNUMP (val) && XFIXNUMPTR (val) == a ? val : make_misc_ptr (a); | 2749 | return FIXNUMP (val) && XFIXNUMPTR (val) == a ? val : make_misc_ptr (a); |
| 2754 | } | 2750 | } |
| 2755 | 2751 | ||