diff options
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/src/lisp.h b/src/lisp.h index 976b7a15251..e9836a2211b 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -140,7 +140,7 @@ typedef unsigned char bits_word; | |||
| 140 | # define BITS_WORD_MAX ((1u << BOOL_VECTOR_BITS_PER_CHAR) - 1) | 140 | # define BITS_WORD_MAX ((1u << BOOL_VECTOR_BITS_PER_CHAR) - 1) |
| 141 | enum { BITS_PER_BITS_WORD = BOOL_VECTOR_BITS_PER_CHAR }; | 141 | enum { BITS_PER_BITS_WORD = BOOL_VECTOR_BITS_PER_CHAR }; |
| 142 | #endif | 142 | #endif |
| 143 | verify (BITS_WORD_MAX >> (BITS_PER_BITS_WORD - 1) == 1); | 143 | static_assert (BITS_WORD_MAX >> (BITS_PER_BITS_WORD - 1) == 1); |
| 144 | 144 | ||
| 145 | /* Use pD to format ptrdiff_t values, which suffice for indexes into | 145 | /* Use pD to format ptrdiff_t values, which suffice for indexes into |
| 146 | buffers and strings. Emacs never allocates objects larger than | 146 | buffers and strings. Emacs never allocates objects larger than |
| @@ -281,14 +281,14 @@ DEFINE_GDB_SYMBOL_END (VALMASK) | |||
| 281 | emacs_align_type union in alloc.c. | 281 | emacs_align_type union in alloc.c. |
| 282 | 282 | ||
| 283 | Although these macros are reasonably portable, they are not | 283 | Although these macros are reasonably portable, they are not |
| 284 | guaranteed on non-GCC platforms, as the C standard does not require support | 284 | guaranteed on non-GCC platforms, as the C standard does not require |
| 285 | for alignment to GCALIGNMENT and older compilers may ignore | 285 | support for alignment to GCALIGNMENT and older compilers may ignore |
| 286 | alignment requests. For any type T where garbage collection | 286 | alignment requests. For any type T where garbage collection requires |
| 287 | requires alignment, use verify (GCALIGNED (T)) to verify the | 287 | alignment, use static_assert (GCALIGNED (T)) to verify the |
| 288 | requirement on the current platform. Types need this check if | 288 | requirement on the current platform. Types need this check if their |
| 289 | their objects can be allocated outside the garbage collector. For | 289 | objects can be allocated outside the garbage collector. For example, |
| 290 | example, struct Lisp_Symbol needs the check because of lispsym and | 290 | struct Lisp_Symbol needs the check because of lispsym and struct |
| 291 | struct Lisp_Cons needs it because of STACK_CONS. */ | 291 | Lisp_Cons needs it because of STACK_CONS. */ |
| 292 | 292 | ||
| 293 | #define GCALIGNED_UNION_MEMBER char alignas (GCALIGNMENT) gcaligned; | 293 | #define GCALIGNED_UNION_MEMBER char alignas (GCALIGNMENT) gcaligned; |
| 294 | #if HAVE_STRUCT_ATTRIBUTE_ALIGNED | 294 | #if HAVE_STRUCT_ATTRIBUTE_ALIGNED |
| @@ -865,7 +865,7 @@ struct Lisp_Symbol | |||
| 865 | GCALIGNED_UNION_MEMBER | 865 | GCALIGNED_UNION_MEMBER |
| 866 | } u; | 866 | } u; |
| 867 | }; | 867 | }; |
| 868 | verify (GCALIGNED (struct Lisp_Symbol)); | 868 | static_assert (GCALIGNED (struct Lisp_Symbol)); |
| 869 | 869 | ||
| 870 | /* Declare a Lisp-callable function. The MAXARGS parameter has the same | 870 | /* Declare a Lisp-callable function. The MAXARGS parameter has the same |
| 871 | meaning as in the DEFUN macro, and is used to construct a prototype. */ | 871 | meaning as in the DEFUN macro, and is used to construct a prototype. */ |
| @@ -1480,7 +1480,7 @@ struct Lisp_Cons | |||
| 1480 | GCALIGNED_UNION_MEMBER | 1480 | GCALIGNED_UNION_MEMBER |
| 1481 | } u; | 1481 | } u; |
| 1482 | }; | 1482 | }; |
| 1483 | verify (GCALIGNED (struct Lisp_Cons)); | 1483 | static_assert (GCALIGNED (struct Lisp_Cons)); |
| 1484 | 1484 | ||
| 1485 | INLINE bool | 1485 | INLINE bool |
| 1486 | (NILP) (Lisp_Object x) | 1486 | (NILP) (Lisp_Object x) |
| @@ -1610,7 +1610,7 @@ struct Lisp_String | |||
| 1610 | GCALIGNED_UNION_MEMBER | 1610 | GCALIGNED_UNION_MEMBER |
| 1611 | } u; | 1611 | } u; |
| 1612 | }; | 1612 | }; |
| 1613 | verify (GCALIGNED (struct Lisp_String)); | 1613 | static_assert (GCALIGNED (struct Lisp_String)); |
| 1614 | 1614 | ||
| 1615 | INLINE bool | 1615 | INLINE bool |
| 1616 | STRINGP (Lisp_Object x) | 1616 | STRINGP (Lisp_Object x) |
| @@ -2025,10 +2025,11 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val) | |||
| 2025 | } | 2025 | } |
| 2026 | 2026 | ||
| 2027 | /* True, since Qnil's representation is zero. Every place in the code | 2027 | /* True, since Qnil's representation is zero. Every place in the code |
| 2028 | that assumes Qnil is zero should verify (NIL_IS_ZERO), to make it easy | 2028 | that assumes Qnil is zero should static_assert (NIL_IS_ZERO), to make |
| 2029 | to find such assumptions later if we change Qnil to be nonzero. | 2029 | it easy to find such assumptions later if we change Qnil to be |
| 2030 | Test iQnil and Lisp_Symbol instead of Qnil directly, since the latter | 2030 | nonzero. Test iQnil and Lisp_Symbol instead of Qnil directly, since |
| 2031 | is not suitable for use in an integer constant expression. */ | 2031 | the latter is not suitable for use in an integer constant |
| 2032 | expression. */ | ||
| 2032 | enum { NIL_IS_ZERO = iQnil == 0 && Lisp_Symbol == 0 }; | 2033 | enum { NIL_IS_ZERO = iQnil == 0 && Lisp_Symbol == 0 }; |
| 2033 | 2034 | ||
| 2034 | /* Clear the object addressed by P, with size NBYTES, so that all its | 2035 | /* Clear the object addressed by P, with size NBYTES, so that all its |
| @@ -2037,7 +2038,7 @@ INLINE void | |||
| 2037 | memclear (void *p, ptrdiff_t nbytes) | 2038 | memclear (void *p, ptrdiff_t nbytes) |
| 2038 | { | 2039 | { |
| 2039 | eassert (0 <= nbytes); | 2040 | eassert (0 <= nbytes); |
| 2040 | verify (NIL_IS_ZERO); | 2041 | static_assert (NIL_IS_ZERO); |
| 2041 | /* Since Qnil is zero, memset suffices. */ | 2042 | /* Since Qnil is zero, memset suffices. */ |
| 2042 | memset (p, 0, nbytes); | 2043 | memset (p, 0, nbytes); |
| 2043 | } | 2044 | } |
| @@ -2240,7 +2241,7 @@ union Aligned_Lisp_Subr | |||
| 2240 | struct Lisp_Subr s; | 2241 | struct Lisp_Subr s; |
| 2241 | GCALIGNED_UNION_MEMBER | 2242 | GCALIGNED_UNION_MEMBER |
| 2242 | }; | 2243 | }; |
| 2243 | verify (GCALIGNED (union Aligned_Lisp_Subr)); | 2244 | static_assert (GCALIGNED (union Aligned_Lisp_Subr)); |
| 2244 | 2245 | ||
| 2245 | INLINE bool | 2246 | INLINE bool |
| 2246 | SUBRP (Lisp_Object a) | 2247 | SUBRP (Lisp_Object a) |
| @@ -2281,11 +2282,11 @@ enum char_table_specials | |||
| 2281 | }; | 2282 | }; |
| 2282 | 2283 | ||
| 2283 | /* Sanity-check pseudovector layout. */ | 2284 | /* Sanity-check pseudovector layout. */ |
| 2284 | verify (offsetof (struct Lisp_Char_Table, defalt) == header_size); | 2285 | static_assert (offsetof (struct Lisp_Char_Table, defalt) == header_size); |
| 2285 | verify (offsetof (struct Lisp_Char_Table, extras) | 2286 | static_assert (offsetof (struct Lisp_Char_Table, extras) |
| 2286 | == header_size + CHAR_TABLE_STANDARD_SLOTS * sizeof (Lisp_Object)); | 2287 | == header_size + CHAR_TABLE_STANDARD_SLOTS * sizeof (Lisp_Object)); |
| 2287 | verify (offsetof (struct Lisp_Sub_Char_Table, contents) | 2288 | static_assert (offsetof (struct Lisp_Sub_Char_Table, contents) |
| 2288 | == header_size + SUB_CHAR_TABLE_OFFSET * sizeof (Lisp_Object)); | 2289 | == header_size + SUB_CHAR_TABLE_OFFSET * sizeof (Lisp_Object)); |
| 2289 | 2290 | ||
| 2290 | /* Return the number of "extra" slots in the char table CT. */ | 2291 | /* Return the number of "extra" slots in the char table CT. */ |
| 2291 | 2292 | ||
| @@ -2819,7 +2820,7 @@ SXHASH_REDUCE (EMACS_UINT x) | |||
| 2819 | INLINE hash_hash_t | 2820 | INLINE hash_hash_t |
| 2820 | reduce_emacs_uint_to_hash_hash (EMACS_UINT x) | 2821 | reduce_emacs_uint_to_hash_hash (EMACS_UINT x) |
| 2821 | { | 2822 | { |
| 2822 | verify (sizeof x <= 2 * sizeof (hash_hash_t)); | 2823 | static_assert (sizeof x <= 2 * sizeof (hash_hash_t)); |
| 2823 | return (sizeof x == sizeof (hash_hash_t) | 2824 | return (sizeof x == sizeof (hash_hash_t) |
| 2824 | ? x | 2825 | ? x |
| 2825 | : x ^ (x >> (8 * (sizeof x - sizeof (hash_hash_t))))); | 2826 | : x ^ (x >> (8 * (sizeof x - sizeof (hash_hash_t))))); |
| @@ -3214,7 +3215,7 @@ struct Lisp_Float | |||
| 3214 | GCALIGNED_UNION_MEMBER | 3215 | GCALIGNED_UNION_MEMBER |
| 3215 | } u; | 3216 | } u; |
| 3216 | }; | 3217 | }; |
| 3217 | verify (GCALIGNED (struct Lisp_Float)); | 3218 | static_assert (GCALIGNED (struct Lisp_Float)); |
| 3218 | 3219 | ||
| 3219 | INLINE bool | 3220 | INLINE bool |
| 3220 | (FLOATP) (Lisp_Object x) | 3221 | (FLOATP) (Lisp_Object x) |
| @@ -4204,7 +4205,7 @@ modiff_incr (modiff_count *a, ptrdiff_t len) | |||
| 4204 | /* Increase the counter more for a large modification and less for a | 4205 | /* Increase the counter more for a large modification and less for a |
| 4205 | small modification. Increase it logarithmically to avoid | 4206 | small modification. Increase it logarithmically to avoid |
| 4206 | increasing it too much. */ | 4207 | increasing it too much. */ |
| 4207 | verify (PTRDIFF_MAX <= ULLONG_MAX); | 4208 | static_assert (PTRDIFF_MAX <= ULLONG_MAX); |
| 4208 | int incr = len == 0 ? 1 : elogb (len) + 1; | 4209 | int incr = len == 0 ? 1 : elogb (len) + 1; |
| 4209 | bool modiff_overflow = ckd_add (a, a0, incr); | 4210 | bool modiff_overflow = ckd_add (a, a0, incr); |
| 4210 | eassert (!modiff_overflow && *a >> 30 >> 30 == 0); | 4211 | eassert (!modiff_overflow && *a >> 30 >> 30 == 0); |
| @@ -4344,7 +4345,7 @@ extern void tim_sort (Lisp_Object, Lisp_Object, Lisp_Object *, const ptrdiff_t, | |||
| 4344 | ARG_NONNULL ((3)); | 4345 | ARG_NONNULL ((3)); |
| 4345 | 4346 | ||
| 4346 | /* Defined in floatfns.c. */ | 4347 | /* Defined in floatfns.c. */ |
| 4347 | verify (FLT_RADIX == 2 || FLT_RADIX == 16); | 4348 | static_assert (FLT_RADIX == 2 || FLT_RADIX == 16); |
| 4348 | enum { LOG2_FLT_RADIX = FLT_RADIX == 2 ? 1 : 4 }; | 4349 | enum { LOG2_FLT_RADIX = FLT_RADIX == 2 ? 1 : 4 }; |
| 4349 | int double_integer_scale (double); | 4350 | int double_integer_scale (double); |
| 4350 | #ifndef HAVE_TRUNC | 4351 | #ifndef HAVE_TRUNC |