]> Savannah Git Hosting - gnulib.git/commitdiff
alignasof: port to IBM XL C 16.1
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Jan 2025 06:06:55 +0000 (22:06 -0800)
committerBruno Haible <bruno@clisp.org>
Sun, 2 Feb 2025 09:38:10 +0000 (10:38 +0100)
* doc/gnulib.texi (alignof):
Improve doc to match implementation better.
* m4/stdalign.m4 (alignas): Do not define to _Alignas
if __xlC__ claims to conform to C11, because _Alignas fails with
weird diagnostics "Unexpected text %1$s encountered."
* tests/test-alignasof.c (TEST_ALIGNMENT, alignas):
Follow doc advice.

ChangeLog
doc/gnulib.texi
m4/stdalign.m4
tests/test-alignasof.c

index 26cc55b97d068718fdfdbecedf055580a2e9396a..7e86d07f8fcddaafc115c62beb786f5d4c6ca6ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2025-01-18  Paul Eggert  <eggert@cs.ucla.edu>
+
+       alignasof: port to IBM XL C 16.1
+       * doc/gnulib.texi (alignof):
+       Improve doc to match implementation better.
+       * m4/stdalign.m4 (alignas): Do not define to _Alignas
+       if __xlC__ claims to conform to C11, because _Alignas fails with
+       weird diagnostics "Unexpected text %1$s encountered."
+       * tests/test-alignasof.c (TEST_ALIGNMENT, alignas):
+       Follow doc advice.
+
 2025-01-18  Collin Funk  <collin.funk1@gmail.com>
 
        renameatu: Work around a GNU/Hurd bug.
index 81f8399d59b884f220290a7425420e5f2ac0e32c..5eed50d4e074885e76e868af993ba415c6329f9d 100644 (file)
@@ -970,9 +970,6 @@ to be more like standard C@.
 
 Portability problems fixed by Gnulib:
 @itemize
-@item
-Pre-C11 platforms lack @code{alignas} and @code{alignof}.
-
 @item
 On pre-C23 platforms, @code{<stdalign.h>} must be included before
 using @code{alignas} or @code{alignof}.
@@ -981,6 +978,26 @@ using @code{alignas} or @code{alignof}.
 
 Portability problems not fixed by Gnulib:
 @itemize
+@item
+The set of alignments supported by @code{alignas} is implementation
+dependent, and implementations need not support alignments greater
+than @code{alignof (max_align_t)}.
+
+@item
+Some older platforms do not support @code{alignas}.
+To test this, use the @code{alignasof} module
+along with the @code{#if} conditional
+@code{(defined alignas || defined __alignas_is_defined
+|| 202311 <= __STDC_VERSION__ || 201103 <= __cplusplus)}.
+Platforms where @code{alignas} does not work include:
+IBM XL C for AIX V16.1.
+
+@item
+On some platforms, the argument of @code{alignas} must be an integer
+constant like @samp{8}, instead of an integer constant expression
+like @samp{4 + 4} that evaluates to 8:
+GCC 4.9.
+
 @item
 On pre-C23 platforms, @code{alignas} and @code{alignof} are macros.
 @end itemize
index bd4ec12e89cafe4d162d620f74c982a75483b882..885feafdd8b16982e5677a432ad095b4d94c0839 100644 (file)
@@ -1,5 +1,5 @@
 # stdalign.m4
-# serial 2
+# serial 3
 dnl Copyright 2011-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -181,7 +181,8 @@ AC_DEFUN([gl_ALIGNASOF],
 #  if ((defined _Alignas \
         && !(defined __cplusplus \
              && (201103 <= __cplusplus || defined _MSC_VER))) \
-       || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
+       || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__ \
+           && !defined __xlC__))
 #   define alignas _Alignas
 #  endif
 # endif
index 638b4be2814ad322836eafb095b6c84b40507e12..b0c74f848ff86b47ff253bac79b14b40b7e18934 100644 (file)
@@ -29,13 +29,12 @@ typedef struct { char a[2]; } struct2;
 typedef struct { char a[3]; } struct3;
 typedef struct { char a[4]; } struct4;
 
-#if (202311 <= __STDC_VERSION__ || __alignas_is_defined \
-     || 201103 <= __cplusplus)
+#if (defined alignas || __alignas_is_defined \
+     || 202311 <= __STDC_VERSION__ || 201103 <= __cplusplus)
 /* mingw can go up only to 8.  8 is all that GNU Emacs needs, so let's
    limit the test to 8 for now.  */
 # define TEST_ALIGNMENT 8
 #else
-# undef alignas
 # define alignas(alignment)
 # define TEST_ALIGNMENT 1
 #endif