* .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.
+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.
+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
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
'
if exist ..\autogen\config.in sed -f ../msdos/sed2x.inp < ..\autogen\config.in > config.tmp\r
:src4\r
sed -f ../msdos/sed2v2.inp <config.tmp >config.h2\r
-Rem See if DECL_ALIGN can be supported with this GCC\r
-rm -f junk.c junk.o junk junk.exe\r
-echo struct { int i; char *p; } __attribute__((__aligned__(8))) foo; >junk.c\r
-rem Two percent signs because it is a special character for COMMAND.COM/CMD\r
-rem Filter thru Sed because "&" is special for CMD.EXE\r
-echo int main(void) { return (unsigned long)"&"foo %% 8; } | sed "s/.&./\&/" >>junk.c\r
-gcc -o junk junk.c\r
-if not exist junk.exe coff2exe junk\r
-junk\r
-If Not ErrorLevel 1 Goto alignOk\r
-Echo WARNING: Your GCC does not support 8-byte aligned variables.\r
-Echo WARNING: Therefore Emacs cannot support buffers larger than 128MB.\r
-rem The following line disables DECL_ALIGN which in turn disables USE_LSB_TAG\r
-rem For details see lisp.h where it defines USE_LSB_TAG\r
-echo #define NO_DECL_ALIGN >>config.h2\r
-:alignOk\r
Rem See if they have libxml2 later than v2.2.0 installed\r
Echo Checking whether libxml2 v2.2.1 or later is installed ...\r
rm -f junk.c junk.o junk junk.exe\r
If Exist build-aux\snippet\c++defs.h update build-aux/snippet/c++defs.h build-aux/snippet/cxxdefs.h\r
If Exist alloca.in.h update alloca.in.h alloca.in-h\r
If Exist getopt.in.h update getopt.in.h getopt.in-h\r
+If Exist stdalign.in.h update stdalign.in.h stdalign.in-h\r
If Exist stdbool.in.h update stdbool.in.h stdbool.in-h\r
If Exist signal.in.h update signal.in.h signal.in-h\r
If Exist stdalign.in.h update stdalign.in.h stdalign.in-h\r
set djgpp_ver=\r
set sys_malloc=\r
set libxml=\r
-\r
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.
# 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
--- /dev/null
+# 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])
+])
# 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:
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
m4/c-strtod.m4
m4/clock_time.m4
m4/dup2.m4
+ m4/environ.m4
m4/extensions.m4
m4/filemode.m4
m4/getloadavg.m4
+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
/^#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/
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@/\#/
+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.
/* 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
+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)
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 \
}
-/* 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
#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:
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 */
/* 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;
#ifndef EMACS_LISP_H
#define EMACS_LISP_H
+#include <stdalign.h>
#include <stdarg.h>
#include <stddef.h>
#include <inttypes.h>
on the few static Lisp_Objects used: all the defsubr as well
as the two special buffers buffer_defaults and buffer_local_symbols. */
-/* First, try and define DECL_ALIGN(type,var) which declares a static
- variable VAR of type TYPE with the added requirement that it be
- TYPEBITS-aligned. */
-
enum Lisp_Bits
{
/* Number of bits in a Lisp_Object tag. This can be used in #if,
#define GCTYPEBITS 3
GCTYPEBITS,
+ /* 2**GCTYPEBITS. This must also be a macro that expands to a
+ literal integer constant, for MSVC. */
+ GCALIGNMENT =
+#define GCALIGNMENT 8
+ GCALIGNMENT,
+
/* Number of bits in a Lisp_Object value, not counting the tag. */
VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS,
FIXNUM_BITS = VALBITS + 1
};
+#if GCALIGNMENT != 1 << GCTYPEBITS
+# error "GCALIGNMENT and GCTYPEBITS are inconsistent"
+#endif
+
/* The maximum value that can be stored in a EMACS_INT, assuming all
bits other than the type bits contribute to a nonnegative signed value.
This can be used in #if, e.g., '#if VAL_MAX < UINTPTR_MAX' below. */
#define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1))
-#ifndef NO_DECL_ALIGN
-# ifndef DECL_ALIGN
-# if HAVE_ATTRIBUTE_ALIGNED
-# define DECL_ALIGN(type, var) \
- type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
-# elif defined(_MSC_VER)
-# define ALIGN_GCTYPEBITS 8
-# if (1 << GCTYPEBITS) != ALIGN_GCTYPEBITS
-# error ALIGN_GCTYPEBITS is wrong!
-# endif
-# define DECL_ALIGN(type, var) \
- type __declspec(align(ALIGN_GCTYPEBITS)) var
-# else
- /* What directives do other compilers use? */
-# endif
-# endif
-#endif
-
/* Unless otherwise specified, use USE_LSB_TAG on systems where: */
#ifndef USE_LSB_TAG
/* 1. We know malloc returns a multiple of 8. */
# if (defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ \
|| defined DARWIN_OS || defined __sun)
/* 2. We can specify multiple-of-8 alignment on static variables. */
-# ifdef DECL_ALIGN
+# ifdef alignas
/* 3. Pointers-as-ints exceed VAL_MAX.
On hosts where pointers-as-ints do not exceed VAL_MAX, USE_LSB_TAG is:
a. unnecessary, because the top bits of an EMACS_INT are unused, and
# define USE_LSB_TAG 0
#endif
-/* If we cannot use 8-byte alignment, make DECL_ALIGN a no-op. */
-#ifndef DECL_ALIGN
+#ifndef alignas
+# define alignas(alignment) /* empty */
# if USE_LSB_TAG
-# error "USE_LSB_TAG used without defining DECL_ALIGN"
+# error "USE_LSB_TAG requires alignas"
# endif
-# define DECL_ALIGN(type, var) type var
#endif
#ifdef _MSC_VER
#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
- static DECL_ALIGN (struct Lisp_Subr, sname) = \
+ static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
{ (PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS) \
| (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \
{ (Lisp_Object (__cdecl *)(void))fnname }, \
#else /* not _MSC_VER */
#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
- static DECL_ALIGN (struct Lisp_Subr, sname) = \
+ static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
{ PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS, \
{ .a ## maxargs = fnname }, \
minargs, maxargs, lname, intspec, 0}; \