logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0002-Use-_Alignof-when-built-as-C11.patch (1542B)


  1. From 7233abcc2902766760f9dd26217df159d4e6340a Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Tue, 2 Jul 2019 23:54:25 -0700
  4. Subject: [PATCH] Use _Alignof when built as C11
  5. ---
  6. libelf/libelf_align.c | 21 +++++++++++++++++----
  7. 1 file changed, 17 insertions(+), 4 deletions(-)
  8. diff --git a/libelf/libelf_align.c b/libelf/libelf_align.c
  9. index c0cdce97..2150fea7 100644
  10. --- a/libelf/libelf_align.c
  11. +++ b/libelf/libelf_align.c
  12. @@ -39,25 +39,38 @@ struct align {
  13. unsigned int a64;
  14. };
  15. -#ifdef __GNUC__
  16. +#if __STDC_VERSION__ >= 201112L
  17. +#define MALIGN(N) { \
  18. + .a32 = _Alignof(Elf32_##N), \
  19. + .a64 = _Alignof(Elf64_##N) \
  20. + }
  21. +#define MALIGN64(V) { \
  22. + .a32 = 0, \
  23. + .a64 = _Alignof(Elf64_##V) \
  24. + }
  25. +#define MALIGN_WORD() { \
  26. + .a32 = _Alignof(int32_t), \
  27. + .a64 = _Alignof(int64_t) \
  28. + }
  29. +#elif defined(__GNUC__)
  30. #define MALIGN(N) { \
  31. .a32 = __alignof__(Elf32_##N), \
  32. .a64 = __alignof__(Elf64_##N) \
  33. }
  34. -#define MALIGN64(V) { \
  35. +#define MALIGN64(V) { \
  36. .a32 = 0, \
  37. .a64 = __alignof__(Elf64_##V) \
  38. }
  39. #define MALIGN_WORD() { \
  40. .a32 = __alignof__(int32_t), \
  41. .a64 = __alignof__(int64_t) \
  42. - }
  43. + }
  44. #elif defined(__lint__)
  45. #define MALIGN(N) { .a32 = 0, .a64 = 0 }
  46. #define MALIGN64(N) { .a32 = 0, .a64 = 0 }
  47. #define MALIGN_WORD(N) { .a32 = 0, .a64 = 0 }
  48. #else
  49. -#error Need the __alignof__ builtin.
  50. +#error Need C11 _Alignof, or the __alignof__ builtin.
  51. #endif
  52. #define UNSUPPORTED() { \
  53. .a32 = 0, \
  54. --
  55. 2.31.1