diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/alloc.c b/src/alloc.c index 67187f12ea6..5bbd5e55c42 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -46,6 +46,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 46 | #include TERM_HEADER | 46 | #include TERM_HEADER |
| 47 | #endif /* HAVE_WINDOW_SYSTEM */ | 47 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 48 | 48 | ||
| 49 | #include <flexmember.h> | ||
| 49 | #include <verify.h> | 50 | #include <verify.h> |
| 50 | #include <execinfo.h> /* For backtrace. */ | 51 | #include <execinfo.h> /* For backtrace. */ |
| 51 | 52 | ||
| @@ -1757,27 +1758,23 @@ static char const string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] = | |||
| 1757 | 1758 | ||
| 1758 | #ifdef GC_CHECK_STRING_BYTES | 1759 | #ifdef GC_CHECK_STRING_BYTES |
| 1759 | 1760 | ||
| 1760 | #define SDATA_SIZE(NBYTES) \ | 1761 | #define SDATA_SIZE(NBYTES) FLEXSIZEOF (struct sdata, data, NBYTES) |
| 1761 | ((SDATA_DATA_OFFSET \ | ||
| 1762 | + (NBYTES) + 1 \ | ||
| 1763 | + sizeof (ptrdiff_t) - 1) \ | ||
| 1764 | & ~(sizeof (ptrdiff_t) - 1)) | ||
| 1765 | 1762 | ||
| 1766 | #else /* not GC_CHECK_STRING_BYTES */ | 1763 | #else /* not GC_CHECK_STRING_BYTES */ |
| 1767 | 1764 | ||
| 1768 | /* The 'max' reserves space for the nbytes union member even when NBYTES + 1 is | 1765 | /* The 'max' reserves space for the nbytes union member even when NBYTES + 1 is |
| 1769 | less than the size of that member. The 'max' is not needed when | 1766 | less than the size of that member. The 'max' is not needed when |
| 1770 | SDATA_DATA_OFFSET is a multiple of sizeof (ptrdiff_t), because then the | 1767 | SDATA_DATA_OFFSET is a multiple of FLEXALIGNOF (struct sdata), |
| 1771 | alignment code reserves enough space. */ | 1768 | because then the alignment code reserves enough space. */ |
| 1772 | 1769 | ||
| 1773 | #define SDATA_SIZE(NBYTES) \ | 1770 | #define SDATA_SIZE(NBYTES) \ |
| 1774 | ((SDATA_DATA_OFFSET \ | 1771 | ((SDATA_DATA_OFFSET \ |
| 1775 | + (SDATA_DATA_OFFSET % sizeof (ptrdiff_t) == 0 \ | 1772 | + (SDATA_DATA_OFFSET % FLEXALIGNOF (struct sdata) == 0 \ |
| 1776 | ? NBYTES \ | 1773 | ? NBYTES \ |
| 1777 | : max (NBYTES, sizeof (ptrdiff_t) - 1)) \ | 1774 | : max (NBYTES, FLEXALIGNOF (struct sdata) - 1)) \ |
| 1778 | + 1 \ | 1775 | + 1 \ |
| 1779 | + sizeof (ptrdiff_t) - 1) \ | 1776 | + FLEXALIGNOF (struct sdata) - 1) \ |
| 1780 | & ~(sizeof (ptrdiff_t) - 1)) | 1777 | & ~(FLEXALIGNOF (struct sdata) - 1)) |
| 1781 | 1778 | ||
| 1782 | #endif /* not GC_CHECK_STRING_BYTES */ | 1779 | #endif /* not GC_CHECK_STRING_BYTES */ |
| 1783 | 1780 | ||
| @@ -1997,7 +1994,7 @@ allocate_string_data (struct Lisp_String *s, | |||
| 1997 | 1994 | ||
| 1998 | if (nbytes > LARGE_STRING_BYTES) | 1995 | if (nbytes > LARGE_STRING_BYTES) |
| 1999 | { | 1996 | { |
| 2000 | size_t size = offsetof (struct sblock, data) + needed; | 1997 | size_t size = FLEXSIZEOF (struct sblock, data, needed); |
| 2001 | 1998 | ||
| 2002 | #ifdef DOUG_LEA_MALLOC | 1999 | #ifdef DOUG_LEA_MALLOC |
| 2003 | if (!mmap_lisp_allowed_p ()) | 2000 | if (!mmap_lisp_allowed_p ()) |
| @@ -2953,15 +2950,15 @@ set_next_vector (struct Lisp_Vector *v, struct Lisp_Vector *p) | |||
| 2953 | enum | 2950 | enum |
| 2954 | { | 2951 | { |
| 2955 | /* Alignment of struct Lisp_Vector objects. */ | 2952 | /* Alignment of struct Lisp_Vector objects. */ |
| 2956 | vector_alignment = COMMON_MULTIPLE (ALIGNOF_STRUCT_LISP_VECTOR, | 2953 | vector_alignment = COMMON_MULTIPLE (FLEXALIGNOF (struct Lisp_Vector), |
| 2957 | GCALIGNMENT), | 2954 | GCALIGNMENT), |
| 2958 | 2955 | ||
| 2959 | /* Vector size requests are a multiple of this. */ | 2956 | /* Vector size requests are a multiple of this. */ |
| 2960 | roundup_size = COMMON_MULTIPLE (vector_alignment, word_size) | 2957 | roundup_size = COMMON_MULTIPLE (vector_alignment, word_size) |
| 2961 | }; | 2958 | }; |
| 2962 | 2959 | ||
| 2963 | /* Verify assumptions described above. */ | 2960 | /* Verify assumptions described above. */ |
| 2964 | verify ((VECTOR_BLOCK_SIZE % roundup_size) == 0); | 2961 | verify (VECTOR_BLOCK_SIZE % roundup_size == 0); |
| 2965 | verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS)); | 2962 | verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS)); |
| 2966 | 2963 | ||
| 2967 | /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */ | 2964 | /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */ |