]> git.eshelyaron.com Git - emacs.git/commitdiff
Use GCALIGNED properly for GCC
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 9 Nov 2017 03:11:18 +0000 (19:11 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 9 Nov 2017 03:12:02 +0000 (19:12 -0800)
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'.

lib-src/make-docfile.c
src/buffer.c
src/lisp.h
src/thread.c

index 0ea3f7b6b6a9a78b3a7089de5c295cdc7c64e483..ff84df94a69293965a58e3739ffe8f0d5f1354e8 100644 (file)
@@ -668,7 +668,7 @@ close_emacs_globals (ptrdiff_t num_symbols)
           "extern\n"
           "#endif\n"
           "struct {\n"
-          "  struct Lisp_Symbol GCALIGNED s;\n"
+          "  struct GCALIGNED Lisp_Symbol s;\n"
           "} lispsym[%td];\n"),
          num_symbols);
 }
index 15735a298ad456252adb67195166741fdef77a2a..edeed55e8be664b4d89b453cf00fa11b4c9bb264 100644 (file)
@@ -61,7 +61,7 @@ struct buffer *all_buffers;
    Setting the default value also goes through the alist of buffers
    and stores into each buffer that does not say it has a local value.  */
 
-struct buffer GCALIGNED buffer_defaults;
+struct GCALIGNED buffer buffer_defaults;
 
 /* This structure marks which slots in a buffer have corresponding
    default values in buffer_defaults.
@@ -84,7 +84,7 @@ struct buffer buffer_local_flags;
 /* This structure holds the names of symbols whose values may be
    buffer-local.  It is indexed and accessed in the same way as the above.  */
 
-struct buffer GCALIGNED buffer_local_symbols;
+struct GCALIGNED buffer buffer_local_symbols;
 
 /* Return the symbol of the per-buffer variable at offset OFFSET in
    the buffer structure.  */
index 4dd472053bfa416ffea77defb5cef772ea9b14d3..015346858b5dc333f93ee9b242dbb8240d098908 100644 (file)
@@ -277,10 +277,14 @@ DEFINE_GDB_SYMBOL_END (VALMASK)
 error !;
 #endif
 
-/* Declare an object to have an address that is a multiple of
-   GCALIGNMENT.  This is a no-op if the object's natural alignment is
-   already a multiple of GCALIGNMENT.  alignas is not suitable here,
-   as it fails if the object's natural alignment exceeds GCALIGNMENT.  */
+/* Use GCALIGNED immediately after the 'struct' keyword to require the
+   struct to have an address that is a multiple of GCALIGNMENT.  This
+   is a no-op if the struct's natural alignment is already a multiple
+   of GCALIGNMENT.  GCALIGNED's implementation uses the 'aligned'
+   attribute instead of 'alignas (GCALIGNMENT)', as the latter would
+   fail if an object's natural alignment exceeds GCALIGNMENT.  The
+   implementation hopes that natural alignment suffices on platforms
+   lacking 'aligned'.  */
 #ifdef HAVE_STRUCT_ATTRIBUTE_ALIGNED
 # define GCALIGNED __attribute__ ((aligned (GCALIGNMENT)))
 #else
@@ -2944,7 +2948,7 @@ CHECK_NUMBER_CDR (Lisp_Object x)
 #ifdef _MSC_VER
 #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)    \
    Lisp_Object fnname DEFUN_ARGS_ ## maxargs ;                         \
-   static struct Lisp_Subr GCALIGNED sname =                           \
+   static struct GCALIGNED Lisp_Subr sname =                           \
    { { (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS)                           \
        | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)) },           \
       { (Lisp_Object (__cdecl *)(void))fnname },                        \
@@ -2952,7 +2956,7 @@ CHECK_NUMBER_CDR (Lisp_Object x)
    Lisp_Object fnname
 #else  /* not _MSC_VER */
 #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)    \
-   static struct Lisp_Subr GCALIGNED sname =                           \
+   static struct GCALIGNED Lisp_Subr sname =                           \
      { { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS },                                \
        { .a ## maxargs = fnname },                                     \
        minargs, maxargs, lname, intspec, 0};                           \
index 03f5b31855e480e9ace606e968f2e9a39b6598d4..7335833cf94e3eb2f15605ebc781e2bbd080a7d8 100644 (file)
@@ -26,7 +26,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #include "coding.h"
 #include "syssignal.h"
 
-static struct thread_state GCALIGNED main_thread;
+static struct GCALIGNED thread_state main_thread;
 
 struct thread_state *current_thread = &main_thread;