aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2012-07-28 16:05:32 -0700
committerPaul Eggert2012-07-28 16:05:32 -0700
commite32a579975bc219bc24d403deeb1fa89187fc51e (patch)
tree957a729b7f4eb64980359a57828f02d29e6758e7
parent01bd1b0df605d644ae31e8f1f81d926a5d8c7099 (diff)
downloademacs-e32a579975bc219bc24d403deeb1fa89187fc51e.tar.gz
emacs-e32a579975bc219bc24d403deeb1fa89187fc51e.zip
Use Gnulib stdalign and environ modules (Bug#9772, Bug#9960).
* .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.
-rw-r--r--ChangeLog15
-rw-r--r--admin/ChangeLog5
-rwxr-xr-xadmin/merge-gnulib5
-rw-r--r--config.bat18
-rw-r--r--configure.ac13
-rw-r--r--lib/gnulib.mk2
-rw-r--r--m4/environ.m447
-rw-r--r--m4/gnulib-comp.m44
-rw-r--r--msdos/ChangeLog7
-rw-r--r--msdos/sed2v2.inp1
-rw-r--r--msdos/sedlibmk.inp2
-rw-r--r--nt/ChangeLog5
-rw-r--r--nt/config.nt3
-rw-r--r--src/ChangeLog12
-rw-r--r--src/alloc.c21
-rw-r--r--src/buffer.c4
-rw-r--r--src/lisp.h46
17 files changed, 126 insertions, 84 deletions
diff --git a/ChangeLog b/ChangeLog
index 03f4291a634..f9546f9e056 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
12012-07-28 Paul Eggert <eggert@cs.ucla.edu>
2
3 Use Gnulib environ module (Bug#9772).
4 * m4/environ.m4: New file, from gnulib.
5 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
6
7 Use Gnulib stdalign module (Bug#9772, Bug#9960).
8 This should improve portability of macros like alignof and DECL_ALIGN.
9 * lib/stdalign.in.h, m4/stdalign.m4: New files, from gnulib.
10 * .bzrignore: Add lib/stdalign.h.
11 * config.bat: Do not set NO_DECL_ALIGN; no longer needed.
12 Copy lib/stdalign.in.h to lib/stdalign.in-h as needed.
13 * configure.ac (HAVE_ATTRIBUTE_ALIGNED): Remove the code that
14 fiddles with this, as gnulib now does this for us.
15
12012-07-17 Dmitry Antipov <dmantipov@yandex.ru> 162012-07-17 Dmitry Antipov <dmantipov@yandex.ru>
2 17
3 Fix toolkit configuration report. 18 Fix toolkit configuration report.
diff --git a/admin/ChangeLog b/admin/ChangeLog
index b4c88c20ed1..d97e7dde32d 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,8 @@
12012-07-28 Paul Eggert <eggert@cs.ucla.edu>
2
3 Use Gnulib environ and stdalign modules (Bug#9772, Bug#9960).
4 * merge-gnulib: Add environ, stdalign.
5
12012-07-20 Dmitry Antipov <dmantipov@yandex.ru> 62012-07-20 Dmitry Antipov <dmantipov@yandex.ru>
2 7
3 * coccinelle/unibyte_string.cocci: Semantic patch to convert from 8 * coccinelle/unibyte_string.cocci: Semantic patch to convert from
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index 727b701cfe0..49d194c8033 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -28,11 +28,12 @@ GNULIB_URL=git://git.savannah.gnu.org/gnulib.git
28GNULIB_MODULES=' 28GNULIB_MODULES='
29 alloca-opt c-strcase 29 alloca-opt c-strcase
30 careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 30 careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512
31 dtoastr dtotimespec dup2 31 dtoastr dtotimespec dup2 environ
32 filemode getloadavg getopt-gnu gettime gettimeofday 32 filemode getloadavg getopt-gnu gettime gettimeofday
33 ignore-value intprops largefile lstat 33 ignore-value intprops largefile lstat
34 manywarnings mktime pselect pthread_sigmask readlink 34 manywarnings mktime pselect pthread_sigmask readlink
35 socklen stat-time stdarg stdio strftime strtoimax strtoumax symlink sys_stat 35 socklen stat-time stdalign stdarg stdio
36 strftime strtoimax strtoumax symlink sys_stat
36 sys_time time timespec-add timespec-sub utimens 37 sys_time time timespec-add timespec-sub utimens
37 warnings 38 warnings
38' 39'
diff --git a/config.bat b/config.bat
index 4803ad899c1..d3443d450d6 100644
--- a/config.bat
+++ b/config.bat
@@ -161,22 +161,6 @@ if exist config.in sed -f ../msdos/sed2x.inp < config.in > config.tmp
161if exist ..\autogen\config.in sed -f ../msdos/sed2x.inp < ..\autogen\config.in > config.tmp 161if exist ..\autogen\config.in sed -f ../msdos/sed2x.inp < ..\autogen\config.in > config.tmp
162:src4 162:src4
163sed -f ../msdos/sed2v2.inp <config.tmp >config.h2 163sed -f ../msdos/sed2v2.inp <config.tmp >config.h2
164Rem See if DECL_ALIGN can be supported with this GCC
165rm -f junk.c junk.o junk junk.exe
166echo struct { int i; char *p; } __attribute__((__aligned__(8))) foo; >junk.c
167rem Two percent signs because it is a special character for COMMAND.COM/CMD
168rem Filter thru Sed because "&" is special for CMD.EXE
169echo int main(void) { return (unsigned long)"&"foo %% 8; } | sed "s/.&./\&/" >>junk.c
170gcc -o junk junk.c
171if not exist junk.exe coff2exe junk
172junk
173If Not ErrorLevel 1 Goto alignOk
174Echo WARNING: Your GCC does not support 8-byte aligned variables.
175Echo WARNING: Therefore Emacs cannot support buffers larger than 128MB.
176rem The following line disables DECL_ALIGN which in turn disables USE_LSB_TAG
177rem For details see lisp.h where it defines USE_LSB_TAG
178echo #define NO_DECL_ALIGN >>config.h2
179:alignOk
180Rem See if they have libxml2 later than v2.2.0 installed 164Rem See if they have libxml2 later than v2.2.0 installed
181Echo Checking whether libxml2 v2.2.1 or later is installed ... 165Echo Checking whether libxml2 v2.2.1 or later is installed ...
182rm -f junk.c junk.o junk junk.exe 166rm -f junk.c junk.o junk junk.exe
@@ -281,6 +265,7 @@ Rem Rename files like djtar on plain DOS filesystem would.
281If Exist build-aux\snippet\c++defs.h update build-aux/snippet/c++defs.h build-aux/snippet/cxxdefs.h 265If Exist build-aux\snippet\c++defs.h update build-aux/snippet/c++defs.h build-aux/snippet/cxxdefs.h
282If Exist alloca.in.h update alloca.in.h alloca.in-h 266If Exist alloca.in.h update alloca.in.h alloca.in-h
283If Exist getopt.in.h update getopt.in.h getopt.in-h 267If Exist getopt.in.h update getopt.in.h getopt.in-h
268If Exist stdalign.in.h update stdalign.in.h stdalign.in-h
284If Exist stdbool.in.h update stdbool.in.h stdbool.in-h 269If Exist stdbool.in.h update stdbool.in.h stdbool.in-h
285If Exist signal.in.h update signal.in.h signal.in-h 270If Exist signal.in.h update signal.in.h signal.in-h
286If Exist stdalign.in.h update stdalign.in.h stdalign.in-h 271If Exist stdalign.in.h update stdalign.in.h stdalign.in-h
@@ -346,4 +331,3 @@ set nodebug=
346set djgpp_ver= 331set djgpp_ver=
347set sys_malloc= 332set sys_malloc=
348set libxml= 333set libxml=
349
diff --git a/configure.ac b/configure.ac
index fba98513825..b43087a0aa3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1298,19 +1298,6 @@ AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr,
1298dnl Check for endianness. 1298dnl Check for endianness.
1299dnl AC_C_BIGENDIAN is done by gnulib. 1299dnl AC_C_BIGENDIAN is done by gnulib.
1300 1300
1301AC_CACHE_CHECK([for __attribute__ ((__aligned__ (expr)))],
1302 [emacs_cv_attribute_aligned],
1303 [AC_COMPILE_IFELSE(
1304 [AC_LANG_PROGRAM(
1305 [[char __attribute__ ((__aligned__ (1 << 3))) c;]],
1306 [[]])],
1307 [emacs_cv_attribute_aligned=yes],
1308 [emacs_cv_attribute_aligned=no])])
1309if test $emacs_cv_attribute_aligned = yes; then
1310 AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1,
1311 [Define to 1 if GCC-style __attribute__ ((__aligned__ (expr))) works.])
1312fi
1313
1314dnl check for Make feature 1301dnl check for Make feature
1315dnl AC_PROG_MAKE_SET is done by Automake. 1302dnl AC_PROG_MAKE_SET is done by Automake.
1316 1303
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 6e2bf89786c..c85b923029e 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -21,7 +21,7 @@
21# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
22# 22#
23# Generated by gnulib-tool. 23# Generated by gnulib-tool.
24# 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 24# 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
25 25
26 26
27MOSTLYCLEANFILES += core *.stackdump 27MOSTLYCLEANFILES += core *.stackdump
diff --git a/m4/environ.m4 b/m4/environ.m4
new file mode 100644
index 00000000000..8eb57c9d999
--- /dev/null
+++ b/m4/environ.m4
@@ -0,0 +1,47 @@
1# environ.m4 serial 6
2dnl Copyright (C) 2001-2004, 2006-2012 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN_ONCE([gl_ENVIRON],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 dnl Persuade glibc <unistd.h> to declare environ.
11 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
12
13 AC_CHECK_HEADERS_ONCE([unistd.h])
14 gt_CHECK_VAR_DECL(
15 [#if HAVE_UNISTD_H
16 #include <unistd.h>
17 #endif
18 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
19 #include <stdlib.h>
20 ],
21 [environ])
22 if test $gt_cv_var_environ_declaration != yes; then
23 HAVE_DECL_ENVIRON=0
24 fi
25])
26
27# Check if a variable is properly declared.
28# gt_CHECK_VAR_DECL(includes,variable)
29AC_DEFUN([gt_CHECK_VAR_DECL],
30[
31 define([gt_cv_var], [gt_cv_var_]$2[_declaration])
32 AC_MSG_CHECKING([if $2 is properly declared])
33 AC_CACHE_VAL([gt_cv_var], [
34 AC_COMPILE_IFELSE(
35 [AC_LANG_PROGRAM(
36 [[$1
37 extern struct { int foo; } $2;]],
38 [[$2.foo = 1;]])],
39 [gt_cv_var=no],
40 [gt_cv_var=yes])])
41 AC_MSG_RESULT([$gt_cv_var])
42 if test $gt_cv_var = yes; then
43 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,
44 [Define if you have the declaration of $2.])
45 fi
46 undefine([gt_cv_var])
47])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 754086ec2e7..b0cd185a2b5 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -52,6 +52,7 @@ AC_DEFUN([gl_EARLY],
52 # Code from module dtoastr: 52 # Code from module dtoastr:
53 # Code from module dtotimespec: 53 # Code from module dtotimespec:
54 # Code from module dup2: 54 # Code from module dup2:
55 # Code from module environ:
55 # Code from module extensions: 56 # Code from module extensions:
56 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 57 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
57 # Code from module filemode: 58 # Code from module filemode:
@@ -148,6 +149,8 @@ if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then
148 gl_PREREQ_DUP2 149 gl_PREREQ_DUP2
149fi 150fi
150gl_UNISTD_MODULE_INDICATOR([dup2]) 151gl_UNISTD_MODULE_INDICATOR([dup2])
152gl_ENVIRON
153gl_UNISTD_MODULE_INDICATOR([environ])
151gl_FILEMODE 154gl_FILEMODE
152gl_GETLOADAVG 155gl_GETLOADAVG
153if test $HAVE_GETLOADAVG = 0; then 156if test $HAVE_GETLOADAVG = 0; then
@@ -598,6 +601,7 @@ AC_DEFUN([gl_FILE_LIST], [
598 m4/c-strtod.m4 601 m4/c-strtod.m4
599 m4/clock_time.m4 602 m4/clock_time.m4
600 m4/dup2.m4 603 m4/dup2.m4
604 m4/environ.m4
601 m4/extensions.m4 605 m4/extensions.m4
602 m4/filemode.m4 606 m4/filemode.m4
603 m4/getloadavg.m4 607 m4/getloadavg.m4
diff --git a/msdos/ChangeLog b/msdos/ChangeLog
index 85251afef05..c5b509c72af 100644
--- a/msdos/ChangeLog
+++ b/msdos/ChangeLog
@@ -1,3 +1,10 @@
12012-07-28 Paul Eggert <eggert@cs.ucla.edu>
2
3 Use Gnulib stdalign module (Bug#9772, Bug#9960).
4 * sed2v2.inp (HAVE_ATTRIBUTE_ALIGNED): Remove edit.
5 * sedlibmk.inp (STDALIGN_H, @GL_GENERATE_STDALIGN_H_TRUE@)
6 (GL_GENERATE_STDALIGN_H_FALSE): New edits.
7
12012-07-14 Eli Zaretskii <eliz@gnu.org> 82012-07-14 Eli Zaretskii <eliz@gnu.org>
2 9
3 * sed1v2.inp: In the recipe for $(leimdir)/leim-list.el, edit the 10 * sed1v2.inp: In the recipe for $(leimdir)/leim-list.el, edit the
diff --git a/msdos/sed2v2.inp b/msdos/sed2v2.inp
index 759418f0f15..214480a27ab 100644
--- a/msdos/sed2v2.inp
+++ b/msdos/sed2v2.inp
@@ -35,7 +35,6 @@
35/^#undef HAVE_FREXP *$/s/^.*$/#define HAVE_FREXP 1/ 35/^#undef HAVE_FREXP *$/s/^.*$/#define HAVE_FREXP 1/
36/^#undef HAVE_FMOD *$/s/^.*$/#define HAVE_FMOD 1/ 36/^#undef HAVE_FMOD *$/s/^.*$/#define HAVE_FMOD 1/
37/^#undef HAVE_RINT *$/s/^.*$/#define HAVE_RINT 1/ 37/^#undef HAVE_RINT *$/s/^.*$/#define HAVE_RINT 1/
38/^#undef HAVE_ATTRIBUTE_ALIGNED *$/s/^.*$/#define HAVE_ATTRIBUTE_ALIGNED 1/
39/^#undef HAVE_C99_STRTOLD *$/s/^.*$/#define HAVE_C99_STRTOLD 1/ 38/^#undef HAVE_C99_STRTOLD *$/s/^.*$/#define HAVE_C99_STRTOLD 1/
40/^#undef HAVE_CBRT *$/s/^.*$/#define HAVE_CBRT 1/ 39/^#undef HAVE_CBRT *$/s/^.*$/#define HAVE_CBRT 1/
41/^#undef HAVE_DIFFTIME *$/s/^.*$/#define HAVE_DIFFTIME 1/ 40/^#undef HAVE_DIFFTIME *$/s/^.*$/#define HAVE_DIFFTIME 1/
diff --git a/msdos/sedlibmk.inp b/msdos/sedlibmk.inp
index 432749af92a..b5b66753bb3 100644
--- a/msdos/sedlibmk.inp
+++ b/msdos/sedlibmk.inp
@@ -647,6 +647,8 @@ s/^@GL_GENERATE_ALLOCA_H_TRUE@//
647s/^@GL_GENERATE_ALLOCA_H_FALSE@/\#/ 647s/^@GL_GENERATE_ALLOCA_H_FALSE@/\#/
648s/^@GL_GENERATE_STDBOOL_H_TRUE@/\#/ 648s/^@GL_GENERATE_STDBOOL_H_TRUE@/\#/
649s/^@GL_GENERATE_STDBOOL_H_FALSE@// 649s/^@GL_GENERATE_STDBOOL_H_FALSE@//
650s/^@GL_GENERATE_STDALIGN_H_TRUE@//
651s/^@GL_GENERATE_STDALIGN_H_FALSE@/\#/
650s/^@GL_GENERATE_STDARG_H_TRUE@/\#/ 652s/^@GL_GENERATE_STDARG_H_TRUE@/\#/
651s/^@GL_GENERATE_STDARG_H_FALSE@/\#/ 653s/^@GL_GENERATE_STDARG_H_FALSE@/\#/
652s/^@GL_GENERATE_STDDEF_H_TRUE@/\#/ 654s/^@GL_GENERATE_STDDEF_H_TRUE@/\#/
diff --git a/nt/ChangeLog b/nt/ChangeLog
index 16a6577cb6c..f0e9f247d14 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,3 +1,8 @@
12012-07-28 Paul Eggert <eggert@cs.ucla.edu>
2
3 Use Gnulib stdalign module (Bug#9772, Bug#9960).
4 * config.nt (HAVE_ATTRIBUTE_ALIGNED): Remove.
5
12012-07-14 Juanma Barranquero <lekktu@gmail.com> 62012-07-14 Juanma Barranquero <lekktu@gmail.com>
2 7
3 * config.nt: Sync with autogen/config.in. 8 * config.nt: Sync with autogen/config.in.
diff --git a/nt/config.nt b/nt/config.nt
index d727cd3fafd..d32ead3d9c0 100644
--- a/nt/config.nt
+++ b/nt/config.nt
@@ -227,9 +227,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
227/* Define to 1 if ALSA is available. */ 227/* Define to 1 if ALSA is available. */
228#undef HAVE_ALSA 228#undef HAVE_ALSA
229 229
230/* Define to 1 if GCC-style __attribute__ ((__aligned__ (expr))) works. */
231#undef HAVE_ATTRIBUTE_ALIGNED
232
233/* Define to 1 if strtold conforms to C99. */ 230/* Define to 1 if strtold conforms to C99. */
234#undef HAVE_C99_STRTOLD 231#undef HAVE_C99_STRTOLD
235 232
diff --git a/src/ChangeLog b/src/ChangeLog
index 6457fc2209b..cc112f4b5da 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
12012-07-28 Paul Eggert <eggert@cs.ucla.edu>
2
3 Use Gnulib stdalign module (Bug#9772, Bug#9960).
4 * alloc.c (XMALLOC_BASE_ALIGNMENT, GC_POINTER_ALIGNMENT, pure_alloc):
5 Simplify by using alignof.
6 (pure_alloc) [! USE_LSB_TAG]: Don't over-align EMACS_INT values.
7 * lisp.h: Include <stdalign.h>.
8 (GCALIGNMENT): New macro and constant.
9 (DECL_ALIGN): Remove. All uses replaced by alignas (GCALIGNMENT).
10 (USE_LSB_TAG): ifdef on alignas, not on DECL_ALIGN.
11 (stdalign): New macro, if not already defined.
12
12012-07-28 Eli Zaretskii <eliz@gnu.org> 132012-07-28 Eli Zaretskii <eliz@gnu.org>
2 14
3 Fix non-ASCII input in non-GUI frames on MS-Windows. (Bug#12055) 15 Fix non-ASCII input in non-GUI frames on MS-Windows. (Bug#12055)
diff --git a/src/alloc.c b/src/alloc.c
index a551dd821b8..e5f412bb4c3 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -533,12 +533,7 @@ buffer_memory_full (ptrdiff_t nbytes)
533 hold a size_t value and (2) the header size is a multiple of the 533 hold a size_t value and (2) the header size is a multiple of the
534 alignment that Emacs needs for C types and for USE_LSB_TAG. */ 534 alignment that Emacs needs for C types and for USE_LSB_TAG. */
535#define XMALLOC_BASE_ALIGNMENT \ 535#define XMALLOC_BASE_ALIGNMENT \
536 offsetof ( \ 536 alignof (union { long double d; intmax_t i; void *p; })
537 struct { \
538 union { long double d; intmax_t i; void *p; } u; \
539 char c; \
540 }, \
541 c)
542 537
543#if USE_LSB_TAG 538#if USE_LSB_TAG
544# define XMALLOC_HEADER_ALIGNMENT \ 539# define XMALLOC_HEADER_ALIGNMENT \
@@ -4652,10 +4647,10 @@ mark_maybe_pointer (void *p)
4652} 4647}
4653 4648
4654 4649
4655/* Alignment of pointer values. Use offsetof, as it sometimes returns 4650/* Alignment of pointer values. Use alignof, as it sometimes returns
4656 a smaller alignment than GCC's __alignof__ and mark_memory might 4651 a smaller alignment than GCC's __alignof__ and mark_memory might
4657 miss objects if __alignof__ were used. */ 4652 miss objects if __alignof__ were used. */
4658#define GC_POINTER_ALIGNMENT offsetof (struct {char a; void *b;}, b) 4653#define GC_POINTER_ALIGNMENT alignof (void *)
4659 4654
4660/* Define POINTERS_MIGHT_HIDE_IN_OBJECTS to 1 if marking via C pointers does 4655/* Define POINTERS_MIGHT_HIDE_IN_OBJECTS to 1 if marking via C pointers does
4661 not suffice, which is the typical case. A host where a Lisp_Object is 4656 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)
5103#if USE_LSB_TAG 5098#if USE_LSB_TAG
5104 size_t alignment = (1 << GCTYPEBITS); 5099 size_t alignment = (1 << GCTYPEBITS);
5105#else 5100#else
5106 size_t alignment = sizeof (EMACS_INT); 5101 size_t alignment = alignof (EMACS_INT);
5107 5102
5108 /* Give Lisp_Floats an extra alignment. */ 5103 /* Give Lisp_Floats an extra alignment. */
5109 if (type == Lisp_Float) 5104 if (type == Lisp_Float)
5110 { 5105 alignment = alignof (struct Lisp_Float);
5111#if defined __GNUC__ && __GNUC__ >= 2
5112 alignment = __alignof (struct Lisp_Float);
5113#else
5114 alignment = sizeof (struct Lisp_Float);
5115#endif
5116 }
5117#endif 5106#endif
5118 5107
5119 again: 5108 again:
diff --git a/src/buffer.c b/src/buffer.c
index 5e45882b892..70630de53cb 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -56,7 +56,7 @@ struct buffer *all_buffers;
56 Setting the default value also goes through the alist of buffers 56 Setting the default value also goes through the alist of buffers
57 and stores into each buffer that does not say it has a local value. */ 57 and stores into each buffer that does not say it has a local value. */
58 58
59DECL_ALIGN (struct buffer, buffer_defaults); 59struct buffer alignas (GCALIGNMENT) buffer_defaults;
60 60
61/* A Lisp_Object pointer to the above, used for staticpro */ 61/* A Lisp_Object pointer to the above, used for staticpro */
62 62
@@ -83,7 +83,7 @@ struct buffer buffer_local_flags;
83/* This structure holds the names of symbols whose values may be 83/* This structure holds the names of symbols whose values may be
84 buffer-local. It is indexed and accessed in the same way as the above. */ 84 buffer-local. It is indexed and accessed in the same way as the above. */
85 85
86DECL_ALIGN (struct buffer, buffer_local_symbols); 86struct buffer alignas (GCALIGNMENT) buffer_local_symbols;
87 87
88/* A Lisp_Object pointer to the above, used for staticpro */ 88/* A Lisp_Object pointer to the above, used for staticpro */
89static Lisp_Object Vbuffer_local_symbols; 89static Lisp_Object Vbuffer_local_symbols;
diff --git a/src/lisp.h b/src/lisp.h
index 80a9ab343c3..a45e9c2c892 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20#ifndef EMACS_LISP_H 20#ifndef EMACS_LISP_H
21#define EMACS_LISP_H 21#define EMACS_LISP_H
22 22
23#include <stdalign.h>
23#include <stdarg.h> 24#include <stdarg.h>
24#include <stddef.h> 25#include <stddef.h>
25#include <inttypes.h> 26#include <inttypes.h>
@@ -151,10 +152,6 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
151 on the few static Lisp_Objects used: all the defsubr as well 152 on the few static Lisp_Objects used: all the defsubr as well
152 as the two special buffers buffer_defaults and buffer_local_symbols. */ 153 as the two special buffers buffer_defaults and buffer_local_symbols. */
153 154
154/* First, try and define DECL_ALIGN(type,var) which declares a static
155 variable VAR of type TYPE with the added requirement that it be
156 TYPEBITS-aligned. */
157
158enum Lisp_Bits 155enum Lisp_Bits
159 { 156 {
160 /* Number of bits in a Lisp_Object tag. This can be used in #if, 157 /* Number of bits in a Lisp_Object tag. This can be used in #if,
@@ -163,6 +160,12 @@ enum Lisp_Bits
163#define GCTYPEBITS 3 160#define GCTYPEBITS 3
164 GCTYPEBITS, 161 GCTYPEBITS,
165 162
163 /* 2**GCTYPEBITS. This must also be a macro that expands to a
164 literal integer constant, for MSVC. */
165 GCALIGNMENT =
166#define GCALIGNMENT 8
167 GCALIGNMENT,
168
166 /* Number of bits in a Lisp_Object value, not counting the tag. */ 169 /* Number of bits in a Lisp_Object value, not counting the tag. */
167 VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS, 170 VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS,
168 171
@@ -173,36 +176,22 @@ enum Lisp_Bits
173 FIXNUM_BITS = VALBITS + 1 176 FIXNUM_BITS = VALBITS + 1
174 }; 177 };
175 178
179#if GCALIGNMENT != 1 << GCTYPEBITS
180# error "GCALIGNMENT and GCTYPEBITS are inconsistent"
181#endif
182
176/* The maximum value that can be stored in a EMACS_INT, assuming all 183/* The maximum value that can be stored in a EMACS_INT, assuming all
177 bits other than the type bits contribute to a nonnegative signed value. 184 bits other than the type bits contribute to a nonnegative signed value.
178 This can be used in #if, e.g., '#if VAL_MAX < UINTPTR_MAX' below. */ 185 This can be used in #if, e.g., '#if VAL_MAX < UINTPTR_MAX' below. */
179#define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1)) 186#define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1))
180 187
181#ifndef NO_DECL_ALIGN
182# ifndef DECL_ALIGN
183# if HAVE_ATTRIBUTE_ALIGNED
184# define DECL_ALIGN(type, var) \
185 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
186# elif defined(_MSC_VER)
187# define ALIGN_GCTYPEBITS 8
188# if (1 << GCTYPEBITS) != ALIGN_GCTYPEBITS
189# error ALIGN_GCTYPEBITS is wrong!
190# endif
191# define DECL_ALIGN(type, var) \
192 type __declspec(align(ALIGN_GCTYPEBITS)) var
193# else
194 /* What directives do other compilers use? */
195# endif
196# endif
197#endif
198
199/* Unless otherwise specified, use USE_LSB_TAG on systems where: */ 188/* Unless otherwise specified, use USE_LSB_TAG on systems where: */
200#ifndef USE_LSB_TAG 189#ifndef USE_LSB_TAG
201/* 1. We know malloc returns a multiple of 8. */ 190/* 1. We know malloc returns a multiple of 8. */
202# if (defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ \ 191# if (defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ \
203 || defined DARWIN_OS || defined __sun) 192 || defined DARWIN_OS || defined __sun)
204/* 2. We can specify multiple-of-8 alignment on static variables. */ 193/* 2. We can specify multiple-of-8 alignment on static variables. */
205# ifdef DECL_ALIGN 194# ifdef alignas
206/* 3. Pointers-as-ints exceed VAL_MAX. 195/* 3. Pointers-as-ints exceed VAL_MAX.
207 On hosts where pointers-as-ints do not exceed VAL_MAX, USE_LSB_TAG is: 196 On hosts where pointers-as-ints do not exceed VAL_MAX, USE_LSB_TAG is:
208 a. unnecessary, because the top bits of an EMACS_INT are unused, and 197 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 };
223# define USE_LSB_TAG 0 212# define USE_LSB_TAG 0
224#endif 213#endif
225 214
226/* If we cannot use 8-byte alignment, make DECL_ALIGN a no-op. */ 215#ifndef alignas
227#ifndef DECL_ALIGN 216# define alignas(alignment) /* empty */
228# if USE_LSB_TAG 217# if USE_LSB_TAG
229# error "USE_LSB_TAG used without defining DECL_ALIGN" 218# error "USE_LSB_TAG requires alignas"
230# endif 219# endif
231# define DECL_ALIGN(type, var) type var
232#endif 220#endif
233 221
234 222
@@ -1882,7 +1870,7 @@ typedef struct {
1882#ifdef _MSC_VER 1870#ifdef _MSC_VER
1883#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 1871#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1884 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 1872 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1885 static DECL_ALIGN (struct Lisp_Subr, sname) = \ 1873 static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
1886 { (PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS) \ 1874 { (PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS) \
1887 | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \ 1875 | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \
1888 { (Lisp_Object (__cdecl *)(void))fnname }, \ 1876 { (Lisp_Object (__cdecl *)(void))fnname }, \
@@ -1891,7 +1879,7 @@ typedef struct {
1891#else /* not _MSC_VER */ 1879#else /* not _MSC_VER */
1892#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 1880#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1893 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 1881 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1894 static DECL_ALIGN (struct Lisp_Subr, sname) = \ 1882 static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
1895 { PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS, \ 1883 { PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS, \
1896 { .a ## maxargs = fnname }, \ 1884 { .a ## maxargs = fnname }, \
1897 minargs, maxargs, lname, intspec, 0}; \ 1885 minargs, maxargs, lname, intspec, 0}; \