aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2017-11-08 19:11:18 -0800
committerPaul Eggert2017-11-08 19:12:02 -0800
commit9e59de9449b53c3ecd85b624c11360ba9cafee75 (patch)
tree6a5f27fb3679aefe1cf69e4ce070ef99cdebf7fa /src
parentb9d7c902603a49d2624bdd35efdfba1785a4bce5 (diff)
downloademacs-9e59de9449b53c3ecd85b624c11360ba9cafee75.tar.gz
emacs-9e59de9449b53c3ecd85b624c11360ba9cafee75.zip
Use GCALIGNED properly for GCC
Apparently GCC requires that ‘__attribute__ ((aligned (8)))’ must immediately follow the ‘struct’ keyword when aligning a structure. The attribute silently does not work if it follows a tag after the ‘struct’ keyword. Who knew? Anyway, this patch is designed to fix a SIGSEGV problem reported by John Mastro (Bug#29183). * lib-src/make-docfile.c (close_emacs_globals): * src/buffer.c (buffer_defaults, buffer_local_symbols): * src/lisp.h (DEFUN): * src/thread.c (main_thread): Put 'GCALIGNED' immediately after 'struct'.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c4
-rw-r--r--src/lisp.h16
-rw-r--r--src/thread.c2
3 files changed, 13 insertions, 9 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 15735a298ad..edeed55e8be 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -61,7 +61,7 @@ struct buffer *all_buffers;
61 Setting the default value also goes through the alist of buffers 61 Setting the default value also goes through the alist of buffers
62 and stores into each buffer that does not say it has a local value. */ 62 and stores into each buffer that does not say it has a local value. */
63 63
64struct buffer GCALIGNED buffer_defaults; 64struct GCALIGNED buffer buffer_defaults;
65 65
66/* This structure marks which slots in a buffer have corresponding 66/* This structure marks which slots in a buffer have corresponding
67 default values in buffer_defaults. 67 default values in buffer_defaults.
@@ -84,7 +84,7 @@ struct buffer buffer_local_flags;
84/* This structure holds the names of symbols whose values may be 84/* This structure holds the names of symbols whose values may be
85 buffer-local. It is indexed and accessed in the same way as the above. */ 85 buffer-local. It is indexed and accessed in the same way as the above. */
86 86
87struct buffer GCALIGNED buffer_local_symbols; 87struct GCALIGNED buffer buffer_local_symbols;
88 88
89/* Return the symbol of the per-buffer variable at offset OFFSET in 89/* Return the symbol of the per-buffer variable at offset OFFSET in
90 the buffer structure. */ 90 the buffer structure. */
diff --git a/src/lisp.h b/src/lisp.h
index 4dd472053bf..015346858b5 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -277,10 +277,14 @@ DEFINE_GDB_SYMBOL_END (VALMASK)
277error !; 277error !;
278#endif 278#endif
279 279
280/* Declare an object to have an address that is a multiple of 280/* Use GCALIGNED immediately after the 'struct' keyword to require the
281 GCALIGNMENT. This is a no-op if the object's natural alignment is 281 struct to have an address that is a multiple of GCALIGNMENT. This
282 already a multiple of GCALIGNMENT. alignas is not suitable here, 282 is a no-op if the struct's natural alignment is already a multiple
283 as it fails if the object's natural alignment exceeds GCALIGNMENT. */ 283 of GCALIGNMENT. GCALIGNED's implementation uses the 'aligned'
284 attribute instead of 'alignas (GCALIGNMENT)', as the latter would
285 fail if an object's natural alignment exceeds GCALIGNMENT. The
286 implementation hopes that natural alignment suffices on platforms
287 lacking 'aligned'. */
284#ifdef HAVE_STRUCT_ATTRIBUTE_ALIGNED 288#ifdef HAVE_STRUCT_ATTRIBUTE_ALIGNED
285# define GCALIGNED __attribute__ ((aligned (GCALIGNMENT))) 289# define GCALIGNED __attribute__ ((aligned (GCALIGNMENT)))
286#else 290#else
@@ -2944,7 +2948,7 @@ CHECK_NUMBER_CDR (Lisp_Object x)
2944#ifdef _MSC_VER 2948#ifdef _MSC_VER
2945#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 2949#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
2946 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 2950 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
2947 static struct Lisp_Subr GCALIGNED sname = \ 2951 static struct GCALIGNED Lisp_Subr sname = \
2948 { { (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) \ 2952 { { (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) \
2949 | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)) }, \ 2953 | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)) }, \
2950 { (Lisp_Object (__cdecl *)(void))fnname }, \ 2954 { (Lisp_Object (__cdecl *)(void))fnname }, \
@@ -2952,7 +2956,7 @@ CHECK_NUMBER_CDR (Lisp_Object x)
2952 Lisp_Object fnname 2956 Lisp_Object fnname
2953#else /* not _MSC_VER */ 2957#else /* not _MSC_VER */
2954#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 2958#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
2955 static struct Lisp_Subr GCALIGNED sname = \ 2959 static struct GCALIGNED Lisp_Subr sname = \
2956 { { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ 2960 { { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \
2957 { .a ## maxargs = fnname }, \ 2961 { .a ## maxargs = fnname }, \
2958 minargs, maxargs, lname, intspec, 0}; \ 2962 minargs, maxargs, lname, intspec, 0}; \
diff --git a/src/thread.c b/src/thread.c
index 03f5b31855e..7335833cf94 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -26,7 +26,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
26#include "coding.h" 26#include "coding.h"
27#include "syssignal.h" 27#include "syssignal.h"
28 28
29static struct thread_state GCALIGNED main_thread; 29static struct GCALIGNED thread_state main_thread;
30 30
31struct thread_state *current_thread = &main_thread; 31struct thread_state *current_thread = &main_thread;
32 32