diff options
| author | Paul Eggert | 2025-12-07 15:21:46 -0800 |
|---|---|---|
| committer | Paul Eggert | 2025-12-07 15:45:20 -0800 |
| commit | 0d43f2a562c84ff440da978a9275fc44e6f5d9da (patch) | |
| tree | 641ca54e5cce525471cf65ba3fb3952b0176469c /src | |
| parent | f766e8a36b47c55946e577af3dd70f43ebf05a93 (diff) | |
| download | emacs-0d43f2a562c84ff440da978a9275fc44e6f5d9da.tar.gz emacs-0d43f2a562c84ff440da978a9275fc44e6f5d9da.zip | |
Align config.h better to src/lisp.h
This is mostly a cleanup patch to fix growing discrepancies
between src/lisp.h and configure.ac in terms of how they deduce
how EMACS_INT aligns. The patch includes a static check that the
two methods now agree. It also speeds up ‘configure’ a bit.
* configure.ac (ALIGNOF_INT, ALIGNOF_LONG, ALIGNOF_LONG_LONG):
Remove; no longer used.
(ALIGNOF_EMACS_INT): New macro.
(system_malloc): Set to 'no' more consistently with what’s
in src/lisp.h.
* src/lisp.h (ALIGNOF_EMACS_INT): Do not define here, as config.h
defines it now. Check that config.h’s definition equals the
actual alignof (EMACS_INT).
(USE_USB_TAG): Set more consistently with what’s in configure.ac.
(alignas): Don’t second-guess Gnulib.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lisp.h | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/lisp.h b/src/lisp.h index 47442a29f50..e63019cc088 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -90,21 +90,18 @@ DEFINE_GDB_SYMBOL_END (GCTYPEBITS) | |||
| 90 | typedef int EMACS_INT; | 90 | typedef int EMACS_INT; |
| 91 | typedef unsigned int EMACS_UINT; | 91 | typedef unsigned int EMACS_UINT; |
| 92 | enum { EMACS_INT_WIDTH = INT_WIDTH, EMACS_UINT_WIDTH = UINT_WIDTH }; | 92 | enum { EMACS_INT_WIDTH = INT_WIDTH, EMACS_UINT_WIDTH = UINT_WIDTH }; |
| 93 | # define ALIGNOF_EMACS_INT ALIGNOF_INT | ||
| 94 | # define EMACS_INT_MAX INT_MAX | 93 | # define EMACS_INT_MAX INT_MAX |
| 95 | # define pI "" | 94 | # define pI "" |
| 96 | # elif INTPTR_MAX <= LONG_MAX && !defined WIDE_EMACS_INT | 95 | # elif INTPTR_MAX <= LONG_MAX && !defined WIDE_EMACS_INT |
| 97 | typedef long int EMACS_INT; | 96 | typedef long int EMACS_INT; |
| 98 | typedef unsigned long EMACS_UINT; | 97 | typedef unsigned long EMACS_UINT; |
| 99 | enum { EMACS_INT_WIDTH = LONG_WIDTH, EMACS_UINT_WIDTH = ULONG_WIDTH }; | 98 | enum { EMACS_INT_WIDTH = LONG_WIDTH, EMACS_UINT_WIDTH = ULONG_WIDTH }; |
| 100 | # define ALIGNOF_EMACS_INT ALIGNOF_LONG | ||
| 101 | # define EMACS_INT_MAX LONG_MAX | 99 | # define EMACS_INT_MAX LONG_MAX |
| 102 | # define pI "l" | 100 | # define pI "l" |
| 103 | # elif INTPTR_MAX <= LLONG_MAX | 101 | # elif INTPTR_MAX <= LLONG_MAX |
| 104 | typedef long long int EMACS_INT; | 102 | typedef long long int EMACS_INT; |
| 105 | typedef unsigned long long int EMACS_UINT; | 103 | typedef unsigned long long int EMACS_UINT; |
| 106 | enum { EMACS_INT_WIDTH = LLONG_WIDTH, EMACS_UINT_WIDTH = ULLONG_WIDTH }; | 104 | enum { EMACS_INT_WIDTH = LLONG_WIDTH, EMACS_UINT_WIDTH = ULLONG_WIDTH }; |
| 107 | # define ALIGNOF_EMACS_INT ALIGNOF_LONG_LONG | ||
| 108 | # define EMACS_INT_MAX LLONG_MAX | 105 | # define EMACS_INT_MAX LLONG_MAX |
| 109 | /* MinGW supports %lld only if __USE_MINGW_ANSI_STDIO is non-zero, | 106 | /* MinGW supports %lld only if __USE_MINGW_ANSI_STDIO is non-zero, |
| 110 | which is arranged by config.h, and (for mingw.org) if GCC is 6.0 or | 107 | which is arranged by config.h, and (for mingw.org) if GCC is 6.0 or |
| @@ -123,6 +120,7 @@ enum { EMACS_INT_WIDTH = LLONG_WIDTH, EMACS_UINT_WIDTH = ULLONG_WIDTH }; | |||
| 123 | # error "INTPTR_MAX too large" | 120 | # error "INTPTR_MAX too large" |
| 124 | # endif | 121 | # endif |
| 125 | #endif | 122 | #endif |
| 123 | static_assert (alignof (EMACS_INT) == ALIGNOF_EMACS_INT); | ||
| 126 | 124 | ||
| 127 | /* Number of bits to put in each character in the internal representation | 125 | /* Number of bits to put in each character in the internal representation |
| 128 | of bool vectors. This should not vary across implementations. */ | 126 | of bool vectors. This should not vary across implementations. */ |
| @@ -252,15 +250,13 @@ DEFINE_GDB_SYMBOL_END (INTTYPEBITS) | |||
| 252 | b. slower, because it typically requires extra masking. | 250 | b. slower, because it typically requires extra masking. |
| 253 | So, USE_LSB_TAG is true only on hosts where it might be useful. */ | 251 | So, USE_LSB_TAG is true only on hosts where it might be useful. */ |
| 254 | DEFINE_GDB_SYMBOL_BEGIN (bool, USE_LSB_TAG) | 252 | DEFINE_GDB_SYMBOL_BEGIN (bool, USE_LSB_TAG) |
| 255 | #if (ALIGNOF_EMACS_INT < IDEAL_GCALIGNMENT && !defined alignas \ | 253 | #if (ALIGNOF_EMACS_INT < IDEAL_GCALIGNMENT \ |
| 256 | && ! (__GNUC__ || 4 <= __clang_major__) \ | 254 | && !HAVE_C_ALIGNASOF && !defined alignas \ |
| 257 | && __STDC_VERSION__ < 202311 && __cplusplus < 201103) \ | 255 | && !defined HAVE_STRUCT_ATTRIBUTE_ALIGNED) |
| 258 | && !defined WIDE_EMACS_INT \ | 256 | # define USE_LSB_TAG false |
| 259 | && !defined HAVE_STRUCT_ATTRIBUTE_ALIGNED | 257 | #else |
| 260 | #define USE_LSB_TAG 0 | 258 | # define USE_LSB_TAG (VAL_MAX / 2 < INTPTR_MAX) |
| 261 | #else /* ALIGNOF_EMACS_INT >= IDEAL_GCALIGNMENT || defined alignas ... */ | 259 | #endif |
| 262 | #define USE_LSB_TAG (VAL_MAX / 2 < INTPTR_MAX) | ||
| 263 | #endif /* ALIGNOF_EMACS_INT >= IDEAL_GCALIGNMENT || defined alignas ... */ | ||
| 264 | DEFINE_GDB_SYMBOL_END (USE_LSB_TAG) | 260 | DEFINE_GDB_SYMBOL_END (USE_LSB_TAG) |
| 265 | 261 | ||
| 266 | /* Mask for the value (as opposed to the type bits) of a Lisp object. */ | 262 | /* Mask for the value (as opposed to the type bits) of a Lisp object. */ |
| @@ -268,14 +264,9 @@ DEFINE_GDB_SYMBOL_BEGIN (EMACS_INT, VALMASK) | |||
| 268 | # define VALMASK (USE_LSB_TAG ? - (1 << GCTYPEBITS) : VAL_MAX) | 264 | # define VALMASK (USE_LSB_TAG ? - (1 << GCTYPEBITS) : VAL_MAX) |
| 269 | DEFINE_GDB_SYMBOL_END (VALMASK) | 265 | DEFINE_GDB_SYMBOL_END (VALMASK) |
| 270 | 266 | ||
| 271 | /* Support 'alignas (A)' if possible, where A is an integer constant. */ | 267 | /* Ignore 'alignas' on compilers lacking it. */ |
| 272 | #ifndef alignas | 268 | #if !HAVE_C_ALIGNASOF && !defined alignas |
| 273 | # if __GNUC__ || 4 <= __clang_major__ | 269 | # define alignas(a) /* not supported */ |
| 274 | /* This is more reliable than the alignas operator, in GCC 14. */ | ||
| 275 | # define alignas(a) __attribute__ ((__aligned__ (a))) | ||
| 276 | # elif __STDC_VERSION__ < 202311 && __cplusplus < 201103 | ||
| 277 | # define alignas(a) /* not supported */ | ||
| 278 | # endif | ||
| 279 | #endif | 270 | #endif |
| 280 | 271 | ||
| 281 | /* The minimum alignment requirement for Lisp objects that is imposed by the | 272 | /* The minimum alignment requirement for Lisp objects that is imposed by the |