bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

improve clang support (16)


From: Bruno Haible
Subject: improve clang support (16)
Date: Sun, 09 Aug 2020 18:13:30 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

clang has the __aligned__ attribute, like GCC.

The clang platforms I've tested have a working 'alignas' macro
and 'max_align_t' type. But if there should be a problem anytime,
the same workarounds can be used as for GCC.


2020-08-09  Bruno Haible  <bruno@clisp.org>

        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/lib/stdalign.in.h b/lib/stdalign.in.h
index 10eedc5..ad1bd00 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 d556ae8..19d0999 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]