1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-24 10:38:38 +00:00
emacs/lib-src
Paul Eggert b1573a97e1 Use alignas to fix GCALIGN-related bugs
Use alignas and unions to specify alignments of objects needing
addresses that are at least a multiple of GCALIGNMENT.  Using
these standard C facilities should be safer than relying on ad hoc
and poorly-understood features like GCC’s __attribute__
((aligned (N))), the root cause for recent porting bugs like
Bug#29040.  The alignas macro was standardized by C11 and Gnulib
supports alignas for pre-C11 platforms.  I have tested this on Sun
Studio 12 sparc (2007) and GCC 4.4.7 x86-64 (2012) as well as on
more recent platforms like GCC 7.2.1 (2017) on Fedora 26 (both
x86-64 and x86).
* lib-src/make-docfile.c (close_emacs_globals): lispsym is now
just an array of struct Lisp_Symbol, since struct Lisp_Symbol is
now properly aligned.  All uses changed.
* src/alloc.c (NEXT_FREE_LISP_STRING): Just use the new u.next
member; this is simpler and safer than casting a pointer that
might not be aligned properly.
(aligned_Lisp_Symbol): Remove.  No longer needed, now that struct
Lisp_Symbol is aligned properly.  All uses replaced with struct
Lisp_Symbol.
* src/lisp.h (GCALIGNED): Remove, as it does not work as expected:
it can cause the natural alignment to be ignored.  All uses
replaced by unions with a ‘char alignas (GCALIGNMENT)’ member as
described below.
(struct Lisp_Symbol, struct Lisp_Cons, struct Lisp_String):
Change definition from ‘struct TAG { MEMBERS };’ to
‘struct TAG { union { struct { MEMBERS } s; char alignas
(GCALIGNMENT) gcaligned; } u; };’.  This guarantees ‘struct TAG’
to have an alignment that at least max (GCALIGNMENT, N) where N is
its old alignment.  All uses like ‘PTR->MEMBER’ changed to
‘PTR->u.s.MEMBER’; these uses were supposed to be mostly private
anyway.  Verify that the resulting ‘struct TAG’ is properly
aligned for Emacs.
(union vectorlike_header): New member ‘gcaligned’ to guarantee
that this type, and its containing types like ‘struct Lisp_Subr’,
‘struct buffer’ and ‘struct thread_state’, are all properly
aligned for Emacs.
(struct Lisp_String): New union member ‘next’, for the benefit
of NEXT_FREE_LISP_STRING.
(union Aligned_Cons, union Aligned_String): Remove.  All uses
replaced by struct Lisp_Cons and struct Lisp_String, since they
are now properly aligned.
(USE_STACK_CONS, USE_STACK_STRING): Simplify now that we can
assume struct Lisp_Cons and struct Lisp_String are properly
aligned.
2017-11-13 10:16:51 -08:00
..
ChangeLog.1 Spelling fixes 2017-10-18 18:43:44 -07:00
COPYING Merge from Gnulib 2017-10-01 18:31:10 -07:00
ctags.c Port ctags+etags build to Sun C 5.12. 2014-05-18 11:57:04 -07:00
ebrowse.c Prefer HTTPS to FTP and HTTP in documentation 2017-09-13 15:54:37 -07:00
emacsclient.c Prefer HTTPS to FTP and HTTP in documentation 2017-09-13 15:54:37 -07:00
etags.c Avoid compilation warnings in optimized builds 2017-10-15 19:20:58 +03:00
hexl.c Prefer HTTPS to FTP and HTTP in documentation 2017-09-13 15:54:37 -07:00
make-docfile.c Use alignas to fix GCALIGN-related bugs 2017-11-13 10:16:51 -08:00
Makefile.in Prefer HTTPS to FTP and HTTP in documentation 2017-09-13 15:54:37 -07:00
movemail.c Prefer HTTPS to FTP and HTTP in documentation 2017-09-13 15:54:37 -07:00
ntlib.c Prefer HTTPS to HTTP for gnu.org 2017-09-29 17:48:22 -07:00
ntlib.h Prefer HTTPS to HTTP for gnu.org 2017-09-29 17:48:22 -07:00
pop.c Prefer HTTPS to FTP and HTTP in documentation 2017-09-13 15:54:37 -07:00
pop.h Prefer HTTPS to FTP and HTTP in documentation 2017-09-13 15:54:37 -07:00
profile.c Prefer HTTPS to FTP and HTTP in documentation 2017-09-13 15:54:37 -07:00
rcs2log Prefer HTTPS to HTTP for gnu.org 2017-10-01 19:59:01 -07:00
README
update-game-score.c Prefer HTTPS to FTP and HTTP in documentation 2017-09-13 15:54:37 -07:00

This directory contains the source code for the architecture-dependent
files that go in ${archlibdir}.  At present, these are mostly utility
programs used by GNU Emacs.