diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/alloc.c b/src/alloc.c index 48b170b866f..89729b0073b 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -709,7 +709,7 @@ buffer_memory_full (ptrdiff_t nbytes) | |||
| 709 | where Emacs would crash if malloc returned a non-GCALIGNED pointer. */ | 709 | where Emacs would crash if malloc returned a non-GCALIGNED pointer. */ |
| 710 | enum { LISP_ALIGNMENT = alignof (union { union emacs_align_type x; | 710 | enum { LISP_ALIGNMENT = alignof (union { union emacs_align_type x; |
| 711 | GCALIGNED_UNION_MEMBER }) }; | 711 | GCALIGNED_UNION_MEMBER }) }; |
| 712 | verify (LISP_ALIGNMENT % GCALIGNMENT == 0); | 712 | static_assert (LISP_ALIGNMENT % GCALIGNMENT == 0); |
| 713 | 713 | ||
| 714 | /* True if malloc (N) is known to return storage suitably aligned for | 714 | /* True if malloc (N) is known to return storage suitably aligned for |
| 715 | Lisp objects whenever N is a multiple of LISP_ALIGNMENT. In | 715 | Lisp objects whenever N is a multiple of LISP_ALIGNMENT. In |
| @@ -839,7 +839,7 @@ xfree (void *block) | |||
| 839 | /* Other parts of Emacs pass large int values to allocator functions | 839 | /* Other parts of Emacs pass large int values to allocator functions |
| 840 | expecting ptrdiff_t. This is portable in practice, but check it to | 840 | expecting ptrdiff_t. This is portable in practice, but check it to |
| 841 | be safe. */ | 841 | be safe. */ |
| 842 | verify (INT_MAX <= PTRDIFF_MAX); | 842 | static_assert (INT_MAX <= PTRDIFF_MAX); |
| 843 | 843 | ||
| 844 | 844 | ||
| 845 | /* Allocate an array of NITEMS items, each of size ITEM_SIZE. | 845 | /* Allocate an array of NITEMS items, each of size ITEM_SIZE. |
| @@ -1076,7 +1076,7 @@ lisp_free (void *block) | |||
| 1076 | #else /* !HAVE_UNEXEC */ | 1076 | #else /* !HAVE_UNEXEC */ |
| 1077 | # define BLOCK_ALIGN (1 << 15) | 1077 | # define BLOCK_ALIGN (1 << 15) |
| 1078 | #endif | 1078 | #endif |
| 1079 | verify (POWER_OF_2 (BLOCK_ALIGN)); | 1079 | static_assert (POWER_OF_2 (BLOCK_ALIGN)); |
| 1080 | 1080 | ||
| 1081 | /* Use aligned_alloc if it or a simple substitute is available. | 1081 | /* Use aligned_alloc if it or a simple substitute is available. |
| 1082 | Aligned allocation is incompatible with unexmacosx.c, so don't use | 1082 | Aligned allocation is incompatible with unexmacosx.c, so don't use |
| @@ -1096,11 +1096,11 @@ aligned_alloc (size_t alignment, size_t size) | |||
| 1096 | { | 1096 | { |
| 1097 | /* POSIX says the alignment must be a power-of-2 multiple of sizeof (void *). | 1097 | /* POSIX says the alignment must be a power-of-2 multiple of sizeof (void *). |
| 1098 | Verify this for all arguments this function is given. */ | 1098 | Verify this for all arguments this function is given. */ |
| 1099 | verify (BLOCK_ALIGN % sizeof (void *) == 0 | 1099 | static_assert (BLOCK_ALIGN % sizeof (void *) == 0 |
| 1100 | && POWER_OF_2 (BLOCK_ALIGN / sizeof (void *))); | 1100 | && POWER_OF_2 (BLOCK_ALIGN / sizeof (void *))); |
| 1101 | verify (MALLOC_IS_LISP_ALIGNED | 1101 | static_assert (MALLOC_IS_LISP_ALIGNED |
| 1102 | || (LISP_ALIGNMENT % sizeof (void *) == 0 | 1102 | || (LISP_ALIGNMENT % sizeof (void *) == 0 |
| 1103 | && POWER_OF_2 (LISP_ALIGNMENT / sizeof (void *)))); | 1103 | && POWER_OF_2 (LISP_ALIGNMENT / sizeof (void *)))); |
| 1104 | eassert (alignment == BLOCK_ALIGN | 1104 | eassert (alignment == BLOCK_ALIGN |
| 1105 | || (!MALLOC_IS_LISP_ALIGNED && alignment == LISP_ALIGNMENT)); | 1105 | || (!MALLOC_IS_LISP_ALIGNED && alignment == LISP_ALIGNMENT)); |
| 1106 | 1106 | ||
| @@ -1221,7 +1221,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) | |||
| 1221 | #endif | 1221 | #endif |
| 1222 | 1222 | ||
| 1223 | #ifdef USE_ALIGNED_ALLOC | 1223 | #ifdef USE_ALIGNED_ALLOC |
| 1224 | verify (ABLOCKS_BYTES % BLOCK_ALIGN == 0); | 1224 | static_assert (ABLOCKS_BYTES % BLOCK_ALIGN == 0); |
| 1225 | abase = base = aligned_alloc (BLOCK_ALIGN, ABLOCKS_BYTES); | 1225 | abase = base = aligned_alloc (BLOCK_ALIGN, ABLOCKS_BYTES); |
| 1226 | #else | 1226 | #else |
| 1227 | base = malloc (ABLOCKS_BYTES); | 1227 | base = malloc (ABLOCKS_BYTES); |
| @@ -3048,7 +3048,7 @@ enum { VECTOR_BLOCK_SIZE = 4096 }; | |||
| 3048 | enum { roundup_size = COMMON_MULTIPLE (LISP_ALIGNMENT, word_size) }; | 3048 | enum { roundup_size = COMMON_MULTIPLE (LISP_ALIGNMENT, word_size) }; |
| 3049 | 3049 | ||
| 3050 | /* Verify assumption described above. */ | 3050 | /* Verify assumption described above. */ |
| 3051 | verify (VECTOR_BLOCK_SIZE % roundup_size == 0); | 3051 | static_assert (VECTOR_BLOCK_SIZE % roundup_size == 0); |
| 3052 | 3052 | ||
| 3053 | /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */ | 3053 | /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */ |
| 3054 | #define vroundup_ct(x) ROUNDUP (x, roundup_size) | 3054 | #define vroundup_ct(x) ROUNDUP (x, roundup_size) |
| @@ -3062,7 +3062,7 @@ enum {VECTOR_BLOCK_BYTES = VECTOR_BLOCK_SIZE - vroundup_ct (sizeof (void *))}; | |||
| 3062 | /* The current code expects to be able to represent an unused block by | 3062 | /* The current code expects to be able to represent an unused block by |
| 3063 | a single PVEC_FREE object, whose size is limited by the header word. | 3063 | a single PVEC_FREE object, whose size is limited by the header word. |
| 3064 | (Of course we could use multiple such objects.) */ | 3064 | (Of course we could use multiple such objects.) */ |
| 3065 | verify (VECTOR_BLOCK_BYTES <= (word_size << PSEUDOVECTOR_REST_BITS)); | 3065 | static_assert (VECTOR_BLOCK_BYTES <= (word_size << PSEUDOVECTOR_REST_BITS)); |
| 3066 | 3066 | ||
| 3067 | /* Size of the minimal vector allocated from block. */ | 3067 | /* Size of the minimal vector allocated from block. */ |
| 3068 | 3068 | ||
| @@ -3319,7 +3319,7 @@ vectorlike_nbytes (const union vectorlike_header *hdr) | |||
| 3319 | ptrdiff_t word_bytes = (bool_vector_words (bv->size) | 3319 | ptrdiff_t word_bytes = (bool_vector_words (bv->size) |
| 3320 | * sizeof (bits_word)); | 3320 | * sizeof (bits_word)); |
| 3321 | ptrdiff_t boolvec_bytes = bool_header_size + word_bytes; | 3321 | ptrdiff_t boolvec_bytes = bool_header_size + word_bytes; |
| 3322 | verify (header_size <= bool_header_size); | 3322 | static_assert (header_size <= bool_header_size); |
| 3323 | nwords = (boolvec_bytes - header_size + word_size - 1) / word_size; | 3323 | nwords = (boolvec_bytes - header_size + word_size - 1) / word_size; |
| 3324 | } | 3324 | } |
| 3325 | else | 3325 | else |
| @@ -3699,7 +3699,7 @@ allocate_pseudovector (int memlen, int lisplen, | |||
| 3699 | /* Catch bogus values. */ | 3699 | /* Catch bogus values. */ |
| 3700 | enum { size_max = (1 << PSEUDOVECTOR_SIZE_BITS) - 1 }; | 3700 | enum { size_max = (1 << PSEUDOVECTOR_SIZE_BITS) - 1 }; |
| 3701 | enum { rest_max = (1 << PSEUDOVECTOR_REST_BITS) - 1 }; | 3701 | enum { rest_max = (1 << PSEUDOVECTOR_REST_BITS) - 1 }; |
| 3702 | verify (size_max + rest_max <= VECTOR_ELTS_MAX); | 3702 | static_assert (size_max + rest_max <= VECTOR_ELTS_MAX); |
| 3703 | eassert (0 <= tag && tag <= PVEC_TAG_MAX); | 3703 | eassert (0 <= tag && tag <= PVEC_TAG_MAX); |
| 3704 | eassert (0 <= lisplen && lisplen <= zerolen && zerolen <= memlen); | 3704 | eassert (0 <= lisplen && lisplen <= zerolen && zerolen <= memlen); |
| 3705 | eassert (lisplen <= size_max); | 3705 | eassert (lisplen <= size_max); |