diff options
| author | Paul Eggert | 2012-07-28 16:05:32 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-07-28 16:05:32 -0700 |
| commit | e32a579975bc219bc24d403deeb1fa89187fc51e (patch) | |
| tree | 957a729b7f4eb64980359a57828f02d29e6758e7 /src/alloc.c | |
| parent | 01bd1b0df605d644ae31e8f1f81d926a5d8c7099 (diff) | |
| download | emacs-e32a579975bc219bc24d403deeb1fa89187fc51e.tar.gz emacs-e32a579975bc219bc24d403deeb1fa89187fc51e.zip | |
Use Gnulib stdalign and environ modules (Bug#9772, Bug#9960).
* .bzrignore: Add lib/stdalign.h.
* config.bat: Do not set NO_DECL_ALIGN; no longer needed.
Copy lib/stdalign.in.h to lib/stdalign.in-h as needed.
* configure.ac (HAVE_ATTRIBUTE_ALIGNED): Remove the code that
fiddles with this, as gnulib now does this for us.
* admin/merge-gnulib: Add environ, stdalign.
* m4/environ.m4: New file, from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* lib/stdalign.in.h, m4/stdalign.m4: New files, from gnulib.
* sed2v2.inp (HAVE_ATTRIBUTE_ALIGNED): Remove edit.
* sedlibmk.inp (STDALIGN_H, @GL_GENERATE_STDALIGN_H_TRUE@)
(GL_GENERATE_STDALIGN_H_FALSE): New edits.
* nt/config.nt (HAVE_ATTRIBUTE_ALIGNED): Remove.
* src/alloc.c (XMALLOC_BASE_ALIGNMENT, GC_POINTER_ALIGNMENT, pure_alloc):
Simplify by using alignof.
(pure_alloc) [! USE_LSB_TAG]: Don't over-align EMACS_INT values.
* src/lisp.h: Include <stdalign.h>.
(GCALIGNMENT): New macro and constant.
(DECL_ALIGN): Remove. All uses replaced by alignas (GCALIGNMENT).
(USE_LSB_TAG): ifdef on alignas, not on DECL_ALIGN.
(stdalign): New macro, if not already defined.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/alloc.c b/src/alloc.c index a551dd821b8..e5f412bb4c3 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -533,12 +533,7 @@ buffer_memory_full (ptrdiff_t nbytes) | |||
| 533 | hold a size_t value and (2) the header size is a multiple of the | 533 | hold a size_t value and (2) the header size is a multiple of the |
| 534 | alignment that Emacs needs for C types and for USE_LSB_TAG. */ | 534 | alignment that Emacs needs for C types and for USE_LSB_TAG. */ |
| 535 | #define XMALLOC_BASE_ALIGNMENT \ | 535 | #define XMALLOC_BASE_ALIGNMENT \ |
| 536 | offsetof ( \ | 536 | alignof (union { long double d; intmax_t i; void *p; }) |
| 537 | struct { \ | ||
| 538 | union { long double d; intmax_t i; void *p; } u; \ | ||
| 539 | char c; \ | ||
| 540 | }, \ | ||
| 541 | c) | ||
| 542 | 537 | ||
| 543 | #if USE_LSB_TAG | 538 | #if USE_LSB_TAG |
| 544 | # define XMALLOC_HEADER_ALIGNMENT \ | 539 | # define XMALLOC_HEADER_ALIGNMENT \ |
| @@ -4652,10 +4647,10 @@ mark_maybe_pointer (void *p) | |||
| 4652 | } | 4647 | } |
| 4653 | 4648 | ||
| 4654 | 4649 | ||
| 4655 | /* Alignment of pointer values. Use offsetof, as it sometimes returns | 4650 | /* Alignment of pointer values. Use alignof, as it sometimes returns |
| 4656 | a smaller alignment than GCC's __alignof__ and mark_memory might | 4651 | a smaller alignment than GCC's __alignof__ and mark_memory might |
| 4657 | miss objects if __alignof__ were used. */ | 4652 | miss objects if __alignof__ were used. */ |
| 4658 | #define GC_POINTER_ALIGNMENT offsetof (struct {char a; void *b;}, b) | 4653 | #define GC_POINTER_ALIGNMENT alignof (void *) |
| 4659 | 4654 | ||
| 4660 | /* Define POINTERS_MIGHT_HIDE_IN_OBJECTS to 1 if marking via C pointers does | 4655 | /* Define POINTERS_MIGHT_HIDE_IN_OBJECTS to 1 if marking via C pointers does |
| 4661 | not suffice, which is the typical case. A host where a Lisp_Object is | 4656 | not suffice, which is the typical case. A host where a Lisp_Object is |
| @@ -5103,17 +5098,11 @@ pure_alloc (size_t size, int type) | |||
| 5103 | #if USE_LSB_TAG | 5098 | #if USE_LSB_TAG |
| 5104 | size_t alignment = (1 << GCTYPEBITS); | 5099 | size_t alignment = (1 << GCTYPEBITS); |
| 5105 | #else | 5100 | #else |
| 5106 | size_t alignment = sizeof (EMACS_INT); | 5101 | size_t alignment = alignof (EMACS_INT); |
| 5107 | 5102 | ||
| 5108 | /* Give Lisp_Floats an extra alignment. */ | 5103 | /* Give Lisp_Floats an extra alignment. */ |
| 5109 | if (type == Lisp_Float) | 5104 | if (type == Lisp_Float) |
| 5110 | { | 5105 | alignment = alignof (struct Lisp_Float); |
| 5111 | #if defined __GNUC__ && __GNUC__ >= 2 | ||
| 5112 | alignment = __alignof (struct Lisp_Float); | ||
| 5113 | #else | ||
| 5114 | alignment = sizeof (struct Lisp_Float); | ||
| 5115 | #endif | ||
| 5116 | } | ||
| 5117 | #endif | 5106 | #endif |
| 5118 | 5107 | ||
| 5119 | again: | 5108 | again: |