diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-07-28 16:05:32 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-07-28 16:05:32 -0700 |
commit | e32a579975bc219bc24d403deeb1fa89187fc51e (patch) | |
tree | 957a729b7f4eb64980359a57828f02d29e6758e7 /src/lisp.h | |
parent | 01bd1b0df605d644ae31e8f1f81d926a5d8c7099 (diff) | |
download | emacs-e32a579975bc219bc24d403deeb1fa89187fc51e.tar.gz emacs-e32a579975bc219bc24d403deeb1fa89187fc51e.tar.bz2 emacs-e32a579975bc219bc24d403deeb1fa89187fc51e.zip |
Use Gnulib stdalign and environ modules (Bug#9772, Bug#9960).
* .bzrignore: Add lib/stdalign.h.
* config.bat: Do not set NO_DECL_ALIGN; no longer needed.
Copy lib/stdalign.in.h to lib/stdalign.in-h as needed.
* configure.ac (HAVE_ATTRIBUTE_ALIGNED): Remove the code that
fiddles with this, as gnulib now does this for us.
* admin/merge-gnulib: Add environ, stdalign.
* m4/environ.m4: New file, from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* lib/stdalign.in.h, m4/stdalign.m4: New files, from gnulib.
* sed2v2.inp (HAVE_ATTRIBUTE_ALIGNED): Remove edit.
* sedlibmk.inp (STDALIGN_H, @GL_GENERATE_STDALIGN_H_TRUE@)
(GL_GENERATE_STDALIGN_H_FALSE): New edits.
* nt/config.nt (HAVE_ATTRIBUTE_ALIGNED): Remove.
* src/alloc.c (XMALLOC_BASE_ALIGNMENT, GC_POINTER_ALIGNMENT, pure_alloc):
Simplify by using alignof.
(pure_alloc) [! USE_LSB_TAG]: Don't over-align EMACS_INT values.
* src/lisp.h: Include <stdalign.h>.
(GCALIGNMENT): New macro and constant.
(DECL_ALIGN): Remove. All uses replaced by alignas (GCALIGNMENT).
(USE_LSB_TAG): ifdef on alignas, not on DECL_ALIGN.
(stdalign): New macro, if not already defined.
Diffstat (limited to 'src/lisp.h')
-rw-r--r-- | src/lisp.h | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/src/lisp.h b/src/lisp.h index 80a9ab343c3..a45e9c2c892 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifndef EMACS_LISP_H #define EMACS_LISP_H +#include <stdalign.h> #include <stdarg.h> #include <stddef.h> #include <inttypes.h> @@ -151,10 +152,6 @@ extern int suppress_checking EXTERNALLY_VISIBLE; on the few static Lisp_Objects used: all the defsubr as well as the two special buffers buffer_defaults and buffer_local_symbols. */ -/* First, try and define DECL_ALIGN(type,var) which declares a static - variable VAR of type TYPE with the added requirement that it be - TYPEBITS-aligned. */ - enum Lisp_Bits { /* Number of bits in a Lisp_Object tag. This can be used in #if, @@ -163,6 +160,12 @@ enum Lisp_Bits #define GCTYPEBITS 3 GCTYPEBITS, + /* 2**GCTYPEBITS. This must also be a macro that expands to a + literal integer constant, for MSVC. */ + GCALIGNMENT = +#define GCALIGNMENT 8 + GCALIGNMENT, + /* Number of bits in a Lisp_Object value, not counting the tag. */ VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS, @@ -173,36 +176,22 @@ enum Lisp_Bits FIXNUM_BITS = VALBITS + 1 }; +#if GCALIGNMENT != 1 << GCTYPEBITS +# error "GCALIGNMENT and GCTYPEBITS are inconsistent" +#endif + /* The maximum value that can be stored in a EMACS_INT, assuming all bits other than the type bits contribute to a nonnegative signed value. This can be used in #if, e.g., '#if VAL_MAX < UINTPTR_MAX' below. */ #define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1)) -#ifndef NO_DECL_ALIGN -# ifndef DECL_ALIGN -# if HAVE_ATTRIBUTE_ALIGNED -# define DECL_ALIGN(type, var) \ - type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var -# elif defined(_MSC_VER) -# define ALIGN_GCTYPEBITS 8 -# if (1 << GCTYPEBITS) != ALIGN_GCTYPEBITS -# error ALIGN_GCTYPEBITS is wrong! -# endif -# define DECL_ALIGN(type, var) \ - type __declspec(align(ALIGN_GCTYPEBITS)) var -# else - /* What directives do other compilers use? */ -# endif -# endif -#endif - /* Unless otherwise specified, use USE_LSB_TAG on systems where: */ #ifndef USE_LSB_TAG /* 1. We know malloc returns a multiple of 8. */ # if (defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ \ || defined DARWIN_OS || defined __sun) /* 2. We can specify multiple-of-8 alignment on static variables. */ -# ifdef DECL_ALIGN +# ifdef alignas /* 3. Pointers-as-ints exceed VAL_MAX. On hosts where pointers-as-ints do not exceed VAL_MAX, USE_LSB_TAG is: a. unnecessary, because the top bits of an EMACS_INT are unused, and @@ -223,12 +212,11 @@ enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 }; # define USE_LSB_TAG 0 #endif -/* If we cannot use 8-byte alignment, make DECL_ALIGN a no-op. */ -#ifndef DECL_ALIGN +#ifndef alignas +# define alignas(alignment) /* empty */ # if USE_LSB_TAG -# error "USE_LSB_TAG used without defining DECL_ALIGN" +# error "USE_LSB_TAG requires alignas" # endif -# define DECL_ALIGN(type, var) type var #endif @@ -1882,7 +1870,7 @@ typedef struct { #ifdef _MSC_VER #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ - static DECL_ALIGN (struct Lisp_Subr, sname) = \ + static struct Lisp_Subr alignas (GCALIGNMENT) sname = \ { (PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS) \ | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \ { (Lisp_Object (__cdecl *)(void))fnname }, \ @@ -1891,7 +1879,7 @@ typedef struct { #else /* not _MSC_VER */ #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ - static DECL_ALIGN (struct Lisp_Subr, sname) = \ + static struct Lisp_Subr alignas (GCALIGNMENT) sname = \ { PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS, \ { .a ## maxargs = fnname }, \ minargs, maxargs, lname, intspec, 0}; \ |