]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
Add syntax-check rule against CPU predef misspellings.
authorBruno Haible <bruno@clisp.org>
Wed, 7 May 2025 09:34:47 +0000 (11:34 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 7 May 2025 09:34:47 +0000 (11:34 +0200)
* lib/getloadavg.c: Test __alpha, not __alpha__.
* tests/test-snan-2.c: Likewise.
* m4/exponentd.m4: Test __arm__, not __arm.
* lib/utimensat.c: Test __hppa, not __hppa__.
* tests/qemu.h: Likewise.
* lib/fma.c: Test __sparc, not __sparc__.
* tests/qemu.h: Likewise.
* tests/test-exp2.h: Likewise.
* tests/test-nonblocking-pipe.h: Likewise.
* tests/test-snan-1.c: Likewise.
* tests/test-snan-2.c: Likewise.

ChangeLog
Makefile
lib/fma.c
lib/getloadavg.c
lib/utimensat.c
m4/exponentd.m4
tests/qemu.h
tests/test-exp2.h
tests/test-nonblocking-pipe.h
tests/test-snan-1.c
tests/test-snan-2.c

index a430ffd406e7eb00162c28b1a27eb682c53aef69..450aa55dba34b54c6c4f0336e757dcd3c47b0d3e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2025-05-07  Bruno Haible  <bruno@clisp.org>
 
+       Add syntax-check rule against CPU predef misspellings.
+       * lib/getloadavg.c: Test __alpha, not __alpha__.
+       * tests/test-snan-2.c: Likewise.
+       * m4/exponentd.m4: Test __arm__, not __arm.
+       * lib/utimensat.c: Test __hppa, not __hppa__.
+       * tests/qemu.h: Likewise.
+       * lib/fma.c: Test __sparc, not __sparc__.
+       * tests/qemu.h: Likewise.
+       * tests/test-exp2.h: Likewise.
+       * tests/test-nonblocking-pipe.h: Likewise.
+       * tests/test-snan-1.c: Likewise.
+       * tests/test-snan-2.c: Likewise.
+
        Add syntax-check rule against OS predef misspellings.
        * Makefile (sc_prohibit_misspelled_os_predefs): New target.
        * lib/stat-size.h: Simplify detection of HP-UX.
index 7ed889138a3ebdcc520f18e0419a261dc7f04a8b..0ffc6779467022d064f7ab6cc26fdf9a09f26ac8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -70,6 +70,36 @@ misspelled_compiler_predefs =\
   __GNUC_MAJOR__       \
   __GNUC_MINOR         \
 
+# Cf. <https://github.com/cpredef/predef/blob/master/Architectures.md>
+# Only the users of module 'host-cpu-c-abi' are allowed to use __${arch}__
+# for all architectures.
+sc_prohibit_misspelled_cpu_predefs:
+       if test -d .git; then                                           \
+         git ls-files m4 lib tests                                     \
+           | grep -Ev '^(m4/host-cpu-c-abi\.m4|lib/sigsegv\.(in\.h|c)|tests/test-sigsegv.*|tests/jit/test-cache\.c)$$' \
+           | xargs grep -Ew '($(misspelled_cpu_predefs_or))'           \
+           && { printf '*** %s\n' 'misspelled predefs' 1>&2; exit 1; } \
+           || :                                                        \
+       else :; fi
+misspelled_cpu_predefs_or = $(shell echo $(misspelled_cpu_predefs) | tr -s ' ' '|')
+misspelled_cpu_predefs =\
+  __alpha__            \
+  __amd64              \
+  __x86_64             \
+  __arm                        \
+  __arm64              \
+  __arm64__            \
+  __aarch64            \
+  __hppa__             \
+  __loongarch64__      \
+  __m68k               \
+  __riscv__            \
+  __riscv64            \
+  __riscv64__          \
+  __sparc__            \
+  __sparc64            \
+  __sparc64__          \
+
 # Cf. <https://github.com/cpredef/predef/blob/master/OperatingSystems.md>
 sc_prohibit_misspelled_os_predefs:
        if test -d .git; then                                           \
index c812f3cea041a78f429a8be2d619a8a0b968b5d7..63108d6fed44ee4381482b2719c40eb18f89fbb4 100644 (file)
--- a/lib/fma.c
+++ b/lib/fma.c
@@ -72,7 +72,7 @@
 #endif
 
 /* Work around GCC 4.2.1 bug on OpenBSD 5.1/SPARC64.  */
-#if defined __GNUC__ && defined __sparc__
+#if defined __GNUC__ && defined __sparc
 # define VOLATILE volatile
 #else
 # define VOLATILE
index b4fb169182acbd519352ee8d61595db7e9be2f2e..752ec1f5ae7071c6f699f2d9fe0a5ac87ee50623 100644 (file)
 #  define SUNOS_5
 # endif
 
-# if defined (__osf__) && (defined (__alpha) || defined (__alpha__))
+# if defined (__osf__) && defined (__alpha)
 #  define OSF_ALPHA
 #  include <sys/mbuf.h>
 #  include <sys/socket.h>
index ca1d39e59005828916719bbf79db0c8bd9e7bd13..fcf2d27eb3eb98e509a384f27630cd1d84864a5a 100644 (file)
@@ -118,7 +118,7 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
             ts[1] = times[1];
           times = ts;
         }
-#   if defined __hppa__ || defined __NetBSD__
+#   if defined __hppa || defined __NetBSD__
       /* Linux kernel 2.6.22.19 on hppa does not reject invalid tv_nsec
          values.
 
index 182a0814a8be42070b3f4ecdef084a39721bff0d..08e933970fb2183d26c7f313525f7df8d3023788 100644 (file)
@@ -1,5 +1,5 @@
 # exponentd.m4
-# serial 4
+# serial 5
 dnl Copyright (C) 2007-2008, 2010-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,
@@ -85,7 +85,7 @@ int main ()
           dnl The newer VFP instructions assume little-endian order
           dnl consistently.
           AC_EGREP_CPP([mixed_endianness], [
-#if defined arm || defined __arm || defined __arm__
+#if defined __arm__
   mixed_endianness
 #endif
             ],
index f565f007359958badeef1d655ca9015ecb4c3308..88dbfbf38efe07d7c23c631969de8a88563f69ac 100644 (file)
@@ -65,7 +65,7 @@ is_running_under_qemu_user (void)
       if (n > 0)
         {
           buf[n] = '\0';
-# if defined __hppa__
+# if defined __hppa
           if (strstr (buf, "QEMU") != NULL)
             return true;
 # endif
@@ -79,7 +79,7 @@ is_running_under_qemu_user (void)
               || strcasestr (buf, "aarch64") != NULL)
             return true;
 # endif
-# if !defined __sparc__
+# if !defined __sparc
           if (strcasestr (buf, "SPARC") != NULL)
             return true;
 # endif
index 7a8e238f4000f1afb4e9ee00cd0b6c7942a4c10b..bed46a2daca0e90cab121fffaec047103a118a0c 100644 (file)
@@ -36,7 +36,7 @@ test_function (void)
     ASSERT (y == L_(1.0));
   }
   /* <https://sourceware.org/bugzilla/show_bug.cgi?id=13824> */
-#if !(__GLIBC__ == 2 && __GLIBC_MINOR__ < 16 && (defined __sparc__ || defined __powerpc__))
+#if !(__GLIBC__ == 2 && __GLIBC_MINOR__ < 16 && (defined __sparc || defined __powerpc__))
   {
     int e;
     DOUBLE x;
index 42c24b18dda9e7fa54d3d10c880e889827bf8f03..db4e59a31f4c0e8a8d47c5d61775d67de00baa05 100644 (file)
@@ -37,7 +37,7 @@
  */
 #if defined __MVS__ || defined __osf__ || (defined __linux__ && (defined __ia64__ || defined __mips__))
 # define PIPE_DATA_BLOCK_SIZE 270000
-#elif defined __linux__ && defined __sparc__
+#elif defined __linux__ && defined __sparc
 # define PIPE_DATA_BLOCK_SIZE 140000
 #elif defined __linux__ && defined __powerpc__
 # define PIPE_DATA_BLOCK_SIZE 1100000
index 42228c3ee7bd642991e54c214ca0aca031dd3150..a958e9af0bc5936f3ab98549f320e1ac8218f556 100644 (file)
@@ -90,7 +90,7 @@ main ()
      This test does not work on MSVC/i386, because of the general IA-32
      problem (see above) and 'long double' == 'double'.  */
   #if !((((__GLIBC__ == 2 && __GLIBC_MINOR__ < 19 && defined __mips64) \
-          || ((defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__) && (defined __aarch64__ || defined __mips64__ || defined __sparc__))) \
+          || ((defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__) && (defined __aarch64__ || defined __mips64__ || defined __sparc))) \
          && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE) \
         || ((defined __i386 || defined _M_IX86) && HAVE_SAME_LONG_DOUBLE_AS_DOUBLE))
   {
index 4586c2d9af28c01f0ccdde57bd019908f588486e..b423b12f84b7b9414d13531b064d2096194b2575 100644 (file)
@@ -115,10 +115,10 @@ main (int argc, char *argv[])
            This test does not work on Cygwin 2.9.0/i386. Cause unknown.
            This test does not work on MSVC/i386, because of the general IA-32
            problem (see above) and 'long double' == 'double'.  */
-        #if !((__GLIBC__ == 2 && __GLIBC_MINOR__ < 36 && defined __alpha__) \
+        #if !((__GLIBC__ == 2 && __GLIBC_MINOR__ < 36 && defined __alpha) \
               || (__GLIBC__ >= 2 && defined __loongarch__) \
               || (((__GLIBC__ == 2 && __GLIBC_MINOR__ < 19 && defined __mips64) \
-                   || ((defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__) && (defined __aarch64__ || defined __mips64__ || defined __sparc__))) \
+                   || ((defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__) && (defined __aarch64__ || defined __mips64__ || defined __sparc))) \
                   && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE) \
               || (defined __CYGWIN__ && defined __i386) \
               || (((defined __i386 || defined _M_IX86) \