diff options
| author | Paul Eggert | 2016-09-07 18:08:45 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-09-07 18:10:11 -0700 |
| commit | d2f1971dd570439da4198fa76603b53b072060f8 (patch) | |
| tree | 38b1ddbeda27b6ed6ac52205169624608cc597fd /src/lisp.h | |
| parent | 12a7e0f88eaa68aabe7e32589e2d5c8f776f6346 (diff) | |
| download | emacs-d2f1971dd570439da4198fa76603b53b072060f8.tar.gz emacs-d2f1971dd570439da4198fa76603b53b072060f8.zip | |
Port flexible array members to GCC + valgrind
These changes are needed to conform to the C standard's rule for
allocating structs containing flexible array members. C11 says
that malloc (offsetof (struct s, m) + n) does not suffice to
allocate a struct with an n-byte tail; instead, malloc’s arg
should be rounded up to the nearest multiple of alignof (struct s).
Although this is arguably a defect in C11, gcc -O2 + valgrind
sometimes complains when this rule is violated, and when debugging
it’s better to keep valgrind happy.
For details please see the thread containing the message at:
https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00416.html
* lib-src/ebrowse.c, src/alloc.c, src/image.c, src/process.c:
Include flexmember.h.
* lib-src/ebrowse.c (add_sym, add_member, make_namespace)
(register_namespace_alias):
* src/alloc.c (SDATA_SIZE, allocate_string_data):
* src/image.c (xpm_cache_color, imagemagick_create_cache):
* src/process.c (Fmake_network_process):
Use FLEXSIZEOF instead of offsetof and addition.
* src/alloc.c (SDATA_SIZE, vector_alignment):
Use FLEXALIGNOF instead of sizeof (ptrdiff_t).
* src/lisp.h (ALIGNOF_STRUCT_LISP_VECTOR):
Remove, as alloc.c can now calculate this on its own.
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/src/lisp.h b/src/lisp.h index 97c8d9fe84f..29ed9fe8a2d 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1429,13 +1429,6 @@ struct Lisp_Vector | |||
| 1429 | Lisp_Object contents[FLEXIBLE_ARRAY_MEMBER]; | 1429 | Lisp_Object contents[FLEXIBLE_ARRAY_MEMBER]; |
| 1430 | }; | 1430 | }; |
| 1431 | 1431 | ||
| 1432 | /* C11 prohibits alignof (struct Lisp_Vector), so compute it manually. */ | ||
| 1433 | enum | ||
| 1434 | { | ||
| 1435 | ALIGNOF_STRUCT_LISP_VECTOR | ||
| 1436 | = alignof (union { struct vectorlike_header a; Lisp_Object b; }) | ||
| 1437 | }; | ||
| 1438 | |||
| 1439 | /* A boolvector is a kind of vectorlike, with contents like a string. */ | 1432 | /* A boolvector is a kind of vectorlike, with contents like a string. */ |
| 1440 | 1433 | ||
| 1441 | struct Lisp_Bool_Vector | 1434 | struct Lisp_Bool_Vector |