]> Savannah Git Hosting - gnulib.git/commitdiff
alignasof tests: Rename test file.
authorBruno Haible <bruno@clisp.org>
Sat, 21 Jan 2023 09:07:19 +0000 (10:07 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 21 Jan 2023 09:07:19 +0000 (10:07 +0100)
* tests/test-alignasof.c: Renamed from tests/test-stdalign.c.
* modules/alignasof-tests (Files, Makefile.am): Update accordingly.

ChangeLog
modules/alignasof-tests
tests/test-alignasof.c [new file with mode: 0644]
tests/test-stdalign.c [deleted file]

index ac0509b30fe77ca818dc38c1492f564ecf3e3b80..1de0058d5e7598dc063e74577c2569ba196385ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-21  Bruno Haible  <bruno@clisp.org>
+
+       alignasof tests: Rename test file.
+       * tests/test-alignasof.c: Renamed from tests/test-stdalign.c.
+       * modules/alignasof-tests (Files, Makefile.am): Update accordingly.
+
 2023-01-21  Bruno Haible  <bruno@clisp.org>
 
        alignasof tests: Fix GCC warning (regression 2023-01-15).
index 95602c2fef861fd53eb5a711eb0828b92f692846..35bef17b99518b64df3b8b73660e966e47fb0d0b 100644 (file)
@@ -1,5 +1,5 @@
 Files:
-tests/test-stdalign.c
+tests/test-alignasof.c
 tests/macros.h
 
 Depends-on:
@@ -9,5 +9,5 @@ stdint
 configure.ac:
 
 Makefile.am:
-TESTS += test-stdalign
-check_PROGRAMS += test-stdalign
+TESTS += test-alignasof
+check_PROGRAMS += test-alignasof
diff --git a/tests/test-alignasof.c b/tests/test-alignasof.c
new file mode 100644 (file)
index 0000000..18c0d48
--- /dev/null
@@ -0,0 +1,100 @@
+/* Test of alignasof module.
+   Copyright 2009-2023 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
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Paul Eggert, inspired by Bruno Haible's test-alignof.c.  */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "macros.h"
+
+typedef long double longdouble;
+typedef struct { char a[1]; } struct1;
+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)
+/* 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
+
+#define CHECK_STATIC(type) \
+  typedef struct { char slot1; type slot2; } type##_helper; \
+  static_assert (alignof (type) == offsetof (type##_helper, slot2)); \
+  const int type##_alignment = alignof (type); \
+  type alignas (TEST_ALIGNMENT) static_##type##_alignas
+
+#define CHECK_ALIGNED(var) ASSERT ((uintptr_t) &(var) % TEST_ALIGNMENT == 0)
+
+CHECK_STATIC (char);
+CHECK_STATIC (short);
+CHECK_STATIC (int);
+CHECK_STATIC (long);
+#ifdef INT64_MAX
+CHECK_STATIC (int64_t);
+#endif
+CHECK_STATIC (float);
+CHECK_STATIC (double);
+/* CHECK_STATIC (longdouble); */
+CHECK_STATIC (struct1);
+CHECK_STATIC (struct2);
+CHECK_STATIC (struct3);
+CHECK_STATIC (struct4);
+
+int
+main ()
+{
+#if defined __SUNPRO_C && __SUNPRO_C < 0x5150
+  /* Avoid a test failure due to Sun Studio Developer Bug Report #2125432.  */
+  fputs ("Skipping test: known Sun C compiler bug\n", stderr);
+  return 77;
+#elif defined __HP_cc && __ia64
+  /* Avoid a test failure due to HP-UX Itanium cc bug; see:
+     https://lists.gnu.org/r/bug-gnulib/2017-03/msg00078.html  */
+  fputs ("Skipping test: known HP-UX Itanium cc compiler bug\n", stderr);
+  return 77;
+#elif defined __clang__ && defined __ibmxl__
+  /* Avoid a test failure with IBM xlc 16.1.  It ignores alignas (8),
+     _Alignas (8), and __attribute__ ((__aligned__ (8))).  */
+  fputs ("Skipping test: known AIX XL C compiler deficiency\n", stderr);
+  return 77;
+#else
+  CHECK_ALIGNED (static_char_alignas);
+  CHECK_ALIGNED (static_short_alignas);
+  CHECK_ALIGNED (static_int_alignas);
+  CHECK_ALIGNED (static_long_alignas);
+# ifdef INT64_MAX
+  CHECK_ALIGNED (static_int64_t_alignas);
+# endif
+  CHECK_ALIGNED (static_float_alignas);
+  CHECK_ALIGNED (static_double_alignas);
+  /* CHECK_ALIGNED (static_longdouble_alignas); */
+  CHECK_ALIGNED (static_struct1_alignas);
+  CHECK_ALIGNED (static_struct2_alignas);
+  CHECK_ALIGNED (static_struct3_alignas);
+  CHECK_ALIGNED (static_struct4_alignas);
+  return 0;
+#endif
+}
diff --git a/tests/test-stdalign.c b/tests/test-stdalign.c
deleted file mode 100644 (file)
index 85008e6..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* Test of <stdalign.h>.
-   Copyright 2009-2023 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
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
-
-/* Written by Paul Eggert, inspired by Bruno Haible's test-alignof.c.  */
-
-#include <config.h>
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "macros.h"
-
-typedef long double longdouble;
-typedef struct { char a[1]; } struct1;
-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)
-/* 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
-
-#define CHECK_STATIC(type) \
-  typedef struct { char slot1; type slot2; } type##_helper; \
-  static_assert (alignof (type) == offsetof (type##_helper, slot2)); \
-  const int type##_alignment = alignof (type); \
-  type alignas (TEST_ALIGNMENT) static_##type##_alignas
-
-#define CHECK_ALIGNED(var) ASSERT ((uintptr_t) &(var) % TEST_ALIGNMENT == 0)
-
-CHECK_STATIC (char);
-CHECK_STATIC (short);
-CHECK_STATIC (int);
-CHECK_STATIC (long);
-#ifdef INT64_MAX
-CHECK_STATIC (int64_t);
-#endif
-CHECK_STATIC (float);
-CHECK_STATIC (double);
-/* CHECK_STATIC (longdouble); */
-CHECK_STATIC (struct1);
-CHECK_STATIC (struct2);
-CHECK_STATIC (struct3);
-CHECK_STATIC (struct4);
-
-int
-main ()
-{
-#if defined __SUNPRO_C && __SUNPRO_C < 0x5150
-  /* Avoid a test failure due to Sun Studio Developer Bug Report #2125432.  */
-  fputs ("Skipping test: known Sun C compiler bug\n", stderr);
-  return 77;
-#elif defined __HP_cc && __ia64
-  /* Avoid a test failure due to HP-UX Itanium cc bug; see:
-     https://lists.gnu.org/r/bug-gnulib/2017-03/msg00078.html  */
-  fputs ("Skipping test: known HP-UX Itanium cc compiler bug\n", stderr);
-  return 77;
-#elif defined __clang__ && defined __ibmxl__
-  /* Avoid a test failure with IBM xlc 16.1.  It ignores alignas (8),
-     _Alignas (8), and __attribute__ ((__aligned__ (8))).  */
-  fputs ("Skipping test: known AIX XL C compiler deficiency\n", stderr);
-  return 77;
-#else
-  CHECK_ALIGNED (static_char_alignas);
-  CHECK_ALIGNED (static_short_alignas);
-  CHECK_ALIGNED (static_int_alignas);
-  CHECK_ALIGNED (static_long_alignas);
-# ifdef INT64_MAX
-  CHECK_ALIGNED (static_int64_t_alignas);
-# endif
-  CHECK_ALIGNED (static_float_alignas);
-  CHECK_ALIGNED (static_double_alignas);
-  /* CHECK_ALIGNED (static_longdouble_alignas); */
-  CHECK_ALIGNED (static_struct1_alignas);
-  CHECK_ALIGNED (static_struct2_alignas);
-  CHECK_ALIGNED (static_struct3_alignas);
-  CHECK_ALIGNED (static_struct4_alignas);
-  return 0;
-#endif
-}