diff --git a/src/alloc.c b/src/alloc.c index a0639fd577..cbeb51bbc9 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -638,13 +638,23 @@ buffer_memory_full (ptrdiff_t nbytes) /* LISP_ALIGNMENT is the alignment of Lisp objects. It must be at least GCALIGNMENT so that pointers can be tagged. It also must be at least as strict as the alignment of all the C types used to - implement Lisp objects; since pseudovectors can contain any C type, - this is max_align_t. On recent GNU/Linux x86 and x86-64 this can - often waste up to 8 bytes, since alignof (max_align_t) is 16 but - typical vectors need only an alignment of 8. However, it is not - worth the hassle to avoid this waste. */ -enum { LISP_ALIGNMENT = alignof (union { max_align_t x; - GCALIGNED_UNION_MEMBER }) }; + implement Lisp objects. This union contains all the C types whose + alignment contributes to LISP_ALIGNMENT. This is not an exhaustive + list of the types, just enough so that the answer works on all + practical Emacs targets. This union does not contain max_align_t, + because with recent GCC on x86 that has an alignment of 16, but + Emacs does not use any types requiring an alignment more than 8. + Emacs modules must respect the alignment limit here. */ +union Lisp_kitchen_sink +{ + double d; + intmax_t i; + uintmax_t u; + void (*f) (void); + void *p; + GCALIGNED_UNION_MEMBER +}; +enum { LISP_ALIGNMENT = alignof (union Lisp_kitchen_sink) }; verify (LISP_ALIGNMENT % GCALIGNMENT == 0); /* True if malloc (N) is known to return storage suitably aligned for