]> code.delx.au - gnu-emacs/commitdiff
Use Gnulib stdalign and environ modules (Bug#9772, Bug#9960).
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 28 Jul 2012 23:05:32 +0000 (16:05 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 28 Jul 2012 23:05:32 +0000 (16:05 -0700)
* .bzrignore: Add lib/stdalign.h.
* config.bat: Do not set NO_DECL_ALIGN; no longer needed.
Copy lib/stdalign.in.h to lib/stdalign.in-h as needed.
* configure.ac (HAVE_ATTRIBUTE_ALIGNED): Remove the code that
fiddles with this, as gnulib now does this for us.
* admin/merge-gnulib: Add environ, stdalign.
* m4/environ.m4: New file, from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* lib/stdalign.in.h, m4/stdalign.m4: New files, from gnulib.
* sed2v2.inp (HAVE_ATTRIBUTE_ALIGNED): Remove edit.
* sedlibmk.inp (STDALIGN_H, @GL_GENERATE_STDALIGN_H_TRUE@)
(GL_GENERATE_STDALIGN_H_FALSE): New edits.
* nt/config.nt (HAVE_ATTRIBUTE_ALIGNED): Remove.
* src/alloc.c (XMALLOC_BASE_ALIGNMENT, GC_POINTER_ALIGNMENT, pure_alloc):
Simplify by using alignof.
(pure_alloc) [! USE_LSB_TAG]: Don't over-align EMACS_INT values.
* src/lisp.h: Include <stdalign.h>.
(GCALIGNMENT): New macro and constant.
(DECL_ALIGN): Remove.  All uses replaced by alignas (GCALIGNMENT).
(USE_LSB_TAG): ifdef on alignas, not on DECL_ALIGN.
(stdalign): New macro, if not already defined.

17 files changed:
ChangeLog
admin/ChangeLog
admin/merge-gnulib
config.bat
configure.ac
lib/gnulib.mk
m4/environ.m4 [new file with mode: 0644]
m4/gnulib-comp.m4
msdos/ChangeLog
msdos/sed2v2.inp
msdos/sedlibmk.inp
nt/ChangeLog
nt/config.nt
src/ChangeLog
src/alloc.c
src/buffer.c
src/lisp.h

index 03f4291a634c64bb53a7a37a72175963fb7d922e..f9546f9e056c70a1b75551bf4b2ab06e7563bca6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2012-07-28  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Use Gnulib environ module (Bug#9772).
+       * m4/environ.m4: New file, from gnulib.
+       * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
+
+       Use Gnulib stdalign module (Bug#9772, Bug#9960).
+       This should improve portability of macros like alignof and DECL_ALIGN.
+       * lib/stdalign.in.h, m4/stdalign.m4: New files, from gnulib.
+       * .bzrignore: Add lib/stdalign.h.
+       * config.bat: Do not set NO_DECL_ALIGN; no longer needed.
+       Copy lib/stdalign.in.h to lib/stdalign.in-h as needed.
+       * configure.ac (HAVE_ATTRIBUTE_ALIGNED): Remove the code that
+       fiddles with this, as gnulib now does this for us.
+
 2012-07-17  Dmitry Antipov  <dmantipov@yandex.ru>
 
        Fix toolkit configuration report.
index b4c88c20ed125f91f5504074d9188b2bcd4d33b2..d97e7dde32d2260fe2d800b116e871771ddce1e8 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-28  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Use Gnulib environ and stdalign modules (Bug#9772, Bug#9960).
+       * merge-gnulib: Add environ, stdalign.
+
 2012-07-20  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * coccinelle/unibyte_string.cocci: Semantic patch to convert from
index 727b701cfe0c429667c905c023985623fd3898de..49d194c8033cd667af4f48ccea83c3ef87cd2b4a 100755 (executable)
@@ -28,11 +28,12 @@ GNULIB_URL=git://git.savannah.gnu.org/gnulib.git
 GNULIB_MODULES='
   alloca-opt c-strcase
   careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512
-  dtoastr dtotimespec dup2
+  dtoastr dtotimespec dup2 environ
   filemode getloadavg getopt-gnu gettime gettimeofday
   ignore-value intprops largefile lstat
   manywarnings mktime pselect pthread_sigmask readlink
-  socklen stat-time stdarg stdio strftime strtoimax strtoumax symlink sys_stat
+  socklen stat-time stdalign stdarg stdio
+  strftime strtoimax strtoumax symlink sys_stat
   sys_time time timespec-add timespec-sub utimens
   warnings
 '
index 4803ad899c1298c7436113550c2c615eb975dcbf..d3443d450d687d99d46b9e97dde12dfc24bf1786 100644 (file)
@@ -161,22 +161,6 @@ if exist config.in sed -f ../msdos/sed2x.inp < config.in > config.tmp
 if exist ..\autogen\config.in sed -f ../msdos/sed2x.inp < ..\autogen\config.in > config.tmp\r
 :src4\r
 sed -f ../msdos/sed2v2.inp <config.tmp >config.h2\r
-Rem See if DECL_ALIGN can be supported with this GCC\r
-rm -f junk.c junk.o junk junk.exe\r
-echo struct { int i; char *p; } __attribute__((__aligned__(8))) foo;  >junk.c\r
-rem Two percent signs because it is a special character for COMMAND.COM/CMD\r
-rem Filter thru Sed because "&" is special for CMD.EXE\r
-echo int main(void) { return (unsigned long)"&"foo %% 8; } | sed "s/.&./\&/"         >>junk.c\r
-gcc -o junk junk.c\r
-if not exist junk.exe coff2exe junk\r
-junk\r
-If Not ErrorLevel 1 Goto alignOk\r
-Echo WARNING: Your GCC does not support 8-byte aligned variables.\r
-Echo WARNING: Therefore Emacs cannot support buffers larger than 128MB.\r
-rem The following line disables DECL_ALIGN which in turn disables USE_LSB_TAG\r
-rem For details see lisp.h where it defines USE_LSB_TAG\r
-echo #define NO_DECL_ALIGN >>config.h2\r
-:alignOk\r
 Rem See if they have libxml2 later than v2.2.0 installed\r
 Echo Checking whether libxml2 v2.2.1 or later is installed ...\r
 rm -f junk.c junk.o junk junk.exe\r
@@ -281,6 +265,7 @@ Rem Rename files like djtar on plain DOS filesystem would.
 If Exist build-aux\snippet\c++defs.h update build-aux/snippet/c++defs.h build-aux/snippet/cxxdefs.h\r
 If Exist alloca.in.h update alloca.in.h alloca.in-h\r
 If Exist getopt.in.h update getopt.in.h getopt.in-h\r
+If Exist stdalign.in.h update stdalign.in.h stdalign.in-h\r
 If Exist stdbool.in.h update stdbool.in.h stdbool.in-h\r
 If Exist signal.in.h update signal.in.h signal.in-h\r
 If Exist stdalign.in.h update stdalign.in.h  stdalign.in-h\r
@@ -346,4 +331,3 @@ set nodebug=
 set djgpp_ver=\r
 set sys_malloc=\r
 set libxml=\r
-\r
index fba98513825e1704cf1948c789601b14bd83a74b..b43087a0aa3d4ead81ea705d0b2e0c15b1a9c47c 100644 (file)
@@ -1298,19 +1298,6 @@ AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr,
 dnl Check for endianness.
 dnl AC_C_BIGENDIAN is done by gnulib.
 
-AC_CACHE_CHECK([for  __attribute__ ((__aligned__ (expr)))],
-  [emacs_cv_attribute_aligned],
-  [AC_COMPILE_IFELSE(
-     [AC_LANG_PROGRAM(
-       [[char __attribute__ ((__aligned__ (1 << 3))) c;]],
-       [[]])],
-     [emacs_cv_attribute_aligned=yes],
-     [emacs_cv_attribute_aligned=no])])
-if test $emacs_cv_attribute_aligned = yes; then
-  AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1,
-    [Define to 1 if GCC-style __attribute__ ((__aligned__ (expr))) works.])
-fi
-
 dnl check for Make feature
 dnl AC_PROG_MAKE_SET is done by Automake.
 
index 6e2bf89786c5349b6ee18b4880de1198a9257b1b..c85b923029ea55a9a731548406407216e56128cb 100644 (file)
@@ -21,7 +21,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat --avoid=msvc-inval --avoid=msvc-nothrow --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-strcase careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdarg stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timespec-add timespec-sub utimens warnings
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat --avoid=msvc-inval --avoid=msvc-nothrow --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-strcase careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdalign stdarg stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timespec-add timespec-sub utimens warnings
 
 
 MOSTLYCLEANFILES += core *.stackdump
diff --git a/m4/environ.m4 b/m4/environ.m4
new file mode 100644 (file)
index 0000000..8eb57c9
--- /dev/null
@@ -0,0 +1,47 @@
+# environ.m4 serial 6
+dnl Copyright (C) 2001-2004, 2006-2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN_ONCE([gl_ENVIRON],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  dnl Persuade glibc <unistd.h> to declare environ.
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  AC_CHECK_HEADERS_ONCE([unistd.h])
+  gt_CHECK_VAR_DECL(
+    [#if HAVE_UNISTD_H
+     #include <unistd.h>
+     #endif
+     /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  */
+     #include <stdlib.h>
+    ],
+    [environ])
+  if test $gt_cv_var_environ_declaration != yes; then
+    HAVE_DECL_ENVIRON=0
+  fi
+])
+
+# Check if a variable is properly declared.
+# gt_CHECK_VAR_DECL(includes,variable)
+AC_DEFUN([gt_CHECK_VAR_DECL],
+[
+  define([gt_cv_var], [gt_cv_var_]$2[_declaration])
+  AC_MSG_CHECKING([if $2 is properly declared])
+  AC_CACHE_VAL([gt_cv_var], [
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+         [[$1
+           extern struct { int foo; } $2;]],
+         [[$2.foo = 1;]])],
+      [gt_cv_var=no],
+      [gt_cv_var=yes])])
+  AC_MSG_RESULT([$gt_cv_var])
+  if test $gt_cv_var = yes; then
+    AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,
+              [Define if you have the declaration of $2.])
+  fi
+  undefine([gt_cv_var])
+])
index 754086ec2e7575dee7250673f68526f9a41b2c39..b0cd185a2b576da50c22c9f2247f9b36475536a0 100644 (file)
@@ -52,6 +52,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module dtoastr:
   # Code from module dtotimespec:
   # Code from module dup2:
+  # Code from module environ:
   # Code from module extensions:
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   # Code from module filemode:
@@ -148,6 +149,8 @@ if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then
   gl_PREREQ_DUP2
 fi
 gl_UNISTD_MODULE_INDICATOR([dup2])
+gl_ENVIRON
+gl_UNISTD_MODULE_INDICATOR([environ])
 gl_FILEMODE
 gl_GETLOADAVG
 if test $HAVE_GETLOADAVG = 0; then
@@ -598,6 +601,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/c-strtod.m4
   m4/clock_time.m4
   m4/dup2.m4
+  m4/environ.m4
   m4/extensions.m4
   m4/filemode.m4
   m4/getloadavg.m4
index 85251afef05e516a72af73fb817121c27a963bda..c5b509c72af7ab43d93795123796ba57cf104f9c 100644 (file)
@@ -1,3 +1,10 @@
+2012-07-28  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Use Gnulib stdalign module (Bug#9772, Bug#9960).
+       * sed2v2.inp (HAVE_ATTRIBUTE_ALIGNED): Remove edit.
+       * sedlibmk.inp (STDALIGN_H, @GL_GENERATE_STDALIGN_H_TRUE@)
+       (GL_GENERATE_STDALIGN_H_FALSE): New edits.
+
 2012-07-14  Eli Zaretskii  <eliz@gnu.org>
 
        * sed1v2.inp: In the recipe for $(leimdir)/leim-list.el, edit the
index 759418f0f1536906ebddd58478d40b7348e8fc16..214480a27abffc1cb37acbd727c7590bc2c1c8dc 100644 (file)
@@ -35,7 +35,6 @@
 /^#undef HAVE_FREXP *$/s/^.*$/#define HAVE_FREXP 1/
 /^#undef HAVE_FMOD *$/s/^.*$/#define HAVE_FMOD 1/
 /^#undef HAVE_RINT *$/s/^.*$/#define HAVE_RINT 1/
-/^#undef HAVE_ATTRIBUTE_ALIGNED *$/s/^.*$/#define HAVE_ATTRIBUTE_ALIGNED 1/
 /^#undef HAVE_C99_STRTOLD *$/s/^.*$/#define HAVE_C99_STRTOLD 1/
 /^#undef HAVE_CBRT *$/s/^.*$/#define HAVE_CBRT 1/
 /^#undef HAVE_DIFFTIME *$/s/^.*$/#define HAVE_DIFFTIME 1/
index 432749af92a3897e9796d60c6f7836b18fa37360..b5b66753bb3b3d1a49d137fe93a3ab403cb8cd55 100644 (file)
@@ -647,6 +647,8 @@ s/^@GL_GENERATE_ALLOCA_H_TRUE@//
 s/^@GL_GENERATE_ALLOCA_H_FALSE@/\#/
 s/^@GL_GENERATE_STDBOOL_H_TRUE@/\#/
 s/^@GL_GENERATE_STDBOOL_H_FALSE@//
+s/^@GL_GENERATE_STDALIGN_H_TRUE@//
+s/^@GL_GENERATE_STDALIGN_H_FALSE@/\#/
 s/^@GL_GENERATE_STDARG_H_TRUE@/\#/
 s/^@GL_GENERATE_STDARG_H_FALSE@/\#/
 s/^@GL_GENERATE_STDDEF_H_TRUE@/\#/
index 16a6577cb6c7dd75ef39e330ae79b0406eccdcd2..f0e9f247d14ab9f199affd70a67d7fc3773994b0 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-28  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Use Gnulib stdalign module (Bug#9772, Bug#9960).
+       * config.nt (HAVE_ATTRIBUTE_ALIGNED): Remove.
+
 2012-07-14  Juanma Barranquero  <lekktu@gmail.com>
 
        * config.nt: Sync with autogen/config.in.
index d727cd3fafd43b6f08456ff226ba4f9dad35e146..d32ead3d9c08cf3ebd868e17b110fa39d6135b01 100644 (file)
@@ -227,9 +227,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 /* Define to 1 if ALSA is available. */
 #undef HAVE_ALSA
 
-/* Define to 1 if GCC-style __attribute__ ((__aligned__ (expr))) works. */
-#undef HAVE_ATTRIBUTE_ALIGNED
-
 /* Define to 1 if strtold conforms to C99. */
 #undef HAVE_C99_STRTOLD
 
index 6457fc2209b4314d9a935dd178d178f0b52fe5df..cc112f4b5dae9a0e431cf9b16518ec51aa62c1a9 100644 (file)
@@ -1,3 +1,15 @@
+2012-07-28  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Use Gnulib stdalign module (Bug#9772, Bug#9960).
+       * alloc.c (XMALLOC_BASE_ALIGNMENT, GC_POINTER_ALIGNMENT, pure_alloc):
+       Simplify by using alignof.
+       (pure_alloc) [! USE_LSB_TAG]: Don't over-align EMACS_INT values.
+       * lisp.h: Include <stdalign.h>.
+       (GCALIGNMENT): New macro and constant.
+       (DECL_ALIGN): Remove.  All uses replaced by alignas (GCALIGNMENT).
+       (USE_LSB_TAG): ifdef on alignas, not on DECL_ALIGN.
+       (stdalign): New macro, if not already defined.
+
 2012-07-28  Eli Zaretskii  <eliz@gnu.org>
 
        Fix non-ASCII input in non-GUI frames on MS-Windows.  (Bug#12055)
index a551dd821b83cbeb47a8f61d1f5ff3874318f1dc..e5f412bb4c334747bdcebed666a54c12df2b0a88 100644 (file)
@@ -533,12 +533,7 @@ buffer_memory_full (ptrdiff_t nbytes)
    hold a size_t value and (2) the header size is a multiple of the
    alignment that Emacs needs for C types and for USE_LSB_TAG.  */
 #define XMALLOC_BASE_ALIGNMENT                         \
-  offsetof (                                           \
-    struct {                                           \
-      union { long double d; intmax_t i; void *p; } u; \
-      char c;                                          \
-    },                                                 \
-    c)
+  alignof (union { long double d; intmax_t i; void *p; })
 
 #if USE_LSB_TAG
 # define XMALLOC_HEADER_ALIGNMENT \
@@ -4652,10 +4647,10 @@ mark_maybe_pointer (void *p)
 }
 
 
-/* Alignment of pointer values.  Use offsetof, as it sometimes returns
+/* Alignment of pointer values.  Use alignof, as it sometimes returns
    a smaller alignment than GCC's __alignof__ and mark_memory might
    miss objects if __alignof__ were used.  */
-#define GC_POINTER_ALIGNMENT offsetof (struct {char a; void *b;}, b)
+#define GC_POINTER_ALIGNMENT alignof (void *)
 
 /* Define POINTERS_MIGHT_HIDE_IN_OBJECTS to 1 if marking via C pointers does
    not suffice, which is the typical case.  A host where a Lisp_Object is
@@ -5103,17 +5098,11 @@ pure_alloc (size_t size, int type)
 #if USE_LSB_TAG
   size_t alignment = (1 << GCTYPEBITS);
 #else
-  size_t alignment = sizeof (EMACS_INT);
+  size_t alignment = alignof (EMACS_INT);
 
   /* Give Lisp_Floats an extra alignment.  */
   if (type == Lisp_Float)
-    {
-#if defined __GNUC__ && __GNUC__ >= 2
-      alignment = __alignof (struct Lisp_Float);
-#else
-      alignment = sizeof (struct Lisp_Float);
-#endif
-    }
+    alignment = alignof (struct Lisp_Float);
 #endif
 
  again:
index 5e45882b8921978ad96aa40f230410d3efbe90bb..70630de53cb97bea0c7981d2e9b21cbb0129f55d 100644 (file)
@@ -56,7 +56,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.  */
 
-DECL_ALIGN (struct buffer, buffer_defaults);
+struct buffer alignas (GCALIGNMENT) buffer_defaults;
 
 /* A Lisp_Object pointer to the above, used for staticpro */
 
@@ -83,7 +83,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. */
 
-DECL_ALIGN (struct buffer, buffer_local_symbols);
+struct buffer alignas (GCALIGNMENT) buffer_local_symbols;
 
 /* A Lisp_Object pointer to the above, used for staticpro */
 static Lisp_Object Vbuffer_local_symbols;
index 80a9ab343c33a2ef27e9b325f5f76b171298f146..a45e9c2c892576c5ff9963ecec4cb2917cec6ae9 100644 (file)
@@ -20,6 +20,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #ifndef EMACS_LISP_H
 #define EMACS_LISP_H
 
+#include <stdalign.h>
 #include <stdarg.h>
 #include <stddef.h>
 #include <inttypes.h>
@@ -151,10 +152,6 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
    on the few static Lisp_Objects used: all the defsubr as well
    as the two special buffers buffer_defaults and buffer_local_symbols.  */
 
-/* First, try and define DECL_ALIGN(type,var) which declares a static
-   variable VAR of type TYPE with the added requirement that it be
-   TYPEBITS-aligned.  */
-
 enum Lisp_Bits
   {
     /* Number of bits in a Lisp_Object tag.  This can be used in #if,
@@ -163,6 +160,12 @@ enum Lisp_Bits
 #define GCTYPEBITS 3
        GCTYPEBITS,
 
+    /* 2**GCTYPEBITS.  This must also be a macro that expands to a
+       literal integer constant, for MSVC.  */
+    GCALIGNMENT =
+#define GCALIGNMENT 8
+       GCALIGNMENT,
+
     /* Number of bits in a Lisp_Object value, not counting the tag.  */
     VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS,
 
@@ -173,36 +176,22 @@ enum Lisp_Bits
     FIXNUM_BITS = VALBITS + 1
   };
 
+#if GCALIGNMENT != 1 << GCTYPEBITS
+# error "GCALIGNMENT and GCTYPEBITS are inconsistent"
+#endif
+
 /* The maximum value that can be stored in a EMACS_INT, assuming all
    bits other than the type bits contribute to a nonnegative signed value.
    This can be used in #if, e.g., '#if VAL_MAX < UINTPTR_MAX' below.  */
 #define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1))
 
-#ifndef NO_DECL_ALIGN
-# ifndef DECL_ALIGN
-#  if HAVE_ATTRIBUTE_ALIGNED
-#   define DECL_ALIGN(type, var) \
-     type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
-#  elif defined(_MSC_VER)
-#   define ALIGN_GCTYPEBITS 8
-#   if (1 << GCTYPEBITS) != ALIGN_GCTYPEBITS
-#    error ALIGN_GCTYPEBITS is wrong!
-#   endif
-#   define DECL_ALIGN(type, var) \
-     type __declspec(align(ALIGN_GCTYPEBITS)) var
-#  else
-     /* What directives do other compilers use?  */
-#  endif
-# endif
-#endif
-
 /* Unless otherwise specified, use USE_LSB_TAG on systems where:  */
 #ifndef USE_LSB_TAG
 /* 1.  We know malloc returns a multiple of 8.  */
 # if (defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ \
       || defined DARWIN_OS || defined __sun)
 /* 2.  We can specify multiple-of-8 alignment on static variables.  */
-#  ifdef DECL_ALIGN
+#  ifdef alignas
 /* 3.  Pointers-as-ints exceed VAL_MAX.
    On hosts where pointers-as-ints do not exceed VAL_MAX, USE_LSB_TAG is:
     a. unnecessary, because the top bits of an EMACS_INT are unused, and
@@ -223,12 +212,11 @@ enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 };
 # define USE_LSB_TAG 0
 #endif
 
-/* If we cannot use 8-byte alignment, make DECL_ALIGN a no-op.  */
-#ifndef DECL_ALIGN
+#ifndef alignas
+# define alignas(alignment) /* empty */
 # if USE_LSB_TAG
-#  error "USE_LSB_TAG used without defining DECL_ALIGN"
+#  error "USE_LSB_TAG requires alignas"
 # endif
-# define DECL_ALIGN(type, var) type var
 #endif
 
 
@@ -1882,7 +1870,7 @@ typedef struct {
 #ifdef _MSC_VER
 #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)    \
    Lisp_Object fnname DEFUN_ARGS_ ## maxargs ;                         \
-   static DECL_ALIGN (struct Lisp_Subr, sname) =                       \
+   static struct Lisp_Subr alignas (GCALIGNMENT) sname =               \
    { (PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS)                             \
      | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)),               \
       { (Lisp_Object (__cdecl *)(void))fnname },                        \
@@ -1891,7 +1879,7 @@ typedef struct {
 #else  /* not _MSC_VER */
 #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)    \
    Lisp_Object fnname DEFUN_ARGS_ ## maxargs ;                         \
-   static DECL_ALIGN (struct Lisp_Subr, sname) =                       \
+   static struct Lisp_Subr alignas (GCALIGNMENT) sname =               \
      { PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS,                            \
       { .a ## maxargs = fnname },                                      \
        minargs, maxargs, lname, intspec, 0};                           \