diff options
| author | Khem Raj <raj.khem@gmail.com> | 2023-01-15 10:51:51 -0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-18 16:42:27 +0000 |
| commit | 307aea25a501407611b0f88c97a4455a9d21ef40 (patch) | |
| tree | 3108a4231bef8da43c1eaf96007fe81544f579a8 /meta/recipes-devtools | |
| parent | 376d0fdd0e107a56fa811b7ad6ba80d8dc6a1310 (diff) | |
| download | poky-307aea25a501407611b0f88c97a4455a9d21ef40.tar.gz | |
m4: Define alignof_slot using _Alignof when using C11 or newer
(From OE-Core rev: 6ab48834cfe852f7bc9a0fe412ff80de216f8247)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
| -rw-r--r-- | meta/recipes-devtools/m4/m4-1.4.19.inc | 1 | ||||
| -rw-r--r-- | meta/recipes-devtools/m4/m4/0001-Define-alignof_slot-using-_Alignof-when-using-C11-or.patch | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/meta/recipes-devtools/m4/m4-1.4.19.inc b/meta/recipes-devtools/m4/m4-1.4.19.inc index 6ee9742277..c098a4077e 100644 --- a/meta/recipes-devtools/m4/m4-1.4.19.inc +++ b/meta/recipes-devtools/m4/m4-1.4.19.inc | |||
| @@ -9,6 +9,7 @@ inherit autotools texinfo ptest gettext | |||
| 9 | SRC_URI = "${GNU_MIRROR}/m4/m4-${PV}.tar.gz \ | 9 | SRC_URI = "${GNU_MIRROR}/m4/m4-${PV}.tar.gz \ |
| 10 | file://ac_config_links.patch \ | 10 | file://ac_config_links.patch \ |
| 11 | file://0001-sigsegv-Fix-build-on-ppc-musl.patch \ | 11 | file://0001-sigsegv-Fix-build-on-ppc-musl.patch \ |
| 12 | file://0001-Define-alignof_slot-using-_Alignof-when-using-C11-or.patch \ | ||
| 12 | " | 13 | " |
| 13 | SRC_URI:append:class-target = " file://run-ptest \ | 14 | SRC_URI:append:class-target = " file://run-ptest \ |
| 14 | file://serial-tests-config.patch \ | 15 | file://serial-tests-config.patch \ |
diff --git a/meta/recipes-devtools/m4/m4/0001-Define-alignof_slot-using-_Alignof-when-using-C11-or.patch b/meta/recipes-devtools/m4/m4/0001-Define-alignof_slot-using-_Alignof-when-using-C11-or.patch new file mode 100644 index 0000000000..8757abd7a0 --- /dev/null +++ b/meta/recipes-devtools/m4/m4/0001-Define-alignof_slot-using-_Alignof-when-using-C11-or.patch | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | From b0fd3a58354b1f5ead891907979dfd3dd36840d5 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Sat, 14 Jan 2023 14:55:03 -0800 | ||
| 4 | Subject: [PATCH] Define alignof_slot using _Alignof when using C11 or newer | ||
| 5 | |||
| 6 | WG14 N2350 made very clear that it is an UB having type definitions | ||
| 7 | within "offsetof" [1]. This patch enhances the implementation of macro | ||
| 8 | alignof_slot to use builtin "_Alignof" to avoid undefined behavior on | ||
| 9 | when using std=c11 or newer | ||
| 10 | |||
| 11 | clang 16+ has started to flag this [2] | ||
| 12 | |||
| 13 | Fixes build when using -std >= gnu11 and using clang16+ [3] | ||
| 14 | |||
| 15 | [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm | ||
| 16 | [2] https://reviews.llvm.org/D133574 | ||
| 17 | [3] https://public-inbox.org/bug-gnulib/20230114232744.215167-1-raj.khem@gmail.com/T/#u | ||
| 18 | |||
| 19 | Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=2d404c7dd974cc65f894526f4a1b76bc1dcd8d82] | ||
| 20 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 21 | --- | ||
| 22 | lib/alignof.h | 2 ++ | ||
| 23 | 1 file changed, 2 insertions(+) | ||
| 24 | |||
| 25 | --- a/lib/alignof.h | ||
| 26 | +++ b/lib/alignof.h | ||
| 27 | @@ -18,19 +18,19 @@ | ||
| 28 | #define _ALIGNOF_H | ||
| 29 | |||
| 30 | #include <stddef.h> | ||
| 31 | +#include "stdalign.h" | ||
| 32 | |||
| 33 | /* alignof_slot (TYPE) | ||
| 34 | Determine the alignment of a structure slot (field) of a given type, | ||
| 35 | at compile time. Note that the result depends on the ABI. | ||
| 36 | - This is the same as alignof (TYPE) and _Alignof (TYPE), defined in | ||
| 37 | - <stdalign.h> if __alignof_is_defined is 1. | ||
| 38 | + This is the same as alignof (TYPE). | ||
| 39 | Note: The result cannot be used as a value for an 'enum' constant, | ||
| 40 | due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */ | ||
| 41 | #if defined __cplusplus | ||
| 42 | template <class type> struct alignof_helper { char __slot1; type __slot2; }; | ||
| 43 | # define alignof_slot(type) offsetof (alignof_helper<type>, __slot2) | ||
| 44 | #else | ||
| 45 | -# define alignof_slot(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) | ||
| 46 | +# define alignof_slot(type) alignof (type) | ||
| 47 | #endif | ||
| 48 | |||
| 49 | /* alignof_type (TYPE) | ||
