Permalink
Browse files

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.
  • Loading branch information...
1 parent 3b1d351 commit 2503ea770673b25e3d86ba74573ae2915df1f25d @eggert eggert committed Jul 28, 2012
Showing with 127 additions and 84 deletions.
  1. +1 −0 .bzrignore
  2. +15 −0 ChangeLog
  3. +5 −0 admin/ChangeLog
  4. +3 −2 admin/merge-gnulib
  5. +1 −17 config.bat
  6. +0 −13 configure.ac
  7. +1 −1 lib/gnulib.mk
  8. +47 −0 m4/environ.m4
  9. +4 −0 m4/gnulib-comp.m4
  10. +7 −0 msdos/ChangeLog
  11. +0 −1 msdos/sed2v2.inp
  12. +2 −0 msdos/sedlibmk.inp
  13. +5 −0 nt/ChangeLog
  14. +0 −3 nt/config.nt
  15. +12 −0 src/ChangeLog
  16. +5 −16 src/alloc.c
  17. +2 −2 src/buffer.c
  18. +17 −29 src/lisp.h
View
@@ -86,6 +86,7 @@ lib/arg-nonnull.h
lib/c++defs.h
lib/getopt.h
lib/inttypes.h
+lib/stdalign.h
lib/stdbool.h
lib/stdio.h
lib/stdint.h
View
@@ -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.
View
@@ -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
View
@@ -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
'
View
@@ -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
:src4
sed -f ../msdos/sed2v2.inp <config.tmp >config.h2
-Rem See if DECL_ALIGN can be supported with this GCC
-rm -f junk.c junk.o junk junk.exe
-echo struct { int i; char *p; } __attribute__((__aligned__(8))) foo; >junk.c
-rem Two percent signs because it is a special character for COMMAND.COM/CMD
-rem Filter thru Sed because "&" is special for CMD.EXE
-echo int main(void) { return (unsigned long)"&"foo %% 8; } | sed "s/.&./\&/" >>junk.c
-gcc -o junk junk.c
-if not exist junk.exe coff2exe junk
-junk
-If Not ErrorLevel 1 Goto alignOk
-Echo WARNING: Your GCC does not support 8-byte aligned variables.
-Echo WARNING: Therefore Emacs cannot support buffers larger than 128MB.
-rem The following line disables DECL_ALIGN which in turn disables USE_LSB_TAG
-rem For details see lisp.h where it defines USE_LSB_TAG
-echo #define NO_DECL_ALIGN >>config.h2
-:alignOk
Rem See if they have libxml2 later than v2.2.0 installed
Echo Checking whether libxml2 v2.2.1 or later is installed ...
rm -f junk.c junk.o junk junk.exe
@@ -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
If Exist alloca.in.h update alloca.in.h alloca.in-h
If Exist getopt.in.h update getopt.in.h getopt.in-h
+If Exist stdalign.in.h update stdalign.in.h stdalign.in-h
If Exist stdbool.in.h update stdbool.in.h stdbool.in-h
If Exist signal.in.h update signal.in.h signal.in-h
If Exist stdalign.in.h update stdalign.in.h stdalign.in-h
@@ -346,4 +331,3 @@ set nodebug=
set djgpp_ver=
set sys_malloc=
set libxml=
-
View
@@ -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.
View
@@ -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
View
@@ -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])
+])
View
@@ -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
View
@@ -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
View
@@ -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/
View
@@ -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@/\#/
View
@@ -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.
View
@@ -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
View
@@ -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)
View
@@ -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:
View
@@ -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;
Oops, something went wrong.

0 comments on commit 2503ea7

Please sign in to comment.