# HG changeset patch # User Paul Eggert # Date 1322818493 28800 # Node ID 7fae013a2fd6d99c542712de6a2a9a47837e6eb9 # Parent e4bb630139e4fc4bec3d208c8a9e863eb4239509 stdalign: port to Clang 3.0 Problem reported by Simon Josefsson in . * doc/posix-headers/stdalign.texi (stdalign.h): Mention Clang 3.0, which has but which does not define alignof. * m4/stdalign.m4 (gl_STDALIGN_H): Check for Clang 3.0's problem. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-12-02 Paul Eggert + + stdalign: port to Clang 3.0 + Problem reported by Simon Josefsson in + . + * doc/posix-headers/stdalign.texi (stdalign.h): Mention Clang 3.0, + which has but which does not define alignof. + * m4/stdalign.m4 (gl_STDALIGN_H): Check for Clang 3.0's problem. + 2011-12-01 Eric Blake mktempd: silence dd usage diff --git a/doc/posix-headers/stdalign.texi b/doc/posix-headers/stdalign.texi --- 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{} does not define @code{alignof}/@code{_Alignof}. @end itemize Portability problems not fixed by Gnulib: diff --git a/m4/stdalign.m4 b/m4/stdalign.m4 --- 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 + 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'