]> Savannah Git Hosting - gnulib.git/commitdiff
expm1f-ieee: Work around AIX 7.2 bug.
authorBruno Haible <bruno@clisp.org>
Mon, 4 Jan 2021 21:27:47 +0000 (22:27 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 4 Jan 2021 21:27:47 +0000 (22:27 +0100)
* m4/expm1f.m4 (gl_FUNC_EXPM1F): Initialize gl_expm1f_required. If
module 'expm1f-ieee' is in use, check whether expm1f works according to
IEEE.
* m4/expm1f-ieee.m4: New file.
* modules/expm1f-ieee (Files): Add it.
(Depends-on): Update conditions.
(configure.ac): Invoke gl_FUNC_EXPM1F_IEEE.
* doc/posix-functions/expm1f.texi: Mention the AIX bug.

ChangeLog
doc/posix-functions/expm1f.texi
m4/expm1f-ieee.m4 [new file with mode: 0644]
m4/expm1f.m4
modules/expm1f-ieee

index 33cc845a9d3c78fb1aba301ac8e3143ba5c4f8ce..0add7d2679051d61f9a494e617a92674c247c01f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2021-01-04  Bruno Haible  <bruno@clisp.org>
+
+       expm1f-ieee: Work around AIX 7.2 bug.
+       * m4/expm1f.m4 (gl_FUNC_EXPM1F): Initialize gl_expm1f_required. If
+       module 'expm1f-ieee' is in use, check whether expm1f works according to
+       IEEE.
+       * m4/expm1f-ieee.m4: New file.
+       * modules/expm1f-ieee (Files): Add it.
+       (Depends-on): Update conditions.
+       (configure.ac): Invoke gl_FUNC_EXPM1F_IEEE.
+       * doc/posix-functions/expm1f.texi: Mention the AIX bug.
+
 2021-01-04  Bruno Haible  <bruno@clisp.org>
 
        ffsl, ffsll: Work around AIX 7.2 problem.
index c732cfea7c1f967231d9ea46750c000720b143f0..e95e510a03c13a84aec98a48b24b35a4735ff288 100644 (file)
@@ -4,9 +4,9 @@
 
 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/expm1f.html}
 
-Gnulib module: expm1f
+Gnulib module: expm1f or expm1f-ieee
 
-Portability problems fixed by Gnulib:
+Portability problems fixed by either Gnulib module @code{expm1f} or @code{expm1f-ieee}:
 @itemize
 @item
 This function is missing on some platforms:
@@ -16,6 +16,14 @@ This function produces wrong results for arguments <= @minus{}17.32868 on some p
 IRIX 6.5.
 @end itemize
 
+Portability problems fixed by Gnulib module @code{expm1f-ieee}:
+@itemize
+@item
+This function returns a positive zero for a minus zero argument
+on some platforms:
+AIX 7.2.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @end itemize
diff --git a/m4/expm1f-ieee.m4 b/m4/expm1f-ieee.m4
new file mode 100644 (file)
index 0000000..5344955
--- /dev/null
@@ -0,0 +1,15 @@
+# expm1f-ieee.m4 serial 1
+dnl Copyright (C) 2021 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This macro is in a separate file (not in expm1f.m4 and not inlined in the
+dnl module description), so that gl_FUNC_EXPM1F can test whether 'aclocal' has
+dnl found uses of this macro.
+
+AC_DEFUN([gl_FUNC_EXPM1F_IEEE],
+[
+  m4_divert_text([INIT_PREPARE], [gl_expm1f_required=ieee])
+  AC_REQUIRE([gl_FUNC_EXPM1F])
+])
index 5cb661f9d4fd69ee12e6d0d7398fd5ca94eb353c..c18ff1a5025d2804ed8ffb3d4593ce3c7c7e0ed9 100644 (file)
@@ -1,4 +1,4 @@
-# expm1f.m4 serial 3
+# expm1f.m4 serial 4
 dnl Copyright (C) 2011-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,6 +6,7 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_EXPM1F],
 [
+  m4_divert_text([DEFAULTS], [gl_expm1f_required=plain])
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_EXPM1])
 
@@ -20,6 +21,7 @@ AC_DEFUN([gl_FUNC_EXPM1F],
   LIBS="$save_LIBS"
   if test $ac_cv_func_expm1f = yes; then
     EXPM1F_LIBM="$EXPM1_LIBM"
+
     save_LIBS="$LIBS"
     LIBS="$LIBS $EXPM1F_LIBM"
     gl_FUNC_EXPM1F_WORKS
@@ -28,6 +30,73 @@ AC_DEFUN([gl_FUNC_EXPM1F],
       *yes) ;;
       *) REPLACE_EXPM1F=1 ;;
     esac
+
+    m4_ifdef([gl_FUNC_EXPM1F_IEEE], [
+      if test $gl_expm1f_required = ieee && test $REPLACE_EXPM1F = 0; then
+        AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+        AC_CACHE_CHECK([whether expm1f works according to ISO C 99 with IEC 60559],
+          [gl_cv_func_expm1f_ieee],
+          [
+            save_LIBS="$LIBS"
+            LIBS="$LIBS $EXPM1F_LIBM"
+            AC_RUN_IFELSE(
+              [AC_LANG_SOURCE([[
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES 1 /* for glibc */
+#endif
+#include <math.h>
+]gl_FLOAT_MINUS_ZERO_CODE[
+]gl_FLOAT_SIGNBIT_CODE[
+#ifndef expm1f
+extern
+#ifdef __cplusplus
+"C"
+#endif
+float expm1f (float);
+#endif
+/* Compare two numbers with ==.
+   This is a separate function because IRIX 6.5 "cc -O" miscompiles an
+   'x == x' test.  */
+static int
+numeric_equal (float x, float y)
+{
+  return x == y;
+}
+static float dummy (float x) { return 0; }
+int main (int argc, char *argv[])
+{
+  float (* volatile my_expm1f) (float) = argc ? expm1f : dummy;
+  /* Test expm1f(-0.0f).
+     This test fails on AIX 7.2.  */
+  float y = my_expm1f (minus_zerof);
+  if (signbitf (minus_zerof) && !signbitf (y))
+    return 1;
+  return 0;
+}
+              ]])],
+              [gl_cv_func_expm1f_ieee=yes],
+              [gl_cv_func_expm1f_ieee=no],
+              [case "$host_os" in
+                                # Guess yes on glibc systems.
+                 *-gnu* | gnu*) gl_cv_func_expm1f_ieee="guessing yes" ;;
+                                # Guess yes on musl systems.
+                 *-musl*)       gl_cv_func_expm1f_ieee="guessing yes" ;;
+                                # Guess yes on native Windows.
+                 mingw*)        gl_cv_func_expm1f_ieee="guessing yes" ;;
+                                # Guess no on AIX.
+                 aix*)          gl_cv_func_expm1f_ieee="guessing no" ;;
+                                # If we don't know, obey --enable-cross-guesses.
+                 *)             gl_cv_func_expm1f_ieee="$gl_cross_guess_normal" ;;
+               esac
+              ])
+            LIBS="$save_LIBS"
+          ])
+        case "$gl_cv_func_expm1f_ieee" in
+          *yes) ;;
+          *) REPLACE_EXPM1F=1 ;;
+        esac
+      fi
+    ])
   else
     HAVE_EXPM1F=0
   fi
index ed966e0d14a9380c4ef1c8d2801e413be1f691ab..ffab1d7b5adcf28fb5e28b8dbbc699645b5768f3 100644 (file)
@@ -2,14 +2,15 @@ Description:
 expm1f() function according to ISO C 99 with IEC 60559.
 
 Files:
+m4/expm1f-ieee.m4
 
 Depends-on:
 expm1f
 fpieee
-expm1-ieee      [test $HAVE_EXPM1F = 0]
+expm1-ieee      [test $HAVE_EXPM1F = 0 || test $REPLACE_EXPM1F = 1]
 
 configure.ac:
-AC_REQUIRE([gl_FUNC_EXPM1F])
+gl_FUNC_EXPM1F_IEEE
 
 Makefile.am: