]> Savannah Git Hosting - gnulib.git/commitdiff
isnanl, isfinite, snan: Improve cross-compilation guess.
authorBruno Haible <bruno@clisp.org>
Mon, 14 Apr 2025 09:37:25 +0000 (11:37 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 14 Apr 2025 09:37:25 +0000 (11:37 +0200)
* m4/exponentl.m4 (gl_LONG_DOUBLE_EXPONENT_LOCATION): When
cross-compiling, invoke gl_LONG_DOUBLE_VS_DOUBLE and
gl_DOUBLE_EXPONENT_LOCATION, and guess the result depending on the CPU.
* modules/getpayloadl (Depends-on): Add exponentd.m4, math_h.m4.
* modules/isfinite (Depends-on): Likewise.
* modules/isnanl (Depends-on): Likewise.
* modules/setpayloadl (Depends-on): Likewise.
* modules/setpayloadsigl (Depends-on): Likewise.
* modules/isnanl-nolibm (Depends-on): Add exponentd.m4.

ChangeLog
m4/exponentl.m4
modules/getpayloadl
modules/isfinite
modules/isnanl
modules/isnanl-nolibm
modules/setpayloadl
modules/setpayloadsigl

index 210be85262136a9080aa1064c99d34463be68edc..bdbf12b53585c4fde2c18856ef7b4c887a5a4b60 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2025-04-14  Bruno Haible  <bruno@clisp.org>
+
+       isnanl, isfinite, snan: Improve cross-compilation guess.
+       * m4/exponentl.m4 (gl_LONG_DOUBLE_EXPONENT_LOCATION): When
+       cross-compiling, invoke gl_LONG_DOUBLE_VS_DOUBLE and
+       gl_DOUBLE_EXPONENT_LOCATION, and guess the result depending on the CPU.
+       * modules/getpayloadl (Depends-on): Add exponentd.m4, math_h.m4.
+       * modules/isfinite (Depends-on): Likewise.
+       * modules/isnanl (Depends-on): Likewise.
+       * modules/setpayloadl (Depends-on): Likewise.
+       * modules/setpayloadsigl (Depends-on): Likewise.
+       * modules/isnanl-nolibm (Depends-on): Add exponentd.m4.
+
 2025-04-13  Paul Eggert  <eggert@cs.ucla.edu>
 
        regex: pacify gcc -Wcalloc-transposed-args
index 7e147ecceea27b58127a1de759591a61b91317c0..a52e996b5e0192127a90a8db55ef93d666a9c2f1 100644 (file)
@@ -1,5 +1,5 @@
 # exponentl.m4
-# serial 7
+# serial 8
 dnl Copyright (C) 2007-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,
@@ -81,24 +81,94 @@ int main ()
         [gl_cv_cc_long_double_expbit0="unknown"],
         [
           dnl When cross-compiling, in general we don't know. It depends on the
-          dnl ABI and compiler version. There are too many cases.
-          gl_cv_cc_long_double_expbit0="unknown"
-          case "$host_os" in
-            mingw* | windows*)
-              # On native Windows (little-endian), we know the result
-              # in two cases: mingw, MSVC.
-              AC_EGREP_CPP([Known], [
-#ifdef __MINGW32__
- Known
-#endif
-                ], [gl_cv_cc_long_double_expbit0="word 2 bit 0"])
-              AC_EGREP_CPP([Known], [
-#ifdef _MSC_VER
- Known
-#endif
-                ], [gl_cv_cc_long_double_expbit0="word 1 bit 20"])
-              ;;
-          esac
+          dnl ABI and compiler version. But we know the results for specific
+          dnl CPUs.
+          AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
+          if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
+            gl_DOUBLE_EXPONENT_LOCATION
+            gl_cv_cc_long_double_expbit0="$gl_cv_cc_double_expbit0"
+            if test "$gl_cv_cc_double_expbit0" = unknown; then
+              case "$host_cpu" in
+                arm*)
+                  # See the comments in exponentd.m4.
+                  ;;
+                aarch64 | sh4)
+                  # little-endian IEEE 754 double-precision
+                  gl_cv_cc_long_double_expbit0='word 1 bit 20'
+                  ;;
+                hppa*)
+                  # big-endian IEEE 754 double-precision
+                  gl_cv_cc_long_double_expbit0='word 0 bit 20'
+                  ;;
+                mips*)
+                  AC_COMPILE_IFELSE(
+                    [AC_LANG_PROGRAM([[
+                       #if defined _MIPSEB /* equivalent: __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ */
+                       int big;
+                       #else
+                       #error little
+                       #endif
+                       ]], [[]])
+                    ],
+                    [# big-endian IEEE 754 double-precision
+                     gl_cv_cc_long_double_expbit0='word 0 bit 20'
+                    ],
+                    [# little-endian IEEE 754 double-precision
+                     gl_cv_cc_long_double_expbit0='word 1 bit 20'
+                    ])
+                  ;;
+              esac
+            fi
+          else
+            case "$host_cpu" in
+changequote(,)dnl
+              i[34567]86 | x86_64 | ia64*)
+changequote([,])dnl
+                # 80-bits "extended precision"
+                gl_cv_cc_long_double_expbit0='word 2 bit 0'
+                ;;
+              m68k*)
+                # big-endian, 80-bits padded to 96 bits, non-IEEE exponent
+                gl_cv_cc_long_double_expbit0='word 0 bit 16'
+                ;;
+              alpha* | arm* | aarch64 | loongarch64 | riscv32 | riscv64 | sh4)
+                # little-endian IEEE 754 quadruple-precision
+                gl_cv_cc_long_double_expbit0='word 3 bit 16'
+                ;;
+              s390* | sparc | sparc64)
+                # big-endian IEEE 754 quadruple-precision
+                gl_cv_cc_long_double_expbit0='word 0 bit 16'
+                ;;
+              mips*)
+                AC_COMPILE_IFELSE(
+                  [AC_LANG_PROGRAM([[
+                     #if defined _MIPSEB /* equivalent: __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ */
+                     int big;
+                     #else
+                     #error little
+                     #endif
+                     ]], [[]])
+                  ],
+                  [# big-endian IEEE 754 quadruple-precision
+                   gl_cv_cc_long_double_expbit0='word 0 bit 16'
+                  ],
+                  [# little-endian IEEE 754 quadruple-precision
+                   gl_cv_cc_long_double_expbit0='word 3 bit 16'
+                  ])
+                ;;
+              powerpc64le)
+                # little-endian double-double
+                gl_cv_cc_long_double_expbit0='word 1 bit 20'
+                ;;
+              powerpc* | rs6000)
+                # big-endian double-double
+                gl_cv_cc_long_double_expbit0='word 0 bit 20'
+                ;;
+              *)
+                gl_cv_cc_long_double_expbit0="unknown"
+                ;;
+            esac
+          fi
         ])
       rm -f conftest.out
     ])
index a9b93e5d8acebe4cb2542b30e6c10cccccd24bff..0274af0a52739eeb9558bd29498280f3f355b74f 100644 (file)
@@ -6,6 +6,8 @@ lib/getpayloadl.c
 m4/mathfunc.m4
 m4/getpayload.m4
 m4/exponentl.m4
+m4/exponentd.m4
+m4/math_h.m4
 
 Depends-on:
 math-h
index 3039a588022cb182f7239a398ba9cee596c99150..68382e32a608d269812f9288d7639f3115e4ed51 100644 (file)
@@ -6,6 +6,8 @@ lib/isfinite.c
 m4/isfinite.m4
 m4/check-math-lib.m4
 m4/exponentl.m4
+m4/exponentd.m4
+m4/math_h.m4
 
 Depends-on:
 math-h
index 9cee3534e23de04c6f0466489be188151427e783..4e0def2bb05abea3e1e548ba6ce34b387cca03f1 100644 (file)
@@ -6,6 +6,8 @@ lib/isnanl.c
 lib/isnan.c
 lib/float+.h
 m4/exponentl.m4
+m4/exponentd.m4
+m4/math_h.m4
 m4/isnanl.m4
 
 Depends-on:
index 2375d5931846bf979435f719dd2595f3cdff6f9f..91e23ca40b4d9e998dd2296c7b4edee735bac6c8 100644 (file)
@@ -7,6 +7,7 @@ lib/isnanl.c
 lib/isnan.c
 lib/float+.h
 m4/exponentl.m4
+m4/exponentd.m4
 m4/isnanl.m4
 m4/math_h.m4
 
index 18dc1ee46c2ffad7e7160850fed8a91356d5d077..f58d0f81ca476b1b5171f7aad8ad9c3a58f5b292 100644 (file)
@@ -6,6 +6,8 @@ lib/setpayloadl.c
 m4/mathfunc.m4
 m4/setpayload.m4
 m4/exponentl.m4
+m4/exponentd.m4
+m4/math_h.m4
 m4/nan-mips.m4
 
 Depends-on:
index 370b109fc82470feb14265fea052941c5d54fb4c..1c1151a7cb90fb7ede553cd9d9360f4389b552f9 100644 (file)
@@ -6,6 +6,8 @@ lib/setpayloadsigl.c
 m4/mathfunc.m4
 m4/setpayloadsig.m4
 m4/exponentl.m4
+m4/exponentd.m4
+m4/math_h.m4
 
 Depends-on:
 math-h