summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-03-11 01:27:59 +0100
committerBruno Haible <bruno@clisp.org>2012-03-11 02:40:43 +0100
commit55b49420fc3ae8860ed66a85645b2b4d171646dc (patch)
treef066c0fe36e25d1b951f96dc20370b66cd9602da
parent5ba3e2240b3f1bba41db8a6f96363009f6d71fad (diff)
downloadgnulib-55b49420fc3ae8860ed66a85645b2b4d171646dc.tar.gz
log1p-ieee: Work around test failure on AIX 7.1 and HP-UX 11.
* m4/log1p-ieee.m4: New file. * m4/log1p.m4 (gl_FUNC_LOG1P): If gl_FUNC_LOG1P_IEEE is present, test whether log1p works with a minus zero argument. Replace it if not. * lib/math.in.h (log1p): Override if REPLACE_LOG1P is 1. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_LOG1P. * modules/math (Makefile.am): Substitute REPLACE_LOG1P. * modules/log1p (configure.ac): Consider REPLACE_LOG1P. (Depends-on): Update conditions. * modules/log1p-ieee (Files): Add m4/log1p-ieee.m4, m4/minus-zero.m4, m4/signbit.m4. (configure.ac): Invoke gl_FUNC_LOG1P_IEEE. * doc/posix-functions/log1p.texi: Mention the log1p-ieee module.
-rw-r--r--ChangeLog14
-rw-r--r--doc/posix-functions/log1p.texi11
-rw-r--r--lib/math.in.h13
-rw-r--r--m4/log1p-ieee.m415
-rw-r--r--m4/log1p.m446
-rw-r--r--m4/math_h.m43
-rw-r--r--modules/log1p8
-rw-r--r--modules/log1p-ieee4
-rw-r--r--modules/math1
9 files changed, 104 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index e42a134279..874af82faa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2012-03-10 Bruno Haible <bruno@clisp.org>
+ log1p-ieee: Work around test failure on AIX 7.1 and HP-UX 11.
+ * m4/log1p-ieee.m4: New file.
+ * m4/log1p.m4 (gl_FUNC_LOG1P): If gl_FUNC_LOG1P_IEEE is present, test
+ whether log1p works with a minus zero argument. Replace it if not.
+ * lib/math.in.h (log1p): Override if REPLACE_LOG1P is 1.
+ * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_LOG1P.
+ * modules/math (Makefile.am): Substitute REPLACE_LOG1P.
+ * modules/log1p (configure.ac): Consider REPLACE_LOG1P.
+ (Depends-on): Update conditions.
+ * modules/log1p-ieee (Files): Add m4/log1p-ieee.m4, m4/minus-zero.m4,
+ m4/signbit.m4.
+ (configure.ac): Invoke gl_FUNC_LOG1P_IEEE.
+ * doc/posix-functions/log1p.texi: Mention the log1p-ieee module.
+
Tests for module 'log1pl-ieee'.
* modules/log1pl-ieee-tests: New file.
* tests/test-log1pl-ieee.c: New file.
diff --git a/doc/posix-functions/log1p.texi b/doc/posix-functions/log1p.texi
index a63b75b194..0e1f3aac8f 100644
--- a/doc/posix-functions/log1p.texi
+++ b/doc/posix-functions/log1p.texi
@@ -4,15 +4,22 @@
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/log1p.html}
-Gnulib module: log1p
+Gnulib module: log1p or log1p-ieee
-Portability problems fixed by Gnulib:
+Portability problems fixed by either Gnulib module @code{log1p} or @code{log1p-ieee}:
@itemize
@item
This function is missing on some platforms:
Minix 3.1.8, MSVC 9.
@end itemize
+Portability problems fixed by Gnulib module @code{log1p-ieee}:
+@itemize
+@item
+This function has problems when the argument is minus zero on some platforms:
+AIX 7.1, HP-UX 11.
+@end itemize
+
Portability problems not fixed by Gnulib:
@itemize
@end itemize
diff --git a/lib/math.in.h b/lib/math.in.h
index 9d8159070a..5128dccc17 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -1245,10 +1245,19 @@ _GL_WARN_ON_USE (log1pf, "log1pf is unportable - "
#endif
#if @GNULIB_LOG1P@
-# if !@HAVE_LOG1P@
+# if @REPLACE_LOG1P@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef log1p
+# define log1p rpl_log1p
+# endif
+_GL_FUNCDECL_RPL (log1p, double, (double x));
+_GL_CXXALIAS_RPL (log1p, double, (double x));
+# else
+# if !@HAVE_LOG1P@
_GL_FUNCDECL_SYS (log1p, double, (double x));
-# endif
+# endif
_GL_CXXALIAS_SYS (log1p, double, (double x));
+# endif
_GL_CXXALIASWARN (log1p);
#elif defined GNULIB_POSIXCHECK
# undef log1p
diff --git a/m4/log1p-ieee.m4 b/m4/log1p-ieee.m4
new file mode 100644
index 0000000000..2391af8f96
--- /dev/null
+++ b/m4/log1p-ieee.m4
@@ -0,0 +1,15 @@
+# log1p-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_LOG1P can test whether 'aclocal' has
+dnl found uses of this macro.
+
+AC_DEFUN([gl_FUNC_LOG1P_IEEE],
+[
+ m4_divert_text([INIT_PREPARE], [gl_log1p_required=ieee])
+ AC_REQUIRE([gl_FUNC_LOG1P])
+])
diff --git a/m4/log1p.m4 b/m4/log1p.m4
index f692ca023e..8d2b15ca04 100644
--- a/m4/log1p.m4
+++ b/m4/log1p.m4
@@ -1,4 +1,4 @@
-# log1p.m4 serial 1
+# log1p.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_LOG1P],
[
+ m4_divert_text([DEFAULTS], [gl_log1p_required=plain])
AC_REQUIRE([gl_MATH_H_DEFAULTS])
dnl Persuade glibc <math.h> to declare log1p().
@@ -19,8 +20,49 @@ AC_DEFUN([gl_FUNC_LOG1P],
LIBS="$LIBS $LOG1P_LIBM"
AC_CHECK_FUNCS([log1p])
LIBS="$save_LIBS"
- if test $ac_cv_func_log1p = no; then
+ if test $ac_cv_func_log1p = yes; then
+ :
+ m4_ifdef([gl_FUNC_LOG1P_IEEE], [
+ if test $gl_log1p_required = ieee && test $REPLACE_LOG1P = 0; then
+ AC_CACHE_CHECK([whether log1p works according to ISO C 99 with IEC 60559],
+ [gl_cv_func_log1p_ieee],
+ [
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $LOG1P_LIBM"
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES 1 /* for glibc */
+#endif
+#include <math.h>
+]gl_DOUBLE_MINUS_ZERO_CODE[
+]gl_DOUBLE_SIGNBIT_CODE[
+static double dummy (double x) { return 0; }
+int main (int argc, char *argv[])
+{
+ double (*my_log1p) (double) = argc ? log1p : dummy;
+ /* This test fails on AIX, HP-UX 11. */
+ double y = my_log1p (minus_zerod);
+ if (!(y == 0.0) || (signbitd (minus_zerod) && !signbitd (y)))
+ return 1;
+ return 0;
+}
+ ]])],
+ [gl_cv_func_log1p_ieee=yes],
+ [gl_cv_func_log1p_ieee=no],
+ [gl_cv_func_log1p_ieee="guessing no"])
+ LIBS="$save_LIBS"
+ ])
+ case "$gl_cv_func_log1p_ieee" in
+ *yes) ;;
+ *) REPLACE_LOG1P=1 ;;
+ esac
+ fi
+ ])
+ else
HAVE_LOG1P=0
+ fi
+ if test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1; then
dnl Find libraries needed to link lib/log1p.c.
AC_REQUIRE([gl_FUNC_ISNAND])
AC_REQUIRE([gl_FUNC_LOG])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index 522be0b2d5..d832e588b3 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 98
+# math_h.m4 serial 99
dnl Copyright (C) 2007-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,
@@ -270,6 +270,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
REPLACE_LOG=0; AC_SUBST([REPLACE_LOG])
REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF])
REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL])
+ REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P])
REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF])
REPLACE_MODF=0; AC_SUBST([REPLACE_MODF])
REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF])
diff --git a/modules/log1p b/modules/log1p
index e055026aac..57f8ff547c 100644
--- a/modules/log1p
+++ b/modules/log1p
@@ -9,13 +9,13 @@ m4/mathfunc.m4
Depends-on:
math
extensions
-isnand [test $HAVE_LOG1P = 0]
-log [test $HAVE_LOG1P = 0]
-round [test $HAVE_LOG1P = 0]
+isnand [test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1]
+log [test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1]
+round [test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1]
configure.ac:
gl_FUNC_LOG1P
-if test $HAVE_LOG1P = 0; then
+if test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1; then
AC_LIBOBJ([log1p])
fi
gl_MATH_MODULE_INDICATOR([log1p])
diff --git a/modules/log1p-ieee b/modules/log1p-ieee
index b76096e673..7a0aa9bb8e 100644
--- a/modules/log1p-ieee
+++ b/modules/log1p-ieee
@@ -2,12 +2,16 @@ Description:
log1p() function according to ISO C 99 with IEC 60559.
Files:
+m4/log1p-ieee.m4
+m4/minus-zero.m4
+m4/signbit.m4
Depends-on:
log1p
fpieee
configure.ac:
+gl_FUNC_LOG1P_IEEE
Makefile.am:
diff --git a/modules/math b/modules/math
index 16950da40a..cbd86cd775 100644
--- a/modules/math
+++ b/modules/math
@@ -238,6 +238,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''REPLACE_LOG''@|$(REPLACE_LOG)|g' \
-e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \
-e 's|@''REPLACE_LOGL''@|$(REPLACE_LOGL)|g' \
+ -e 's|@''REPLACE_LOG1P''@|$(REPLACE_LOG1P)|g' \
-e 's|@''REPLACE_LOG1PF''@|$(REPLACE_LOG1PF)|g' \
-e 's|@''REPLACE_MODF''@|$(REPLACE_MODF)|g' \
-e 's|@''REPLACE_MODFF''@|$(REPLACE_MODFF)|g' \