summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-03-04 00:47:19 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2021-03-04 00:49:59 -0800
commit3c55969da66ccb9e6c0d045261a246254ca4494c (patch)
tree7429d8bd346ca40e47c065e708398d0162ef0fce
parent7c748055361ce5e9400d4dd460df0b84c735eff4 (diff)
downloadgnulib-3c55969da66ccb9e6c0d045261a246254ca4494c.tar.gz
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.
-rw-r--r--ChangeLog13
-rw-r--r--lib/stdalign.in.h13
-rw-r--r--m4/stdalign.m44
3 files changed, 23 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 9f6818c17e..50d247fac0 100644
--- 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.
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index e7a7402ee8..52a4a7b6e7 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -104,12 +104,13 @@
#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))
diff --git a/m4/stdalign.m4 b/m4/stdalign.m4
index 8dcb634d55..e22d7f78c0 100644
--- a/m4/stdalign.m4
+++ b/m4/stdalign.m4
@@ -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__) \