From: Bruno Haible Date: Sun, 9 Aug 2020 16:12:36 +0000 (+0200) Subject: Use attribute __aligned__ with clang. X-Git-Tag: v1.0~3795 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=1dcad478e8f8a10335a0dbd6f02b08d1f351ce19;p=gnulib.git Use attribute __aligned__ with clang. * lib/stdalign.in.h (_Alignas): Treat clang like GCC. * lib/stddef.in.h (_GL_STDDEF_ALIGNAS): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 7347ea828b..7c8865e292 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-08-09 Bruno Haible + + Use attribute __aligned__ with clang. + * lib/stdalign.in.h (_Alignas): Treat clang like GCC. + * lib/stddef.in.h (_GL_STDDEF_ALIGNAS): Likewise. + 2020-08-09 Bruno Haible Use __alignof__ with clang. diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h index 10eedc550e..ad1bd008a1 100644 --- a/lib/stdalign.in.h +++ b/lib/stdalign.in.h @@ -104,8 +104,9 @@ # define _Alignas(a) alignas (a) # elif ((defined __APPLE__ && defined __MACH__ \ ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ - : __GNUC__ && !defined __ibmxl__) \ - || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \ + : __GNUC__ && !defined __ibmxl__) \ + || (4 <= __clang_major__) \ + || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \ || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__) # define _Alignas(a) __attribute__ ((__aligned__ (a))) # elif 1300 <= _MSC_VER diff --git a/lib/stddef.in.h b/lib/stddef.in.h index d556ae8796..19d09998d5 100644 --- a/lib/stddef.in.h +++ b/lib/stddef.in.h @@ -97,7 +97,7 @@ and the C11 standard allows this. Work around this problem by using __alignof__ (which returns 8 for double) rather than _Alignof (which returns 4), and align each union member accordingly. */ -# ifdef __GNUC__ +# if defined __GNUC__ || (__clang_major__ >= 4) # define _GL_STDDEF_ALIGNAS(type) \ __attribute__ ((__aligned__ (__alignof__ (type)))) # else