Files
oasis-linux-mirror/pkg/elftoolchain/patch/0002-Use-_Alignof-when-built-as-C11.patch

60 lines
1.5 KiB
Diff

From 7233abcc2902766760f9dd26217df159d4e6340a Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Tue, 2 Jul 2019 23:54:25 -0700
Subject: [PATCH] Use _Alignof when built as C11
---
libelf/libelf_align.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/libelf/libelf_align.c b/libelf/libelf_align.c
index c0cdce97..2150fea7 100644
--- a/libelf/libelf_align.c
+++ b/libelf/libelf_align.c
@@ -39,25 +39,38 @@ struct align {
unsigned int a64;
};
-#ifdef __GNUC__
+#if __STDC_VERSION__ >= 201112L
+#define MALIGN(N) { \
+ .a32 = _Alignof(Elf32_##N), \
+ .a64 = _Alignof(Elf64_##N) \
+ }
+#define MALIGN64(V) { \
+ .a32 = 0, \
+ .a64 = _Alignof(Elf64_##V) \
+ }
+#define MALIGN_WORD() { \
+ .a32 = _Alignof(int32_t), \
+ .a64 = _Alignof(int64_t) \
+ }
+#elif defined(__GNUC__)
#define MALIGN(N) { \
.a32 = __alignof__(Elf32_##N), \
.a64 = __alignof__(Elf64_##N) \
}
-#define MALIGN64(V) { \
+#define MALIGN64(V) { \
.a32 = 0, \
.a64 = __alignof__(Elf64_##V) \
}
#define MALIGN_WORD() { \
.a32 = __alignof__(int32_t), \
.a64 = __alignof__(int64_t) \
- }
+ }
#elif defined(__lint__)
#define MALIGN(N) { .a32 = 0, .a64 = 0 }
#define MALIGN64(N) { .a32 = 0, .a64 = 0 }
#define MALIGN_WORD(N) { .a32 = 0, .a64 = 0 }
#else
-#error Need the __alignof__ builtin.
+#error Need C11 _Alignof, or the __alignof__ builtin.
#endif
#define UNSUPPORTED() { \
.a32 = 0, \
--
2.31.1