]> 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:55:18 +0000 (10:55 +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 862f154fa819797081ab59b95b515dc195c5215e..55e4b6db6617eba1025e393f69d4d342f81b5771 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 b6ce2c653d7be1d12875d0615e60860d8b718422..d9b6640ad251dd9d7fa8ca1e9da27dfb59c9a2a2 100644 (file)
@@ -940,9 +940,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}.
@@ -951,6 +948,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 07599cc6daf09114b4b3b0835af96ae436cd446f..2d11e080892fcf3730222fd2f69c0d4f87040960 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,
@@ -180,7 +180,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 12f695666431784bca5c757962325731078c49ac..b0c74f848ff86b47ff253bac79b14b40b7e18934 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of alignasof module.
-   Copyright 2009-2024 Free Software Foundation, Inc.
+   Copyright 2009-2025 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -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