stdalign: port to Clang 3.0
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 2 Dec 2011 09:34:53 +0000 (01:34 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 2 Dec 2011 09:35:51 +0000 (01:35 -0800)
Problem reported by Simon Josefsson in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-12/msg00005.html>.
* doc/posix-headers/stdalign.texi (stdalign.h): Mention Clang 3.0,
which has <stdalign.h> but which does not define alignof.
* m4/stdalign.m4 (gl_STDALIGN_H): Check for Clang 3.0's problem.

ChangeLog
doc/posix-headers/stdalign.texi
m4/stdalign.m4

index 5a616e7..1cb710a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-12-02  Paul Eggert  <eggert@cs.ucla.edu>
+
+       stdalign: port to Clang 3.0
+       Problem reported by Simon Josefsson in
+       <http://lists.gnu.org/archive/html/bug-gnulib/2011-12/msg00005.html>.
+       * doc/posix-headers/stdalign.texi (stdalign.h): Mention Clang 3.0,
+       which has <stdalign.h> but which does not define alignof.
+       * m4/stdalign.m4 (gl_STDALIGN_H): Check for Clang 3.0's problem.
+
 2011-12-01  Eric Blake  <eblake@redhat.com>
 
        mktempd: silence dd usage
index b3d39f0..bebc70d 100644 (file)
@@ -13,6 +13,8 @@ Portability problems fixed by Gnulib:
 @itemize
 @item
 This header file is missing on most circa-2011 platforms.
+@item
+Clang 3.0's @code{<stdalign.h>} does not define @code{alignof}/@code{_Alignof}.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index da64dc6..2641dce 100644 (file)
@@ -9,9 +9,24 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_STDALIGN_H],
 [
-  AC_CHECK_HEADERS_ONCE([stdalign.h])
+  AC_CACHE_CHECK([for working stdalign.h],
+    [gl_cv_header_working_stdalign_h],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <stdalign.h>
+            int align_int = alignof (int) + _Alignof (double);
 
-  if test $ac_cv_header_stdalign_h = yes; then
+            /* Test _Alignas only on platforms where gnulib can help.  */
+            #if \
+                (__GNUC__ || __IBMC__ || __IBMCPP__ \
+                 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
+              int alignas (8) alignas_int = 1;
+            #endif
+          ]])],
+       [gl_cv_header_working_stdalign_h=yes],
+       [gl_cv_header_working_stdalign_h=no])])
+
+  if test $gl_cv_header_working_stdalign_h = yes; then
     STDALIGN_H=''
   else
     STDALIGN_H='stdalign.h'