log1pf-ieee: Work around test failure on OpenBSD 4.9 and AIX 7.1.
authorBruno Haible <bruno@clisp.org>
Sun, 11 Mar 2012 01:06:49 +0000 (02:06 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 11 Mar 2012 01:40:45 +0000 (02:40 +0100)
* m4/log1pf-ieee.m4: New file.
* m4/log1pf.m4 (gl_FUNC_LOG1PF): If gl_FUNC_LOG1PF_IEEE is present,
test whether log1pf works with a minus zero argument. Replace it if
not.
* modules/log1pf-ieee (Files): Add m4/log1pf-ieee.m4, m4/minus-zero.m4,
m4/signbit.m4.
(configure.ac): Invoke gl_FUNC_LOG1PF_IEEE.
* doc/posix-functions/log1pf.texi: Mention the log1pf-ieee module.

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

index 8ce0dcb..41e1da0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2012-03-10  Bruno Haible  <bruno@clisp.org>
 
+       log1pf-ieee: Work around test failure on OpenBSD 4.9 and AIX 7.1.
+       * m4/log1pf-ieee.m4: New file.
+       * m4/log1pf.m4 (gl_FUNC_LOG1PF): If gl_FUNC_LOG1PF_IEEE is present,
+       test whether log1pf works with a minus zero argument. Replace it if
+       not.
+       * modules/log1pf-ieee (Files): Add m4/log1pf-ieee.m4, m4/minus-zero.m4,
+       m4/signbit.m4.
+       (configure.ac): Invoke gl_FUNC_LOG1PF_IEEE.
+       * doc/posix-functions/log1pf.texi: Mention the log1pf-ieee module.
+
        log1pf-ieee: Work around test failure on AIX 5.1 and HP-UX 11.
        * modules/log1pf-ieee (Depends-on): Add log1p-ieee.
        (configure.ac): Require gl_FUNC_LOG1PF.
index 2e3c49a..8f13d54 100644 (file)
@@ -4,9 +4,9 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/log1pf.html}
 
-Gnulib module: log1pf
+Gnulib module: log1pf or log1pf-ieee
 
-Portability problems fixed by Gnulib:
+Portability problems fixed by either Gnulib module @code{log1pf} or @code{log1pf-ieee}:
 @itemize
 @item
 This function is missing on some platforms:
@@ -16,6 +16,13 @@ This function returns a wrong value for the argument -1.0f on some platforms:
 IRIX 6.5.
 @end itemize
 
+Portability problems fixed by Gnulib module @code{log1pf-ieee}:
+@itemize
+@item
+This function has problems when the argument is minus zero on some platforms:
+OpenBSD 4.9, AIX 7.1.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @end itemize
diff --git a/m4/log1pf-ieee.m4 b/m4/log1pf-ieee.m4
new file mode 100644 (file)
index 0000000..918da88
--- /dev/null
@@ -0,0 +1,15 @@
+# log1pf-ieee.m4 serial 1
+dnl Copyright (C) 2012 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 remainder.m4 and not inlined in the
+dnl module description), so that gl_FUNC_LOG1PF can test whether 'aclocal' has
+dnl found uses of this macro.
+
+AC_DEFUN([gl_FUNC_LOG1PF_IEEE],
+[
+  m4_divert_text([INIT_PREPARE], [gl_log1pf_required=ieee])
+  AC_REQUIRE([gl_FUNC_LOG1PF])
+])
index b012433..0f75e94 100644 (file)
@@ -1,4 +1,4 @@
-# log1pf.m4 serial 1
+# log1pf.m4 serial 2
 dnl Copyright (C) 2012 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_LOG1PF],
 [
+  m4_divert_text([DEFAULTS], [gl_log1pf_required=plain])
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_LOG1P])
 
@@ -29,6 +30,44 @@ AC_DEFUN([gl_FUNC_LOG1PF],
       *yes) ;;
       *) REPLACE_LOG1PF=1 ;;
     esac
+
+    m4_ifdef([gl_FUNC_LOG1PF_IEEE], [
+      if test $gl_log1pf_required = ieee && test $REPLACE_LOG1PF = 0; then
+        AC_CACHE_CHECK([whether log1pf works according to ISO C 99 with IEC 60559],
+          [gl_cv_func_log1pf_ieee],
+          [
+            save_LIBS="$LIBS"
+            LIBS="$LIBS $LOG1PF_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[
+static float dummy (float x) { return 0; }
+int main (int argc, char *argv[])
+{
+  float (*my_log1pf) (float) = argc ? log1pf : dummy;
+  /* This test fails on OpenBSD 4.9, AIX 7.1.  */
+  float y = my_log1pf (minus_zerof);
+  if (!(y == 0.0f) || (signbitf (minus_zerof) && !signbitf (y)))
+    return 1;
+  return 0;
+}
+              ]])],
+              [gl_cv_func_log1pf_ieee=yes],
+              [gl_cv_func_log1pf_ieee=no],
+              [gl_cv_func_log1pf_ieee="guessing no"])
+            LIBS="$save_LIBS"
+          ])
+        case "$gl_cv_func_log1pf_ieee" in
+          *yes) ;;
+          *) REPLACE_LOG1PF=1 ;;
+        esac
+      fi
+    ])
   else
     HAVE_LOG1PF=0
   fi
index 7417b54..1e7999c 100644 (file)
@@ -2,6 +2,9 @@ Description:
 log1pf() function according to ISO C 99 with IEC 60559.
 
 Files:
+m4/log1pf-ieee.m4
+m4/minus-zero.m4
+m4/signbit.m4
 
 Depends-on:
 log1pf
@@ -9,7 +12,7 @@ fpieee
 log1p-ieee      [test $HAVE_LOG1PF = 0 || test $REPLACE_LOG1PF = 1]
 
 configure.ac:
-AC_REQUIRE([gl_FUNC_LOG1PF])
+gl_FUNC_LOG1PF_IEEE
 
 Makefile.am: