changeset 16140:7fae013a2fd6

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.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 02 Dec 2011 01:34:53 -0800
parents e4bb630139e4
children 39ebdfb411b2
files ChangeLog doc/posix-headers/stdalign.texi m4/stdalign.m4
diffstat 3 files changed, 28 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/doc/posix-headers/stdalign.texi
+++ b/doc/posix-headers/stdalign.texi
@@ -13,6 +13,8 @@
 @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:
--- a/m4/stdalign.m4
+++ b/m4/stdalign.m4
@@ -9,9 +9,24 @@
 
 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'