]> Savannah Git Hosting - gnulib.git/commitdiff
stdalign: port to tcc + glibc
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 4 Mar 2021 08:47:19 +0000 (00:47 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 4 Mar 2021 08:49:59 +0000 (00:49 -0800)
* lib/stdalign.in.h (_Alignas): Do not define using __attribute__
if __attribute__ is defined as a macro, as __attribute__ surely a
no-op in that case and this is an area where __attribute__ cannot
simply be ignored.
* m4/stdalign.m4 (gl_STDALIGN_H): Include <stdint.h> so that
it #defines __attribute__(x) to nothing on glibc-based systems
when non-GNU-C-compatible compilers are used.
This exposes a bug in Tiny C Compiler 0.9.27’s implementation
of _Alignas on glibc platforms.

ChangeLog
lib/stdalign.in.h
m4/stdalign.m4

index 9f6818c17e82abc2c9b2895fd7e51a368098c214..50d247fac0919fa3cd37d278ea9a8b792664aea5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2021-03-04  Paul Eggert  <eggert@cs.ucla.edu>
+
+       stdalign: port to tcc + glibc
+       * lib/stdalign.in.h (_Alignas): Do not define using __attribute__
+       if __attribute__ is defined as a macro, as __attribute__ surely a
+       no-op in that case and this is an area where __attribute__ cannot
+       simply be ignored.
+       * m4/stdalign.m4 (gl_STDALIGN_H): Include <stdint.h> so that
+       it #defines __attribute__(x) to nothing on glibc-based systems
+       when non-GNU-C-compatible compilers are used.
+       This exposes a bug in Tiny C Compiler 0.9.27’s implementation
+       of _Alignas on glibc platforms.
+
 2021-03-03  Bruno Haible  <bruno@clisp.org>
 
        asyncsafe-spin, simple-atomic: Add support for tcc/x86.
index e7a7402ee8dfa34ae6b0f8c4e4952a03b76dd9e2..52a4a7b6e734200692bfd7f6f32c98394f114cd2 100644 (file)
 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
 # if defined __cplusplus && 201103 <= __cplusplus
 #  define _Alignas(a) alignas (a)
-# elif ((defined __APPLE__ && defined __MACH__                  \
-         ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__)                 \
-         : __GNUC__ && !defined __ibmxl__)                      \
-        || (4 <= __clang_major__)                               \
-        || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC))  \
-        || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)
+# elif (!defined __attribute__ \
+        && ((defined __APPLE__ && defined __MACH__ \
+             ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
+             : __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
 #  define _Alignas(a) __declspec (align (a))
index 8dcb634d55b9ea4521fc8169faf71245b20c162f..e22d7f78c06e73d8ac422b40510bc949cb24caf4 100644 (file)
@@ -13,7 +13,8 @@ AC_DEFUN([gl_STDALIGN_H],
     [gl_cv_header_working_stdalign_h],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
-          [[#include <stdalign.h>
+          [[#include <stdint.h>
+            #include <stdalign.h>
             #include <stddef.h>
 
             /* Test that alignof yields a result consistent with offsetof.
@@ -32,6 +33,7 @@ AC_DEFUN([gl_STDALIGN_H],
             /* Test _Alignas only on platforms where gnulib can help.  */
             #if \
                 ((defined __cplusplus && 201103 <= __cplusplus) \
+                 || (__TINYC__ && defined __attribute__) \
                  || (defined __APPLE__ && defined __MACH__ \
                      ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
                      : __GNUC__) \