* bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC @ 2011-10-17 3:24 Paul Eggert 2011-10-17 4:04 ` Eli Zaretskii ` (3 more replies) 0 siblings, 4 replies; 10+ messages in thread From: Paul Eggert @ 2011-10-17 3:24 UTC (permalink / raw) To: 9772 Package: Emacs Version: 24.0.90 Tags: patch Here's a patch to the Emacs trunk (bzr 106094) to cause it to use <stdalign.h> if available, falling back on a Gnulib replacement otherwise. This simplifies Emacs proper, and should future-proof it for C1X compilers. Although this patch is mostly just a cleanup patch for GNU and POSIX platforms, it may improve performance on some Microsoft hosts, as it contains code for supporting <stdalign.h> under MSVC. As far as I can see, USE_LSB_TAG currently doesn't work with MSVC, so if this patch works it should increase the maximum Emacs buffer size in that environment. I haven't tested it under Windows, though, and quite possibly further work will be needed in that area. Since this is Microsoft-build relevant, I'll CC: this bug report to Eli. === modified file '.bzrignore' --- .bzrignore 2011-09-29 14:19:11 +0000 +++ .bzrignore 2011-10-17 01:22:19 +0000 @@ -53,6 +53,7 @@ lib/c++defs.h lib/getopt.h lib/inttypes.h +lib/stdalign.h lib/stdbool.h lib/stdio.h lib/stdint.h === modified file 'ChangeLog' --- ChangeLog 2011-10-13 02:16:59 +0000 +++ ChangeLog 2011-10-17 01:22:19 +0000 @@ -1,3 +1,18 @@ +2011-10-17 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module. + 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. + * Makefile.in (GNULIB_MODULES): Add stdalign. + * config.bat: Set HAVE_ATTRIBUTE_ALIGNED in lib/stdalign.h, + instead of NO_DECL_ALIGN in config.h. Copy lib/stdalign.in.h to + lib/stdalign.in-h as needed. + * configure.in (HAVE_ATTRIBUTE_ALIGNED): Remove the code that + fiddles with this, as gnulib now does this for us. + * lib/gnulib.mk, lib/md5.c, lib/sha1.c, lib/sha256.c, lib/sha512.c: + * m4/gl-comp.m4, m4/pthread_sigmask.m4: Merge from gnulib. + 2011-10-13 Glenn Morris <rgm@gnu.org> * configure.in: Also look for tputs in libcurses. (Bug#9736) === modified file 'Makefile.in' --- Makefile.in 2011-09-26 21:30:18 +0000 +++ Makefile.in 2011-10-17 01:22:19 +0000 @@ -337,7 +337,7 @@ dup2 \ filemode getloadavg getopt-gnu ignore-value intprops lstat \ mktime pthread_sigmask readlink \ - socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat + socklen stdalign stdarg stdio strftime strtoimax strtoumax symlink sys_stat GNULIB_TOOL_FLAGS = \ --avoid=msvc-inval --avoid=msvc-nothrow --avoid=pathmax \ --avoid=raise --avoid=threadlib \ === modified file 'config.bat' --- config.bat 2011-09-29 12:08:36 +0000 +++ config.bat 2011-10-17 01:22:19 +0000 @@ -161,7 +161,8 @@ 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 +Rem See if alignas can be supported with this GCC +set HAVE_ATTRIBUTE_ALIGNED=1 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 @@ -173,9 +174,9 @@ 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 The following line disables alignas 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 +set HAVE_ATTRIBUTE_ALIGNED=0 :alignOk Rem See if they have libxml2 later than v2.2.0 installed Echo Checking whether libxml2 v2.2.1 or later is installed ... @@ -281,6 +282,7 @@ 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 stddef.in.h update stddef.in.h stddef.in-h @@ -290,7 +292,7 @@ If Exist sys_stat.in.h update sys_stat.in.h sys_stat.in-h If Exist time.in.h update time.in.h time.in-h If Exist unistd.in.h update unistd.in.h unistd.in-h -sed -f ../msdos/sedlibcf.inp < ..\autogen\Makefile.in > makefile.tmp +sed -e "s/@HAVE_ATTRIBUTE_ALIGNED@/%HAVE_ATTRIBUTE_ALIGNED%/g" -f ../msdos/sedlibcf.inp < ..\autogen\Makefile.in > makefile.tmp sed -f ../msdos/sedlibmk.inp < makefile.tmp > Makefile rm -f makefile.tmp Rem Create .Po files for new files in lib/ @@ -343,4 +345,3 @@ set djgpp_ver= set sys_malloc= set libxml= - === modified file 'configure.in' --- configure.in 2011-10-13 02:16:59 +0000 +++ configure.in 2011-10-17 01:22:19 +0000 @@ -1357,19 +1357,6 @@ dnl Check for endianess AC_C_BIGENDIAN -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 AC_PROG_MAKE_SET === modified file 'lib/gnulib.mk' --- lib/gnulib.mk 2011-09-26 21:30:18 +0000 +++ lib/gnulib.mk 2011-10-17 01:22:19 +0000 @@ -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=msvc-inval --avoid=msvc-nothrow --avoid=pathmax --avoid=raise --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat +# 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=msvc-inval --avoid=msvc-nothrow --avoid=pathmax --avoid=raise --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdalign stdarg stdio strftime strtoimax strtoumax symlink sys_stat MOSTLYCLEANFILES += core *.stackdump @@ -421,6 +421,29 @@ ## end gnulib module stat +## begin gnulib module stdalign + +BUILT_SOURCES += $(STDALIGN_H) + +# We need the following in order to create <stdalign.h> when the system +# doesn't have one that works. +if GL_GENERATE_STDALIGN_H +stdalign.h: stdalign.in.h $(top_builddir)/config.status + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's/@''HAVE_ATTRIBUTE_ALIGNED''@/$(HAVE_ATTRIBUTE_ALIGNED)/g' < $(srcdir)/stdalign.in.h; \ + } > $@-t && \ + mv $@-t $@ +else +stdalign.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += stdalign.h stdalign.h-t + +EXTRA_DIST += stdalign.in.h + +## end gnulib module stdalign + ## begin gnulib module stdarg BUILT_SOURCES += $(STDARG_H) === modified file 'lib/md5.c' --- lib/md5.c 2011-02-19 07:28:29 +0000 +++ lib/md5.c 2011-10-17 01:22:19 +0000 @@ -24,7 +24,8 @@ #include "md5.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -254,8 +255,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { === modified file 'lib/sha1.c' --- lib/sha1.c 2011-05-24 08:12:52 +0000 +++ lib/sha1.c 2011-10-17 01:22:19 +0000 @@ -26,7 +26,8 @@ #include "sha1.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -241,8 +242,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { === modified file 'lib/sha256.c' --- lib/sha256.c 2011-06-21 08:45:39 +0000 +++ lib/sha256.c 2011-10-17 01:22:19 +0000 @@ -24,7 +24,8 @@ #include "sha256.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -373,8 +374,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { === modified file 'lib/sha512.c' --- lib/sha512.c 2011-06-21 08:45:39 +0000 +++ lib/sha512.c 2011-10-17 01:22:19 +0000 @@ -24,7 +24,8 @@ #include "sha512.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -381,8 +382,7 @@ if (len >= 128) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (u64) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (u64) != 0) if (UNALIGNED_P (buffer)) while (len > 128) { === added file 'lib/stdalign.in.h' --- lib/stdalign.in.h 1970-01-01 00:00:00 +0000 +++ lib/stdalign.in.h 2011-10-17 01:22:19 +0000 @@ -0,0 +1,61 @@ +/* A substitute for ISO C 1x <stdalign.h>. + + Copyright 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Paul Eggert and Bruno Haible. */ + +#ifndef _GL_STDALIGN_H +#define _GL_STDALIGN_H + +/* ISO C1X <stdalign.h> for platforms that lack it. + + References: + ISO C1X <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf> + sections 6.5.3.4, 6.7.5, 7.15. + C++0X <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf> + section 18.10. */ + +/* Return the alignment of a structure slot (field) of TYPE, + as an integer constant expression. The result cannot be used as a + value for an 'enum' constant, if you want to be portable to HP-UX + 10.20 cc and AIX 3.2.5 xlc. + + This is not the same as GCC's __alignof__ operator; for example, on + x86 with GCC, _Alignof (long long) is typically 4 whereas + __alignof__ (long long) is 8. */ +#include <stddef.h> +#if defined __cplusplus + template <class __t> struct __alignof_helper { char __a; __t __b; }; +# define _Alignof(type) offsetof (__alignof_helper<type>, __b) +#else +# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) +#endif +#define alignof _Alignof +#define __alignof_is_defined 1 + +/* Align a type or variable to the alignment A. */ +#if @HAVE_ATTRIBUTE_ALIGNED@ && !defined __cplusplus +# define _Alignas(a) __attribute__ ((__aligned__ (a))) +#elif 1300 <= _MSC_VER +# define _Alignas(a) __declspec ((align (a))) +#endif +#ifdef _Alignas +# define alignas _Alignas +# define __alignas_is_defined 1 +#endif + +#endif /* _GL_STDALIGN_H */ === modified file 'm4/gl-comp.m4' --- m4/gl-comp.m4 2011-10-07 21:15:00 +0000 +++ m4/gl-comp.m4 2011-10-17 01:22:19 +0000 @@ -76,6 +76,7 @@ # Code from module socklen: # Code from module ssize_t: # Code from module stat: + # Code from module stdalign: # Code from module stdarg: dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode dnl for the builtin va_copy to work. With Autoconf 2.60 or later, @@ -180,6 +181,7 @@ gl_SIGNAL_H gl_TYPE_SOCKLEN_T gt_TYPE_SSIZE_T +gl_STDALIGN_H gl_STDARG_H AM_STDBOOL_H gl_STDDEF_H @@ -311,18 +313,18 @@ if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then func_gl_gnulib_m4code_stat fi - if test $ac_cv_func_strtoimax = no; then - func_gl_gnulib_m4code_verify - fi if test $ac_cv_func_strtoimax = no && test $ac_cv_type_long_long_int = yes; then func_gl_gnulib_m4code_strtoll fi - if test $ac_cv_func_strtoumax = no; then + if test $ac_cv_func_strtoimax = no; then func_gl_gnulib_m4code_verify fi if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then func_gl_gnulib_m4code_strtoull fi + if test $ac_cv_func_strtoumax = no; then + func_gl_gnulib_m4code_verify + fi m4_pattern_allow([^gl_GNULIB_ENABLED_]) AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname]) AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) @@ -513,6 +515,7 @@ lib/signal.in.h lib/sigprocmask.c lib/stat.c + lib/stdalign.in.h lib/stdarg.in.h lib/stdbool.in.h lib/stddef.in.h @@ -563,6 +566,7 @@ m4/ssize_t.m4 m4/st_dm_mode.m4 m4/stat.m4 + m4/stdalign.m4 m4/stdarg.m4 m4/stdbool.m4 m4/stddef_h.m4 === modified file 'm4/pthread_sigmask.m4' --- m4/pthread_sigmask.m4 2011-09-03 23:08:32 +0000 +++ m4/pthread_sigmask.m4 2011-10-17 01:22:19 +0000 @@ -1,4 +1,4 @@ -# pthread_sigmask.m4 serial 12 +# pthread_sigmask.m4 serial 13 dnl Copyright (C) 2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,6 +6,8 @@ AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK], [ + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([pthread_sigmask]) LIB_PTHREAD_SIGMASK= === added file 'm4/stdalign.m4' --- m4/stdalign.m4 1970-01-01 00:00:00 +0000 +++ m4/stdalign.m4 2011-10-17 01:22:19 +0000 @@ -0,0 +1,37 @@ +# Check for stdalign.h that conforms to C1x. + +dnl Copyright 2011 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. + +# Prepare for substituting <stdalign.h> if it is not supported. + +AC_DEFUN([gl_STDALIGN_H], +[ + AC_CHECK_HEADERS_ONCE([stdalign.h]) + HAVE_ATTRIBUTE_ALIGNED='?' + + if test "$ac_cv_header_stdalign_h" = yes; then + STDALIGN_H='' + else + STDALIGN_H='stdalign.h' + AC_CACHE_CHECK([for __attribute__ ((__aligned__ (expr)))], + [gl_cv_attribute_aligned], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[char __attribute__ ((__aligned__ (1 << 3))) c;]], + [[]])], + [gl_cv_attribute_aligned=yes], + [gl_cv_attribute_aligned=no])]) + if test $gl_cv_attribute_aligned = yes; then + HAVE_ATTRIBUTE_ALIGNED=1 + else + HAVE_ATTRIBUTE_ALIGNED=0 + fi + fi + + AC_SUBST([HAVE_ATTRIBUTE_ALIGNED]) + AC_SUBST([STDALIGN_H]) + AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"]) +]) === modified file 'msdos/ChangeLog' --- msdos/ChangeLog 2011-09-29 12:00:18 +0000 +++ msdos/ChangeLog 2011-10-17 01:22:19 +0000 @@ -1,3 +1,10 @@ +2011-10-17 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module. + * sed2v2.inp (HAVE_ATTRIBUTE_ALIGNED): Remove edit. + * sedlibmk.inp (STDALIGN_H, @GL_GENERATE_STDALIGN_H_TRUE@) + (GL_GENERATE_STDALIGN_H_FALSE): New edits. + 2011-09-29 Eli Zaretskii <eliz@gnu.org> * mainmake.v2 (boot): Condition the value on the existence of === modified file 'msdos/sed2v2.inp' --- msdos/sed2v2.inp 2011-09-29 12:00:18 +0000 +++ msdos/sed2v2.inp 2011-10-17 01:22:19 +0000 @@ -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/ @@ -119,4 +118,3 @@ # might be defined in sys/config.h we include at the top of config.h. /^#undef BSTRING/s|#undef|# undef| /^#undef .*$/s|^.*$|/* & */| - === modified file 'msdos/sedlibmk.inp' --- msdos/sedlibmk.inp 2011-09-29 12:00:18 +0000 +++ msdos/sedlibmk.inp 2011-10-17 01:22:19 +0000 @@ -27,7 +27,7 @@ # otherwise edit them to zero: # # /^REPLACE_CALLOC *=/s/@REPLACE_CALLOC@/0/ -# +# # . If the module is a header or adds headers, edit the corresponding # variable to either an empty value or to the name of the header. # Examples: @@ -547,6 +547,7 @@ /^SIZE_T_SUFFIX *=/s/@SIZE_T_SUFFIX@/u/ /^ALLOCA_H *=/s/@[^@\n]*@/alloca.h/ /^STDBOOL_H *=/s/@[^@\n]*@// +/^STDALIGN_H *=/s/@[^@\n]*@/stdalign.h/ /^STDARG_H *=/s/@[^@\n]*@// /^STDDEF_H *=/s/@[^@\n]*@// /^STDINT_H *=/s/@[^@\n]*@/stdint.h/ @@ -600,6 +601,8 @@ 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@/\#/ === modified file 'nt/ChangeLog' --- nt/ChangeLog 2011-09-04 21:52:59 +0000 +++ nt/ChangeLog 2011-10-17 01:22:19 +0000 @@ -1,3 +1,8 @@ +2011-10-17 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module. + * config.nt (HAVE_ATTRIBUTE_ALIGNED): Remove. + 2011-09-04 Paul Eggert <eggert@cs.ucla.edu> * config.nt (HAVE_SNPRINTF): New macro. === modified file 'nt/config.nt' --- nt/config.nt 2011-09-26 03:20:03 +0000 +++ nt/config.nt 2011-10-17 01:22:19 +0000 @@ -271,13 +271,6 @@ /* Preprocessor macros needed for gnulib imports. */ -/* Define to 1 if GCC-style __attribute__ ((__aligned__ (expr))) works. */ -#ifdef __GNUC__ -#define HAVE_ATTRIBUTE_ALIGNED 1 -#else -#undef HAVE_ATTRIBUTE_ALIGNED -#endif - /* Define to 1 if strtold conforms to C99. */ #ifdef __GNUC__ #define HAVE_C99_STRTOLD 1 === modified file 'src/ChangeLog' --- src/ChangeLog 2011-10-15 10:12:00 +0000 +++ src/ChangeLog 2011-10-17 01:22:19 +0000 @@ -1,3 +1,12 @@ +2011-10-17 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module. + * alloc.c (XMALLOC_BASE_ALIGNMENT, GC_LISP_OBJECT_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>. + (DECL_ALIGN): Simplify by using alignas. + 2011-10-15 Martin Rudalics <rudalics@gmx.at> * window.c (coordinates_in_window): Rewrite and delabelize === modified file 'src/alloc.c' --- src/alloc.c 2011-10-12 06:09:40 +0000 +++ src/alloc.c 2011-10-17 01:22:19 +0000 @@ -507,12 +507,7 @@ 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; }) #ifdef USE_LSB_TAG /* A common multiple of the positive integers A and B. Ideally this would be the least common multiple, but there's no way to do that @@ -4235,15 +4230,15 @@ } -/* Alignment of Lisp_Object and pointer values. Use offsetof, as it +/* Alignment of Lisp_Object and 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. For example, on x86 with WIDE_EMACS_INT, __alignof__ (Lisp_Object) is 8 but GC_LISP_OBJECT_ALIGNMENT should be 4. */ #ifndef GC_LISP_OBJECT_ALIGNMENT -# define GC_LISP_OBJECT_ALIGNMENT offsetof (struct {char a; Lisp_Object b;}, b) +# define GC_LISP_OBJECT_ALIGNMENT alignof (Lisp_Object) #endif -#define GC_POINTER_ALIGNMENT offsetof (struct {char a; void *b;}, b) +#define GC_POINTER_ALIGNMENT alignof (void *) /* Mark Lisp objects referenced from the address range START+OFFSET..END or END+OFFSET..START. */ @@ -4662,17 +4657,11 @@ #ifdef 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: === modified file 'src/lisp.h' --- src/lisp.h 2011-10-11 17:35:16 +0000 +++ src/lisp.h 2011-10-17 01:22:19 +0000 @@ -20,6 +20,7 @@ #ifndef EMACS_LISP_H #define EMACS_LISP_H +#include <stdalign.h> #include <stdarg.h> #include <stddef.h> #include <inttypes.h> @@ -163,15 +164,8 @@ /* 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. */ -#ifndef NO_DECL_ALIGN -# ifndef DECL_ALIGN -# if HAVE_ATTRIBUTE_ALIGNED -# define DECL_ALIGN(type, var) \ - type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var -# else - /* What directives do other compilers use? */ -# endif -# endif +#ifdef alignas +# define DECL_ALIGN(type, var) type alignas (1 << GCTYPEBITS) var #endif /* Let's USE_LSB_TAG on systems where we know malloc returns mult-of-8. */ ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC 2011-10-17 3:24 bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC Paul Eggert @ 2011-10-17 4:04 ` Eli Zaretskii 2011-10-17 5:18 ` Paul Eggert 2011-10-17 13:22 ` Stefan Monnier ` (2 subsequent siblings) 3 siblings, 1 reply; 10+ messages in thread From: Eli Zaretskii @ 2011-10-17 4:04 UTC (permalink / raw) To: Paul Eggert; +Cc: 9772 > Date: Sun, 16 Oct 2011 20:24:31 -0700 > From: Paul Eggert <eggert@cs.ucla.edu> > CC: Eli Zaretskii <eliz@gnu.org> > > Here's a patch to the Emacs trunk (bzr 106094) to cause it to use > <stdalign.h> if available, falling back on a Gnulib replacement > otherwise. This simplifies Emacs proper, and should future-proof it > for C1X compilers. Do we need to install this before the release? What bug(s) does it fix? > Although this patch is mostly just a cleanup patch for GNU and POSIX > platforms, it may improve performance on some Microsoft hosts, as it > contains code for supporting <stdalign.h> under MSVC. As far as I can > see, USE_LSB_TAG currently doesn't work with MSVC, so if this patch > works it should increase the maximum Emacs buffer size in that > environment. The MSVC build is currently partially broken. A user submitted patches a few months ago, but they are not yet installed; they need some work before they can be. ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC 2011-10-17 4:04 ` Eli Zaretskii @ 2011-10-17 5:18 ` Paul Eggert 0 siblings, 0 replies; 10+ messages in thread From: Paul Eggert @ 2011-10-17 5:18 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 9772 On 10/16/11 21:04, Eli Zaretskii wrote: > Do we need to install this before the release? What bug(s) does it > fix? This patch is a cleaner fix for the garbage-collector core dump that I fixed on 2011-10-07 with bzr 106013. The fix in 106013 is a bit hacky, and it would be nice to have a cleaner fix for it, but it's not essential, particularly now that I know that the MSVC build is partly broken anyway. ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC 2011-10-17 3:24 bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC Paul Eggert 2011-10-17 4:04 ` Eli Zaretskii @ 2011-10-17 13:22 ` Stefan Monnier 2011-10-17 14:02 ` Eli Zaretskii 2011-10-27 20:19 ` bug#9772: stdalign status report Paul Eggert 2012-07-28 23:21 ` bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC Paul Eggert 3 siblings, 1 reply; 10+ messages in thread From: Stefan Monnier @ 2011-10-17 13:22 UTC (permalink / raw) To: Paul Eggert; +Cc: 9772 > Here's a patch to the Emacs trunk (bzr 106094) to cause it to use > <stdalign.h> if available, falling back on a Gnulib replacement > otherwise. This simplifies Emacs proper, and should future-proof it > for C1X compilers. I like this change, but I hope we can postpone it to after Emacs-24.1. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC 2011-10-17 13:22 ` Stefan Monnier @ 2011-10-17 14:02 ` Eli Zaretskii 2011-10-17 17:46 ` Paul Eggert 0 siblings, 1 reply; 10+ messages in thread From: Eli Zaretskii @ 2011-10-17 14:02 UTC (permalink / raw) To: Stefan Monnier; +Cc: eggert, 9772 > From: Stefan Monnier <monnier@iro.umontreal.ca> > Date: Mon, 17 Oct 2011 09:22:44 -0400 > Cc: 9772@debbugs.gnu.org > > > Here's a patch to the Emacs trunk (bzr 106094) to cause it to use > > <stdalign.h> if available, falling back on a Gnulib replacement > > otherwise. This simplifies Emacs proper, and should future-proof it > > for C1X compilers. > > I like this change Agreed. If my response sounded as if I didn't like it, I'm sorry for the confusion. > but I hope we can postpone it to after Emacs-24.1. If the only reason is to make the Windows and DOS ports cleaner, then I'd definitely suggest to postpone. ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC 2011-10-17 14:02 ` Eli Zaretskii @ 2011-10-17 17:46 ` Paul Eggert 0 siblings, 0 replies; 10+ messages in thread From: Paul Eggert @ 2011-10-17 17:46 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 9772 On 10/17/11 07:02, Eli Zaretskii wrote: >> From: Stefan Monnier <monnier@iro.umontreal.ca> >> but I hope we can postpone it to after Emacs-24.1. > > If the only reason is to make the Windows and DOS ports cleaner, then > I'd definitely suggest to postpone. Yes, that makes sense for now. There may be an issue before 24.1 comes out. If Gnulib is later updated, with a fix that Emacs needs before 24.1, and we then merge from the updated Gnulib, the merge will contain code that assumes <stdalign.h>. We'd need to either merge the Gnulib part of the postponed patch, or edit the Gnulib code by hand after importing it, to undo its assumption of <stdalign.h>. We can cross this bridge if we come to it, which I hope we don't.... ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#9772: stdalign status report 2011-10-17 3:24 bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC Paul Eggert 2011-10-17 4:04 ` Eli Zaretskii 2011-10-17 13:22 ` Stefan Monnier @ 2011-10-27 20:19 ` Paul Eggert 2011-11-08 6:09 ` bug#9772: fix for Bug#9772 should also help fix Bug#9660 Paul Eggert 2012-07-28 23:21 ` bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC Paul Eggert 3 siblings, 1 reply; 10+ messages in thread From: Paul Eggert @ 2011-10-27 20:19 UTC (permalink / raw) To: 9772 I merged the latest gnulib with the latest Emacs and came up with the following revised patch. I don't plan to install this now; I'm just emailing this as a status report in case I get hit by a bus or something. From the Windows point of view I expect that the only thing that's changed is that config.bat got simpler this time around. # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: eggert@cs.ucla.edu-20111027195126-qw6zih99i6st851q # target_branch: bzr+ssh://eggert@bzr.savannah.gnu.org/emacs/trunk # testament_sha1: 1f0df71b36800072c576416777f6b87d893824c0 # timestamp: 2011-10-27 13:16:35 -0700 # base_revision_id: rgm@gnu.org-20111027193835-trn7s0m73juujpuv # # Begin patch === modified file '.bzrignore' --- .bzrignore 2011-09-29 14:19:11 +0000 +++ .bzrignore 2011-10-17 01:22:19 +0000 @@ -53,6 +53,7 @@ lib/c++defs.h lib/getopt.h lib/inttypes.h +lib/stdalign.h lib/stdbool.h lib/stdio.h lib/stdint.h === modified file 'ChangeLog' --- ChangeLog 2011-10-25 16:41:26 +0000 +++ ChangeLog 2011-10-27 19:51:26 +0000 @@ -1,3 +1,20 @@ +2011-10-27 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module (Bug#9772). + 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. + * Makefile.in (GNULIB_MODULES): Add stdalign. + * config.bat: Do not set NO_DECL_ALIGN; no longer needed. + Copy lib/stdalign.in.h to lib/stdalign.in-h as needed. + * configure.in (HAVE_ATTRIBUTE_ALIGNED): Remove the code that + fiddles with this, as gnulib now does this for us. + * lib/gnulib.mk, lib/md5.c, lib/sha1.c, lib/sha256.c, lib/sha512.c: + * m4/gl-comp.m4, m4/pthread_sigmask.m4: Merge from gnulib. + + * doc/misc/texinfo.tex, lib/gettext.h, lib/gnulib.mk, lib/stdlib.in.h: + * m4/include_next.m4, m4/stdlib_h.m4: Merge from gnulib. + 2011-10-25 Nali Toja <nalitoja@gmail.com> (tiny change) * configure.in (HAVE_GNU_MAKE): Respect MAKE env-var. (Bug#9868) === modified file 'Makefile.in' --- Makefile.in 2011-09-26 21:30:18 +0000 +++ Makefile.in 2011-10-17 01:22:19 +0000 @@ -337,7 +337,7 @@ dup2 \ filemode getloadavg getopt-gnu ignore-value intprops lstat \ mktime pthread_sigmask readlink \ - socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat + socklen stdalign stdarg stdio strftime strtoimax strtoumax symlink sys_stat GNULIB_TOOL_FLAGS = \ --avoid=msvc-inval --avoid=msvc-nothrow --avoid=pathmax \ --avoid=raise --avoid=threadlib \ === modified file 'config.bat' --- config.bat 2011-09-29 12:08:36 +0000 +++ config.bat 2011-10-27 19:39:30 +0000 @@ -161,22 +161,6 @@ 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 @@ 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 stddef.in.h update stddef.in.h stddef.in-h @@ -343,4 +328,3 @@ set djgpp_ver= set sys_malloc= set libxml= - === modified file 'configure.in' --- configure.in 2011-10-25 20:46:31 +0000 +++ configure.in 2011-10-27 18:27:17 +0000 @@ -1351,19 +1351,6 @@ dnl Check for endianess AC_C_BIGENDIAN -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 AC_PROG_MAKE_SET === modified file 'doc/misc/texinfo.tex' --- doc/misc/texinfo.tex 2011-09-26 21:30:18 +0000 +++ doc/misc/texinfo.tex 2011-10-27 19:51:26 +0000 @@ -3,7 +3,7 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2011-09-23.09} +\def\texinfoversion{2011-10-19.08} % % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, @@ -2372,7 +2372,9 @@ \else\ifx\next-% \else\ifx\next.% \else\ptexslash - \fi\fi\fi} + \fi\fi\fi + \aftersmartic +} % like \smartslanted except unconditionally uses \ttsl, and no ic. % @var is set to this for defun arguments. @@ -2382,9 +2384,15 @@ % ttsl for book titles, do we? \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} +\def\aftersmartic{} +\def\var#1{% + \let\saveaftersmartic = \aftersmartic + \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% + \smartslanted{#1}% +} + \let\i=\smartitalic \let\slanted=\smartslanted -\def\var#1{\smartslanted{#1}} \let\dfn=\smartslanted \let\emph=\smartitalic @@ -2480,7 +2488,7 @@ \plainfrenchspacing #1% }% - \null + \null % reset spacefactor to 1000 } % We *must* turn on hyphenation at `-' and `_' in @code. @@ -2762,6 +2770,7 @@ \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi + \null % reset \spacefactor=1000 } % @abbr for "Comput. J." and the like. @@ -2774,6 +2783,7 @@ \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi + \null % reset \spacefactor=1000 } % @asis just yields its argument. Used with @table, for example. @@ -8103,7 +8113,7 @@ % space to prevent strange expansion errors.) \def\supereject{\par\penalty -20000\footnoteno =0 } -% @footnotestyle is meaningful for info output only. +% @footnotestyle is meaningful for Info output only. \let\footnotestyle=\comment {\catcode `\@=11 @@ -8166,6 +8176,8 @@ % expands into a box, it must come within the paragraph, lest it % provide a place where TeX can split the footnote. \footstrut + % + % Invoke rest of plain TeX footnote routine. \futurelet\next\fo@t } }%end \catcode `\@=11 === modified file 'lib/gettext.h' --- lib/gettext.h 2011-02-15 04:53:29 +0000 +++ lib/gettext.h 2011-10-27 19:51:26 +0000 @@ -185,7 +185,7 @@ #include <string.h> #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ - (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \ + (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ /* || __STDC_VERSION__ >= 199901L */ ) #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS === modified file 'lib/gnulib.mk' --- lib/gnulib.mk 2011-09-26 21:30:18 +0000 +++ lib/gnulib.mk 2011-10-27 19:51:26 +0000 @@ -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=msvc-inval --avoid=msvc-nothrow --avoid=pathmax --avoid=raise --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat +# 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=msvc-inval --avoid=msvc-nothrow --avoid=pathmax --avoid=raise --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdalign stdarg stdio strftime strtoimax strtoumax symlink sys_stat MOSTLYCLEANFILES += core *.stackdump @@ -421,6 +421,29 @@ ## end gnulib module stat +## begin gnulib module stdalign + +BUILT_SOURCES += $(STDALIGN_H) + +# We need the following in order to create <stdalign.h> when the system +# doesn't have one that works. +if GL_GENERATE_STDALIGN_H +stdalign.h: stdalign.in.h $(top_builddir)/config.status + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + cat $(srcdir)/stdalign.in.h; \ + } > $@-t && \ + mv $@-t $@ +else +stdalign.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += stdalign.h stdalign.h-t + +EXTRA_DIST += stdalign.in.h + +## end gnulib module stdalign + ## begin gnulib module stdarg BUILT_SOURCES += $(STDARG_H) @@ -710,6 +733,7 @@ -e 's/@''GNULIB_MKOSTEMPS''@/$(GNULIB_MKOSTEMPS)/g' \ -e 's/@''GNULIB_MKSTEMP''@/$(GNULIB_MKSTEMP)/g' \ -e 's/@''GNULIB_MKSTEMPS''@/$(GNULIB_MKSTEMPS)/g' \ + -e 's/@''GNULIB_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \ -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \ -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \ -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \ @@ -736,6 +760,7 @@ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ + -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \ -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ === modified file 'lib/md5.c' --- lib/md5.c 2011-02-19 07:28:29 +0000 +++ lib/md5.c 2011-10-17 01:22:19 +0000 @@ -24,7 +24,8 @@ #include "md5.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -254,8 +255,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { === modified file 'lib/sha1.c' --- lib/sha1.c 2011-05-24 08:12:52 +0000 +++ lib/sha1.c 2011-10-17 01:22:19 +0000 @@ -26,7 +26,8 @@ #include "sha1.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -241,8 +242,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { === modified file 'lib/sha256.c' --- lib/sha256.c 2011-06-21 08:45:39 +0000 +++ lib/sha256.c 2011-10-17 01:22:19 +0000 @@ -24,7 +24,8 @@ #include "sha256.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -373,8 +374,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { === modified file 'lib/sha512.c' --- lib/sha512.c 2011-06-21 08:45:39 +0000 +++ lib/sha512.c 2011-10-17 01:22:19 +0000 @@ -24,7 +24,8 @@ #include "sha512.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -381,8 +382,7 @@ if (len >= 128) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (u64) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (u64) != 0) if (UNALIGNED_P (buffer)) while (len > 128) { === added file 'lib/stdalign.in.h' --- lib/stdalign.in.h 1970-01-01 00:00:00 +0000 +++ lib/stdalign.in.h 2011-10-27 19:39:30 +0000 @@ -0,0 +1,85 @@ +/* A substitute for ISO C 1x <stdalign.h>. + + Copyright 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Paul Eggert and Bruno Haible. */ + +#ifndef _GL_STDALIGN_H +#define _GL_STDALIGN_H + +/* ISO C1X <stdalign.h> for platforms that lack it. + + References: + ISO C1X <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf> + sections 6.5.3.4, 6.7.5, 7.15. + C++0X <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf> + section 18.10. */ + +/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment + requirement of a structure member (i.e., slot or field) that is of + type TYPE, as an integer constant expression. + + This differs from GCC's __alignof__ operator, which can yield a + better-performing alignment for an object of that type. For + example, on x86 with GCC, __alignof__ (double) and __alignof__ + (long long) are 8, whereas alignof (double) and alignof (long long) + are 4 unless the option '-malign-double' is used. + + The result cannot be used as a value for an 'enum' constant, if you + want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */ +#include <stddef.h> +#if defined __cplusplus + template <class __t> struct __alignof_helper { char __a; __t __b; }; +# define _Alignof(type) offsetof (__alignof_helper<type>, __b) +#else +# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) +#endif +#define alignof _Alignof +#define __alignof_is_defined 1 + +/* alignas (A), also known as _Alignas (A), aligns a variable or type + to the alignment A, where A is an integer constant expression. For + example: + + int alignas (8) foo; + struct s { int a; int alignas (8) bar; }; + + aligns the address of FOO and the offset of BAR to be multiples of 8. + + A should be a power of two that is at least the type's alignment + and at most the implementation's alignment limit. This limit is + 2**28 on typical GNUish hosts, and 2**13 on MSVC. + + The following draft C1X requirements are not supported here: + + - If A is zero, alignas has no effect. + - alignas can be used multiple times; the strictest one wins. + - alignas (TYPE) is equivalent to alignas (alignof (TYPE)). + + */ + +#if __GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C +# define _Alignas(a) __attribute__ ((__aligned__ (a))) +#elif 1300 <= _MSC_VER +# define _Alignas(a) __declspec ((align (a))) +#endif +#ifdef _Alignas +# define alignas _Alignas +# define __alignas_is_defined 1 +#endif + +#endif /* _GL_STDALIGN_H */ === modified file 'lib/stdlib.in.h' --- lib/stdlib.in.h 2011-07-24 22:15:47 +0000 +++ lib/stdlib.in.h 2011-10-27 19:51:26 +0000 @@ -423,6 +423,22 @@ # endif #endif +#if @GNULIB_POSIX_OPENPT@ +/* Return an FD open to the master side of a pseudo-terminal. Flags should + include O_RDWR, and may also include O_NOCTTY. */ +# if !@HAVE_POSIX_OPENPT@ +_GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); +# endif +_GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); +_GL_CXXALIASWARN (posix_openpt); +#elif defined GNULIB_POSIXCHECK +# undef posix_openpt +# if HAVE_RAW_DECL_POSIX_OPENPT +_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " + "use gnulib module posix_openpt for portability"); +# endif +#endif + #if @GNULIB_PTSNAME@ /* Return the pathname of the pseudo-terminal slave associated with the master FD is open on, or NULL on errors. */ === modified file 'm4/gl-comp.m4' --- m4/gl-comp.m4 2011-10-07 21:15:00 +0000 +++ m4/gl-comp.m4 2011-10-17 01:22:19 +0000 @@ -76,6 +76,7 @@ # Code from module socklen: # Code from module ssize_t: # Code from module stat: + # Code from module stdalign: # Code from module stdarg: dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode dnl for the builtin va_copy to work. With Autoconf 2.60 or later, @@ -180,6 +181,7 @@ gl_SIGNAL_H gl_TYPE_SOCKLEN_T gt_TYPE_SSIZE_T +gl_STDALIGN_H gl_STDARG_H AM_STDBOOL_H gl_STDDEF_H @@ -311,18 +313,18 @@ if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then func_gl_gnulib_m4code_stat fi - if test $ac_cv_func_strtoimax = no; then - func_gl_gnulib_m4code_verify - fi if test $ac_cv_func_strtoimax = no && test $ac_cv_type_long_long_int = yes; then func_gl_gnulib_m4code_strtoll fi - if test $ac_cv_func_strtoumax = no; then + if test $ac_cv_func_strtoimax = no; then func_gl_gnulib_m4code_verify fi if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then func_gl_gnulib_m4code_strtoull fi + if test $ac_cv_func_strtoumax = no; then + func_gl_gnulib_m4code_verify + fi m4_pattern_allow([^gl_GNULIB_ENABLED_]) AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname]) AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) @@ -513,6 +515,7 @@ lib/signal.in.h lib/sigprocmask.c lib/stat.c + lib/stdalign.in.h lib/stdarg.in.h lib/stdbool.in.h lib/stddef.in.h @@ -563,6 +566,7 @@ m4/ssize_t.m4 m4/st_dm_mode.m4 m4/stat.m4 + m4/stdalign.m4 m4/stdarg.m4 m4/stdbool.m4 m4/stddef_h.m4 === modified file 'm4/include_next.m4' --- m4/include_next.m4 2011-09-26 21:30:18 +0000 +++ m4/include_next.m4 2011-10-27 19:51:26 +0000 @@ -1,4 +1,4 @@ -# include_next.m4 serial 22 +# include_next.m4 serial 23 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -219,12 +219,17 @@ gl_dirsep_regex='[/\\]' ;; *) - gl_dirsep_regex='/' + gl_dirsep_regex='\/' ;; esac + dnl A sed expression that turns a string into a basic regular + dnl expression, for use within "/.../". + gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' changequote([,]) - gl_absolute_header_sed='\|'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[|{ - s|.*"\(.*'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[\)".*|\1| + gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \ + | sed -e "$gl_make_literal_regex_sed"` + gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ + s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ changequote(,)dnl s|^/[^/]|//&| changequote([,])dnl === modified file 'm4/pthread_sigmask.m4' --- m4/pthread_sigmask.m4 2011-09-03 23:08:32 +0000 +++ m4/pthread_sigmask.m4 2011-10-17 01:22:19 +0000 @@ -1,4 +1,4 @@ -# pthread_sigmask.m4 serial 12 +# pthread_sigmask.m4 serial 13 dnl Copyright (C) 2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,6 +6,8 @@ AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK], [ + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([pthread_sigmask]) LIB_PTHREAD_SIGMASK= === added file 'm4/stdalign.m4' --- m4/stdalign.m4 1970-01-01 00:00:00 +0000 +++ m4/stdalign.m4 2011-10-27 19:39:30 +0000 @@ -0,0 +1,22 @@ +# Check for stdalign.h that conforms to C1x. + +dnl Copyright 2011 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. + +# Prepare for substituting <stdalign.h> if it is not supported. + +AC_DEFUN([gl_STDALIGN_H], +[ + AC_CHECK_HEADERS_ONCE([stdalign.h]) + + if test $ac_cv_header_stdalign_h = yes; then + STDALIGN_H='' + else + STDALIGN_H='stdalign.h' + fi + + AC_SUBST([STDALIGN_H]) + AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"]) +]) === modified file 'm4/stdlib_h.m4' --- m4/stdlib_h.m4 2011-02-25 07:36:37 +0000 +++ m4/stdlib_h.m4 2011-10-27 19:51:26 +0000 @@ -19,10 +19,10 @@ #if HAVE_RANDOM_H # include <random.h> #endif - ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp - mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r - setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt - unsetenv]) + ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt + initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps posix_openpt + ptsname random_r realpath rpmatch setenv setstate_r srandom_r strtod + strtoll strtoull unlockpt unsetenv]) ]) AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], @@ -50,6 +50,7 @@ GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS]) GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP]) GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS]) + GNULIB_POSIX_OPENPT=0; AC_SUBST([GNULIB_POSIX_OPENPT]) GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME]) GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV]) GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R]) @@ -76,6 +77,7 @@ HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP]) HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) + HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT]) HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H]) HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) === modified file 'msdos/ChangeLog' --- msdos/ChangeLog 2011-09-29 12:00:18 +0000 +++ msdos/ChangeLog 2011-10-27 19:39:30 +0000 @@ -1,3 +1,10 @@ +2011-10-27 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module (Bug#9772). + * sed2v2.inp (HAVE_ATTRIBUTE_ALIGNED): Remove edit. + * sedlibmk.inp (STDALIGN_H, @GL_GENERATE_STDALIGN_H_TRUE@) + (GL_GENERATE_STDALIGN_H_FALSE): New edits. + 2011-09-29 Eli Zaretskii <eliz@gnu.org> * mainmake.v2 (boot): Condition the value on the existence of === modified file 'msdos/sed2v2.inp' --- msdos/sed2v2.inp 2011-09-29 12:00:18 +0000 +++ msdos/sed2v2.inp 2011-10-17 01:22:19 +0000 @@ -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/ @@ -119,4 +118,3 @@ # might be defined in sys/config.h we include at the top of config.h. /^#undef BSTRING/s|#undef|# undef| /^#undef .*$/s|^.*$|/* & */| - === modified file 'msdos/sedlibmk.inp' --- msdos/sedlibmk.inp 2011-09-29 12:00:18 +0000 +++ msdos/sedlibmk.inp 2011-10-17 01:22:19 +0000 @@ -27,7 +27,7 @@ # otherwise edit them to zero: # # /^REPLACE_CALLOC *=/s/@REPLACE_CALLOC@/0/ -# +# # . If the module is a header or adds headers, edit the corresponding # variable to either an empty value or to the name of the header. # Examples: @@ -547,6 +547,7 @@ /^SIZE_T_SUFFIX *=/s/@SIZE_T_SUFFIX@/u/ /^ALLOCA_H *=/s/@[^@\n]*@/alloca.h/ /^STDBOOL_H *=/s/@[^@\n]*@// +/^STDALIGN_H *=/s/@[^@\n]*@/stdalign.h/ /^STDARG_H *=/s/@[^@\n]*@// /^STDDEF_H *=/s/@[^@\n]*@// /^STDINT_H *=/s/@[^@\n]*@/stdint.h/ @@ -600,6 +601,8 @@ 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@/\#/ === modified file 'nt/ChangeLog' --- nt/ChangeLog 2011-10-25 16:54:19 +0000 +++ nt/ChangeLog 2011-10-27 18:27:17 +0000 @@ -1,3 +1,8 @@ +2011-10-27 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module (Bug#9772). + * config.nt (HAVE_ATTRIBUTE_ALIGNED): Remove. + 2011-10-25 Eli Zaretskii <eliz@gnu.org> * makefile.w32-in (dist): Don't put the top-level INSTALL into the === modified file 'nt/config.nt' --- nt/config.nt 2011-10-22 09:17:01 +0000 +++ nt/config.nt 2011-10-27 18:27:17 +0000 @@ -278,13 +278,6 @@ /* Preprocessor macros needed for gnulib imports. */ -/* Define to 1 if GCC-style __attribute__ ((__aligned__ (expr))) works. */ -#ifdef __GNUC__ -#define HAVE_ATTRIBUTE_ALIGNED 1 -#else -#undef HAVE_ATTRIBUTE_ALIGNED -#endif - /* Define to 1 if strtold conforms to C99. */ #ifdef __GNUC__ #define HAVE_C99_STRTOLD 1 === modified file 'src/ChangeLog' --- src/ChangeLog 2011-10-27 14:35:51 +0000 +++ src/ChangeLog 2011-10-27 18:27:17 +0000 @@ -1,3 +1,12 @@ +2011-10-27 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module (Bug#9772). + * alloc.c (XMALLOC_BASE_ALIGNMENT, GC_LISP_OBJECT_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>. + (DECL_ALIGN): Simplify by using alignas. + 2011-10-27 Juanma Barranquero <lekktu@gmail.com> * window.c (Fframe_root_window, Fframe_first_window, Fwindow_end) === modified file 'src/alloc.c' --- src/alloc.c 2011-10-12 06:09:40 +0000 +++ src/alloc.c 2011-10-17 01:22:19 +0000 @@ -507,12 +507,7 @@ 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; }) #ifdef USE_LSB_TAG /* A common multiple of the positive integers A and B. Ideally this would be the least common multiple, but there's no way to do that @@ -4235,15 +4230,15 @@ } -/* Alignment of Lisp_Object and pointer values. Use offsetof, as it +/* Alignment of Lisp_Object and 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. For example, on x86 with WIDE_EMACS_INT, __alignof__ (Lisp_Object) is 8 but GC_LISP_OBJECT_ALIGNMENT should be 4. */ #ifndef GC_LISP_OBJECT_ALIGNMENT -# define GC_LISP_OBJECT_ALIGNMENT offsetof (struct {char a; Lisp_Object b;}, b) +# define GC_LISP_OBJECT_ALIGNMENT alignof (Lisp_Object) #endif -#define GC_POINTER_ALIGNMENT offsetof (struct {char a; void *b;}, b) +#define GC_POINTER_ALIGNMENT alignof (void *) /* Mark Lisp objects referenced from the address range START+OFFSET..END or END+OFFSET..START. */ @@ -4662,17 +4657,11 @@ #ifdef 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: === modified file 'src/lisp.h' --- src/lisp.h 2011-10-11 17:35:16 +0000 +++ src/lisp.h 2011-10-17 01:22:19 +0000 @@ -20,6 +20,7 @@ #ifndef EMACS_LISP_H #define EMACS_LISP_H +#include <stdalign.h> #include <stdarg.h> #include <stddef.h> #include <inttypes.h> @@ -163,15 +164,8 @@ /* 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. */ -#ifndef NO_DECL_ALIGN -# ifndef DECL_ALIGN -# if HAVE_ATTRIBUTE_ALIGNED -# define DECL_ALIGN(type, var) \ - type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var -# else - /* What directives do other compilers use? */ -# endif -# endif +#ifdef alignas +# define DECL_ALIGN(type, var) type alignas (1 << GCTYPEBITS) var #endif /* Let's USE_LSB_TAG on systems where we know malloc returns mult-of-8. */ ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#9772: fix for Bug#9772 should also help fix Bug#9660 2011-10-27 20:19 ` bug#9772: stdalign status report Paul Eggert @ 2011-11-08 6:09 ` Paul Eggert 2011-11-08 6:42 ` Paul Eggert 0 siblings, 1 reply; 10+ messages in thread From: Paul Eggert @ 2011-11-08 6:09 UTC (permalink / raw) To: 9772, 9660 It appears that the patch for Bug#9772 would also help fix one of the problems with the MSVC port (Bug#9660), as it solves the problem of DECL_ALIGN in a portable way. So I updated the Bug#9772 patch to reflect the latest GNU Emacs trunk (bzr 106319) and am resending it below. # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: eggert@cs.ucla.edu-20111108050351-8pi1asjihs20t0ki # target_branch: bzr+ssh://eggert@bzr.savannah.gnu.org/emacs/trunk # testament_sha1: f4cd0307b11c4a1d34ef6fc7efc489d034586917 # timestamp: 2011-11-07 21:07:24 -0800 # base_revision_id: monnier@iro.umontreal.ca-20111108025759-\ # d5u0ag4hdie27lcz # # Begin patch === modified file '.bzrignore' --- .bzrignore 2011-09-29 14:19:11 +0000 +++ .bzrignore 2011-10-17 01:22:19 +0000 @@ -53,6 +53,7 @@ lib/c++defs.h lib/getopt.h lib/inttypes.h +lib/stdalign.h lib/stdbool.h lib/stdio.h lib/stdint.h === modified file 'ChangeLog' --- ChangeLog 2011-11-05 11:34:56 +0000 +++ ChangeLog 2011-11-08 01:07:18 +0000 @@ -1,3 +1,20 @@ +2011-11-08 Paul Eggert <eggert@cs.ucla.edu> + + 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. + * Makefile.in (GNULIB_MODULES): Add stdalign. + * config.bat: Do not set NO_DECL_ALIGN; no longer needed. + Copy lib/stdalign.in.h to lib/stdalign.in-h as needed. + * configure.in (HAVE_ATTRIBUTE_ALIGNED): Remove the code that + fiddles with this, as gnulib now does this for us. + * lib/gnulib.mk, lib/md5.c, lib/sha1.c, lib/sha256.c, lib/sha512.c: + * m4/gl-comp.m4, m4/pthread_sigmask.m4: Merge from gnulib. + + * doc/misc/texinfo.tex, lib/gettext.h, lib/gnulib.mk, lib/stdlib.in.h: + * m4/include_next.m4, m4/stdlib_h.m4: Merge from gnulib. + 2011-11-05 Eli Zaretskii <eliz@gnu.org> * lib/makefile.w32-in (FRC): New dummy target. === modified file 'Makefile.in' --- Makefile.in 2011-09-26 21:30:18 +0000 +++ Makefile.in 2011-10-17 01:22:19 +0000 @@ -337,7 +337,7 @@ dup2 \ filemode getloadavg getopt-gnu ignore-value intprops lstat \ mktime pthread_sigmask readlink \ - socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat + socklen stdalign stdarg stdio strftime strtoimax strtoumax symlink sys_stat GNULIB_TOOL_FLAGS = \ --avoid=msvc-inval --avoid=msvc-nothrow --avoid=pathmax \ --avoid=raise --avoid=threadlib \ === modified file 'config.bat' --- config.bat 2011-10-31 17:49:10 +0000 +++ config.bat 2011-11-01 05:03:56 +0000 @@ -163,22 +163,6 @@ 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 @@ -283,6 +267,7 @@ 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 stddef.in.h update stddef.in.h stddef.in-h @@ -346,4 +331,3 @@ set djgpp_ver= set sys_malloc= set libxml= - === modified file 'configure.in' --- configure.in 2011-11-04 22:16:46 +0000 +++ configure.in 2011-11-07 05:59:29 +0000 @@ -1351,19 +1351,6 @@ dnl Check for endianess AC_C_BIGENDIAN -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 AC_PROG_MAKE_SET === modified file 'doc/misc/ChangeLog' --- doc/misc/ChangeLog 2011-11-01 19:22:57 +0000 +++ doc/misc/ChangeLog 2011-11-08 01:07:18 +0000 @@ -1,3 +1,7 @@ +2011-11-08 Paul Eggert <eggert@cs.ucla.edu> + + * texinfo.tex: Merge from gnulib. + 2011-10-31 Katsumi Yamaoka <yamaoka@jpl.org> * gnus.texi (Other Gnus Versions): Remove. === modified file 'doc/misc/texinfo.tex' --- doc/misc/texinfo.tex 2011-09-26 21:30:18 +0000 +++ doc/misc/texinfo.tex 2011-11-07 05:56:04 +0000 @@ -3,7 +3,7 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2011-09-23.09} +\def\texinfoversion{2011-11-06.09} % % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, @@ -116,6 +116,7 @@ % Set up fixed words for English if not already set. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi +\ifx\putworderror\undefined \gdef\putwordfile{error}\fi \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi \ifx\putwordin\undefined \gdef\putwordin{in}\fi \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi @@ -1194,29 +1195,31 @@ \def\imagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% \def\imageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% % - % pdftex (and the PDF format) support .png, .jpg, .pdf (among - % others). Let's try in that order. + % pdftex (and the PDF format) support .pdf, .png, .jpg (among + % others). Let's try in that order, PDF first since if + % someone has a scalable image, presumably better to use that than a + % bitmap. \let\pdfimgext=\empty \begingroup - \openin 1 #1.png \ifeof 1 - \openin 1 #1.jpg \ifeof 1 - \openin 1 #1.jpeg \ifeof 1 - \openin 1 #1.JPG \ifeof 1 - \openin 1 #1.pdf \ifeof 1 - \openin 1 #1.PDF \ifeof 1 + \openin 1 #1.pdf \ifeof 1 + \openin 1 #1.PDF \ifeof 1 + \openin 1 #1.png \ifeof 1 + \openin 1 #1.jpg \ifeof 1 + \openin 1 #1.jpeg \ifeof 1 + \openin 1 #1.JPG \ifeof 1 \errhelp = \nopdfimagehelp \errmessage{Could not find image file #1 for pdf}% - \else \gdef\pdfimgext{PDF}% + \else \gdef\pdfimgext{JPG}% \fi - \else \gdef\pdfimgext{pdf}% + \else \gdef\pdfimgext{jpeg}% \fi - \else \gdef\pdfimgext{JPG}% + \else \gdef\pdfimgext{jpg}% \fi - \else \gdef\pdfimgext{jpeg}% + \else \gdef\pdfimgext{png}% \fi - \else \gdef\pdfimgext{jpg}% + \else \gdef\pdfimgext{PDF}% \fi - \else \gdef\pdfimgext{png}% + \else \gdef\pdfimgext{pdf}% \fi \closein 1 \endgroup @@ -2372,7 +2375,9 @@ \else\ifx\next-% \else\ifx\next.% \else\ptexslash - \fi\fi\fi} + \fi\fi\fi + \aftersmartic +} % like \smartslanted except unconditionally uses \ttsl, and no ic. % @var is set to this for defun arguments. @@ -2382,9 +2387,15 @@ % ttsl for book titles, do we? \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} +\def\aftersmartic{} +\def\var#1{% + \let\saveaftersmartic = \aftersmartic + \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% + \smartslanted{#1}% +} + \let\i=\smartitalic \let\slanted=\smartslanted -\def\var#1{\smartslanted{#1}} \let\dfn=\smartslanted \let\emph=\smartitalic @@ -2480,7 +2491,7 @@ \plainfrenchspacing #1% }% - \null + \null % reset spacefactor to 1000 } % We *must* turn on hyphenation at `-' and `_' in @code. @@ -2762,6 +2773,7 @@ \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi + \null % reset \spacefactor=1000 } % @abbr for "Comput. J." and the like. @@ -2774,6 +2786,7 @@ \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi + \null % reset \spacefactor=1000 } % @asis just yields its argument. Used with @table, for example. @@ -2979,7 +2992,7 @@ {\tentt \global\dimen0 = 3em}% Width of the box. \dimen2 = .55pt % Thickness of rules % The text. (`r' is open on the right, `e' somewhat less so on the left.) -\setbox0 = \hbox{\kern-.75pt \reducedsf error\kern-1.5pt} +\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} % \setbox\errorbox=\hbox to \dimen0{\hfil \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. @@ -8103,7 +8116,7 @@ % space to prevent strange expansion errors.) \def\supereject{\par\penalty -20000\footnoteno =0 } -% @footnotestyle is meaningful for info output only. +% @footnotestyle is meaningful for Info output only. \let\footnotestyle=\comment {\catcode `\@=11 @@ -8166,6 +8179,8 @@ % expands into a box, it must come within the paragraph, lest it % provide a place where TeX can split the footnote. \footstrut + % + % Invoke rest of plain TeX footnote routine. \futurelet\next\fo@t } }%end \catcode `\@=11 === modified file 'lib/gettext.h' --- lib/gettext.h 2011-02-15 04:53:29 +0000 +++ lib/gettext.h 2011-10-27 19:51:26 +0000 @@ -185,7 +185,7 @@ #include <string.h> #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ - (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \ + (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ /* || __STDC_VERSION__ >= 199901L */ ) #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS === modified file 'lib/gnulib.mk' --- lib/gnulib.mk 2011-09-26 21:30:18 +0000 +++ lib/gnulib.mk 2011-10-27 19:51:26 +0000 @@ -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=msvc-inval --avoid=msvc-nothrow --avoid=pathmax --avoid=raise --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat +# 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=msvc-inval --avoid=msvc-nothrow --avoid=pathmax --avoid=raise --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdalign stdarg stdio strftime strtoimax strtoumax symlink sys_stat MOSTLYCLEANFILES += core *.stackdump @@ -421,6 +421,29 @@ ## end gnulib module stat +## begin gnulib module stdalign + +BUILT_SOURCES += $(STDALIGN_H) + +# We need the following in order to create <stdalign.h> when the system +# doesn't have one that works. +if GL_GENERATE_STDALIGN_H +stdalign.h: stdalign.in.h $(top_builddir)/config.status + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + cat $(srcdir)/stdalign.in.h; \ + } > $@-t && \ + mv $@-t $@ +else +stdalign.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += stdalign.h stdalign.h-t + +EXTRA_DIST += stdalign.in.h + +## end gnulib module stdalign + ## begin gnulib module stdarg BUILT_SOURCES += $(STDARG_H) @@ -710,6 +733,7 @@ -e 's/@''GNULIB_MKOSTEMPS''@/$(GNULIB_MKOSTEMPS)/g' \ -e 's/@''GNULIB_MKSTEMP''@/$(GNULIB_MKSTEMP)/g' \ -e 's/@''GNULIB_MKSTEMPS''@/$(GNULIB_MKSTEMPS)/g' \ + -e 's/@''GNULIB_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \ -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \ -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \ -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \ @@ -736,6 +760,7 @@ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ + -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \ -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ === modified file 'lib/md5.c' --- lib/md5.c 2011-02-19 07:28:29 +0000 +++ lib/md5.c 2011-10-17 01:22:19 +0000 @@ -24,7 +24,8 @@ #include "md5.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -254,8 +255,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { === modified file 'lib/sha1.c' --- lib/sha1.c 2011-05-24 08:12:52 +0000 +++ lib/sha1.c 2011-10-17 01:22:19 +0000 @@ -26,7 +26,8 @@ #include "sha1.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -241,8 +242,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { === modified file 'lib/sha256.c' --- lib/sha256.c 2011-06-21 08:45:39 +0000 +++ lib/sha256.c 2011-10-17 01:22:19 +0000 @@ -24,7 +24,8 @@ #include "sha256.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -373,8 +374,7 @@ if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { === modified file 'lib/sha512.c' --- lib/sha512.c 2011-06-21 08:45:39 +0000 +++ lib/sha512.c 2011-10-17 01:22:19 +0000 @@ -24,7 +24,8 @@ #include "sha512.h" -#include <stddef.h> +#include <stdalign.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -381,8 +382,7 @@ if (len >= 128) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (u64) != 0) +# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (u64) != 0) if (UNALIGNED_P (buffer)) while (len > 128) { === added file 'lib/stdalign.in.h' --- lib/stdalign.in.h 1970-01-01 00:00:00 +0000 +++ lib/stdalign.in.h 2011-11-07 05:56:04 +0000 @@ -0,0 +1,89 @@ +/* A substitute for ISO C 1x <stdalign.h>. + + Copyright 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Paul Eggert and Bruno Haible. */ + +#ifndef _GL_STDALIGN_H +#define _GL_STDALIGN_H + +/* ISO C1X <stdalign.h> for platforms that lack it. + + References: + ISO C1X <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf> + sections 6.5.3.4, 6.7.5, 7.15. + C++0X <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf> + section 18.10. */ + +/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment + requirement of a structure member (i.e., slot or field) that is of + type TYPE, as an integer constant expression. + + This differs from GCC's __alignof__ operator, which can yield a + better-performing alignment for an object of that type. For + example, on x86 with GCC, __alignof__ (double) and __alignof__ + (long long) are 8, whereas alignof (double) and alignof (long long) + are 4 unless the option '-malign-double' is used. + + The result cannot be used as a value for an 'enum' constant, if you + want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */ +#include <stddef.h> +#if defined __cplusplus + template <class __t> struct __alignof_helper { char __a; __t __b; }; +# define _Alignof(type) offsetof (__alignof_helper<type>, __b) +#else +# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) +#endif +#define alignof _Alignof +#define __alignof_is_defined 1 + +/* alignas (A), also known as _Alignas (A), aligns a variable or type + to the alignment A, where A is an integer constant expression. For + example: + + int alignas (8) foo; + struct s { int a; int alignas (8) bar; }; + + aligns the address of FOO and the offset of BAR to be multiples of 8. + + A should be a power of two that is at least the type's alignment + and at most the implementation's alignment limit. This limit is + 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable + to MSVC through at least version 10.0, A should be an integer + constant, as MSVC does not support expressions such as 1 << 3. + To be portable to Sun C 5.11, do not align auto variables to + anything stricter than their default alignment. + + The following draft C1X requirements are not supported here: + + - If A is zero, alignas has no effect. + - alignas can be used multiple times; the strictest one wins. + - alignas (TYPE) is equivalent to alignas (alignof (TYPE)). + + */ + +#if __GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C +# define _Alignas(a) __attribute__ ((__aligned__ (a))) +#elif 1300 <= _MSC_VER +# define _Alignas(a) __declspec (align (a)) +#endif +#ifdef _Alignas +# define alignas _Alignas +# define __alignas_is_defined 1 +#endif + +#endif /* _GL_STDALIGN_H */ === modified file 'lib/stdlib.in.h' --- lib/stdlib.in.h 2011-07-24 22:15:47 +0000 +++ lib/stdlib.in.h 2011-11-08 01:12:08 +0000 @@ -247,7 +247,7 @@ #elif defined GNULIB_POSIXCHECK # undef grantpt # if HAVE_RAW_DECL_GRANTPT -_GL_WARN_ON_USE (ptsname, "grantpt is not portable - " +_GL_WARN_ON_USE (grantpt, "grantpt is not portable - " "use gnulib module grantpt for portability"); # endif #endif @@ -423,6 +423,22 @@ # endif #endif +#if @GNULIB_POSIX_OPENPT@ +/* Return an FD open to the master side of a pseudo-terminal. Flags should + include O_RDWR, and may also include O_NOCTTY. */ +# if !@HAVE_POSIX_OPENPT@ +_GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); +# endif +_GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); +_GL_CXXALIASWARN (posix_openpt); +#elif defined GNULIB_POSIXCHECK +# undef posix_openpt +# if HAVE_RAW_DECL_POSIX_OPENPT +_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " + "use gnulib module posix_openpt for portability"); +# endif +#endif + #if @GNULIB_PTSNAME@ /* Return the pathname of the pseudo-terminal slave associated with the master FD is open on, or NULL on errors. */ === modified file 'm4/gl-comp.m4' --- m4/gl-comp.m4 2011-10-07 21:15:00 +0000 +++ m4/gl-comp.m4 2011-10-17 01:22:19 +0000 @@ -76,6 +76,7 @@ # Code from module socklen: # Code from module ssize_t: # Code from module stat: + # Code from module stdalign: # Code from module stdarg: dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode dnl for the builtin va_copy to work. With Autoconf 2.60 or later, @@ -180,6 +181,7 @@ gl_SIGNAL_H gl_TYPE_SOCKLEN_T gt_TYPE_SSIZE_T +gl_STDALIGN_H gl_STDARG_H AM_STDBOOL_H gl_STDDEF_H @@ -311,18 +313,18 @@ if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then func_gl_gnulib_m4code_stat fi - if test $ac_cv_func_strtoimax = no; then - func_gl_gnulib_m4code_verify - fi if test $ac_cv_func_strtoimax = no && test $ac_cv_type_long_long_int = yes; then func_gl_gnulib_m4code_strtoll fi - if test $ac_cv_func_strtoumax = no; then + if test $ac_cv_func_strtoimax = no; then func_gl_gnulib_m4code_verify fi if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then func_gl_gnulib_m4code_strtoull fi + if test $ac_cv_func_strtoumax = no; then + func_gl_gnulib_m4code_verify + fi m4_pattern_allow([^gl_GNULIB_ENABLED_]) AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname]) AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) @@ -513,6 +515,7 @@ lib/signal.in.h lib/sigprocmask.c lib/stat.c + lib/stdalign.in.h lib/stdarg.in.h lib/stdbool.in.h lib/stddef.in.h @@ -563,6 +566,7 @@ m4/ssize_t.m4 m4/st_dm_mode.m4 m4/stat.m4 + m4/stdalign.m4 m4/stdarg.m4 m4/stdbool.m4 m4/stddef_h.m4 === modified file 'm4/include_next.m4' --- m4/include_next.m4 2011-09-26 21:30:18 +0000 +++ m4/include_next.m4 2011-10-27 19:51:26 +0000 @@ -1,4 +1,4 @@ -# include_next.m4 serial 22 +# include_next.m4 serial 23 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -219,12 +219,17 @@ gl_dirsep_regex='[/\\]' ;; *) - gl_dirsep_regex='/' + gl_dirsep_regex='\/' ;; esac + dnl A sed expression that turns a string into a basic regular + dnl expression, for use within "/.../". + gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' changequote([,]) - gl_absolute_header_sed='\|'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[|{ - s|.*"\(.*'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[\)".*|\1| + gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \ + | sed -e "$gl_make_literal_regex_sed"` + gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ + s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ changequote(,)dnl s|^/[^/]|//&| changequote([,])dnl === modified file 'm4/pthread_sigmask.m4' --- m4/pthread_sigmask.m4 2011-09-03 23:08:32 +0000 +++ m4/pthread_sigmask.m4 2011-10-17 01:22:19 +0000 @@ -1,4 +1,4 @@ -# pthread_sigmask.m4 serial 12 +# pthread_sigmask.m4 serial 13 dnl Copyright (C) 2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,6 +6,8 @@ AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK], [ + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([pthread_sigmask]) LIB_PTHREAD_SIGMASK= === added file 'm4/stdalign.m4' --- m4/stdalign.m4 1970-01-01 00:00:00 +0000 +++ m4/stdalign.m4 2011-10-27 19:39:30 +0000 @@ -0,0 +1,22 @@ +# Check for stdalign.h that conforms to C1x. + +dnl Copyright 2011 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. + +# Prepare for substituting <stdalign.h> if it is not supported. + +AC_DEFUN([gl_STDALIGN_H], +[ + AC_CHECK_HEADERS_ONCE([stdalign.h]) + + if test $ac_cv_header_stdalign_h = yes; then + STDALIGN_H='' + else + STDALIGN_H='stdalign.h' + fi + + AC_SUBST([STDALIGN_H]) + AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"]) +]) === modified file 'm4/stdlib_h.m4' --- m4/stdlib_h.m4 2011-02-25 07:36:37 +0000 +++ m4/stdlib_h.m4 2011-10-27 19:51:26 +0000 @@ -19,10 +19,10 @@ #if HAVE_RANDOM_H # include <random.h> #endif - ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp - mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r - setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt - unsetenv]) + ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt + initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps posix_openpt + ptsname random_r realpath rpmatch setenv setstate_r srandom_r strtod + strtoll strtoull unlockpt unsetenv]) ]) AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], @@ -50,6 +50,7 @@ GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS]) GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP]) GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS]) + GNULIB_POSIX_OPENPT=0; AC_SUBST([GNULIB_POSIX_OPENPT]) GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME]) GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV]) GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R]) @@ -76,6 +77,7 @@ HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP]) HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) + HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT]) HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H]) HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) === modified file 'msdos/ChangeLog' --- msdos/ChangeLog 2011-10-31 17:37:39 +0000 +++ msdos/ChangeLog 2011-11-08 01:07:18 +0000 @@ -1,3 +1,10 @@ +2011-11-08 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module (Bug#9772, Bug#9660). + * sed2v2.inp (HAVE_ATTRIBUTE_ALIGNED): Remove edit. + * sedlibmk.inp (STDALIGN_H, @GL_GENERATE_STDALIGN_H_TRUE@) + (GL_GENERATE_STDALIGN_H_FALSE): New edits. + 2011-10-31 Eli Zaretskii <eliz@gnu.org> * sed3v2.inp (insrcdir): Comment out definition. === modified file 'msdos/sed2v2.inp' --- msdos/sed2v2.inp 2011-10-31 02:25:01 +0000 +++ msdos/sed2v2.inp 2011-11-01 05:03:56 +0000 @@ -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/ @@ -119,4 +118,3 @@ # might be defined in sys/config.h we include at the top of config.h. /^#undef BSTRING/s|#undef|# undef| /^#undef .*$/s|^.*$|/* & */| - === modified file 'msdos/sedlibmk.inp' --- msdos/sedlibmk.inp 2011-09-29 12:00:18 +0000 +++ msdos/sedlibmk.inp 2011-10-17 01:22:19 +0000 @@ -27,7 +27,7 @@ # otherwise edit them to zero: # # /^REPLACE_CALLOC *=/s/@REPLACE_CALLOC@/0/ -# +# # . If the module is a header or adds headers, edit the corresponding # variable to either an empty value or to the name of the header. # Examples: @@ -547,6 +547,7 @@ /^SIZE_T_SUFFIX *=/s/@SIZE_T_SUFFIX@/u/ /^ALLOCA_H *=/s/@[^@\n]*@/alloca.h/ /^STDBOOL_H *=/s/@[^@\n]*@// +/^STDALIGN_H *=/s/@[^@\n]*@/stdalign.h/ /^STDARG_H *=/s/@[^@\n]*@// /^STDDEF_H *=/s/@[^@\n]*@// /^STDINT_H *=/s/@[^@\n]*@/stdint.h/ @@ -600,6 +601,8 @@ 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@/\#/ === modified file 'nt/ChangeLog' --- nt/ChangeLog 2011-11-05 22:33:44 +0000 +++ nt/ChangeLog 2011-11-08 01:07:18 +0000 @@ -1,3 +1,8 @@ +2011-11-08 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module (Bug#9772, Bug#9660). + * config.nt (HAVE_ATTRIBUTE_ALIGNED): Remove. + 2011-11-05 Christoph Scholtes <cschol2112@googlemail.com> * inc/stdint.h (UINT64_MAX, UINT64_MIN, INT64_MIN, UINTMAX_MAX) === modified file 'nt/config.nt' --- nt/config.nt 2011-11-05 17:16:01 +0000 +++ nt/config.nt 2011-11-07 05:59:29 +0000 @@ -278,13 +278,6 @@ /* Preprocessor macros needed for gnulib imports. */ -/* Define to 1 if GCC-style __attribute__ ((__aligned__ (expr))) works. */ -#ifdef __GNUC__ -#define HAVE_ATTRIBUTE_ALIGNED 1 -#else -#undef HAVE_ATTRIBUTE_ALIGNED -#endif - /* Define to 1 if strtold conforms to C99. */ #ifdef __GNUC__ #define HAVE_C99_STRTOLD 1 === modified file 'src/ChangeLog' --- src/ChangeLog 2011-11-07 17:04:01 +0000 +++ src/ChangeLog 2011-11-08 01:07:18 +0000 @@ -1,3 +1,14 @@ +2011-11-08 Paul Eggert <eggert@cs.ucla.edu> + + Use Gnulib stdalign module (Bug#9772, Bug#9660). + * alloc.c (XMALLOC_BASE_ALIGNMENT, GC_LISP_OBJECT_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>. + (DECL_ALIGN): Simplify by using alignas. + Port to MSVC, by using ALIGN_GCTYPEBITS. + (ALIGN_GCTYPEBITS): New macro. + 2011-11-07 Juanma Barranquero <lekktu@gmail.com> * lisp.h (syms_of_abbrev): Remove declaration. === modified file 'src/alloc.c' --- src/alloc.c 2011-11-07 05:37:49 +0000 +++ src/alloc.c 2011-11-07 05:59:29 +0000 @@ -513,12 +513,7 @@ 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; }) #ifdef USE_LSB_TAG /* A common multiple of the positive integers A and B. Ideally this would be the least common multiple, but there's no way to do that @@ -4241,15 +4236,15 @@ } -/* Alignment of Lisp_Object and pointer values. Use offsetof, as it +/* Alignment of Lisp_Object and 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. For example, on x86 with WIDE_EMACS_INT, __alignof__ (Lisp_Object) is 8 but GC_LISP_OBJECT_ALIGNMENT should be 4. */ #ifndef GC_LISP_OBJECT_ALIGNMENT -# define GC_LISP_OBJECT_ALIGNMENT offsetof (struct {char a; Lisp_Object b;}, b) +# define GC_LISP_OBJECT_ALIGNMENT alignof (Lisp_Object) #endif -#define GC_POINTER_ALIGNMENT offsetof (struct {char a; void *b;}, b) +#define GC_POINTER_ALIGNMENT alignof (void *) /* Mark Lisp objects referenced from the address range START+OFFSET..END or END+OFFSET..START. */ @@ -4668,17 +4663,11 @@ #ifdef 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: === modified file 'src/lisp.h' --- src/lisp.h 2011-11-07 17:04:01 +0000 +++ src/lisp.h 2011-11-08 01:07:18 +0000 @@ -20,6 +20,7 @@ #ifndef EMACS_LISP_H #define EMACS_LISP_H +#include <stdalign.h> #include <stdarg.h> #include <stddef.h> #include <inttypes.h> @@ -163,18 +164,8 @@ /* 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. */ -#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 DECL_ALIGN(type, var) \ - type __declspec(align(1 << GCTYPEBITS)) var -# else - /* What directives do other compilers use? */ -# endif -# endif +#ifdef alignas +# define DECL_ALIGN(type, var) type alignas (ALIGN_GCTYPEBITS) var #endif /* Let's USE_LSB_TAG on systems where we know malloc returns mult-of-8. */ @@ -302,6 +293,10 @@ #ifndef GCTYPEBITS #define GCTYPEBITS 3 +#define ALIGN_GCTYPEBITS 8 /* This must be an integer constant, for MSVC. */ +#endif +#if 1 << GCTYPEBITS != ALIGN_GCTYPEBITS +# error "ALIGN_GCTYPEBITS is wrong!" #endif /* These values are overridden by the m- file on some machines. */ ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#9772: fix for Bug#9772 should also help fix Bug#9660 2011-11-08 6:09 ` bug#9772: fix for Bug#9772 should also help fix Bug#9660 Paul Eggert @ 2011-11-08 6:42 ` Paul Eggert 0 siblings, 0 replies; 10+ messages in thread From: Paul Eggert @ 2011-11-08 6:42 UTC (permalink / raw) To: 9772, 9660 On 11/07/11 22:09, Paul Eggert wrote: > It appears that the patch for Bug#9772 would also help fix one of the > problems with the MSVC port (Bug#9660) Whoops, I meant to write "Bug#9960". Sorry about the confusion. I'll send an updated copy of the patch (with 9660 -> 9960) to the latter bug address. ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC 2011-10-17 3:24 bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC Paul Eggert ` (2 preceding siblings ...) 2011-10-27 20:19 ` bug#9772: stdalign status report Paul Eggert @ 2012-07-28 23:21 ` Paul Eggert 3 siblings, 0 replies; 10+ messages in thread From: Paul Eggert @ 2012-07-28 23:21 UTC (permalink / raw) To: 9772 I merged this patch into the Emacs trunk as bzr 109252. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-07-28 23:21 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-10-17 3:24 bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC Paul Eggert 2011-10-17 4:04 ` Eli Zaretskii 2011-10-17 5:18 ` Paul Eggert 2011-10-17 13:22 ` Stefan Monnier 2011-10-17 14:02 ` Eli Zaretskii 2011-10-17 17:46 ` Paul Eggert 2011-10-27 20:19 ` bug#9772: stdalign status report Paul Eggert 2011-11-08 6:09 ` bug#9772: fix for Bug#9772 should also help fix Bug#9660 Paul Eggert 2011-11-08 6:42 ` Paul Eggert 2012-07-28 23:21 ` bug#9772: <stdalign.h>, USE_LSB_TAG, and MSVC Paul Eggert
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).