]> Savannah Git Hosting - gnulib.git/commitdiff
New module 'expm1-ieee'.
authorBruno Haible <bruno@clisp.org>
Tue, 6 Mar 2012 23:38:50 +0000 (00:38 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 6 Mar 2012 23:38:50 +0000 (00:38 +0100)
* modules/expm1-ieee: New file.
* m4/expm1-ieee.m4: New file.
* m4/expm1.m4 (gl_FUNC_EXPM1): If gl_FUNC_EXPM1_IEEE is present, test
whether expm1 works with a minus zero argument. Replace it if not.
* lib/math.in.h (expm1): Override if REPLACE_EXPM1 is 1.
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_EXPM1.
* modules/math (Makefile.am): Substitute REPLACE_EXPM1.
* modules/expm1 (configure.ac): Consider REPLACE_EXPM1.
(Depends-on): Update conditions.
* doc/posix-functions/expm1.texi: Mention the expm1-ieee module and the
AIX problem.

ChangeLog
doc/posix-functions/expm1.texi
lib/math.in.h
m4/expm1-ieee.m4 [new file with mode: 0644]
m4/expm1.m4
m4/math_h.m4
modules/expm1
modules/expm1-ieee [new file with mode: 0644]
modules/math

index f70e98ebe1dfae6bd4c20b63ad2e4d906f79d16c..56dd9fe3d48eddf1c558fe85074d48523db67806 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2012-03-06  Bruno Haible  <bruno@clisp.org>
+
+       New module 'expm1-ieee'.
+       * modules/expm1-ieee: New file.
+       * m4/expm1-ieee.m4: New file.
+       * m4/expm1.m4 (gl_FUNC_EXPM1): If gl_FUNC_EXPM1_IEEE is present, test
+       whether expm1 works with a minus zero argument. Replace it if not.
+       * lib/math.in.h (expm1): Override if REPLACE_EXPM1 is 1.
+       * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_EXPM1.
+       * modules/math (Makefile.am): Substitute REPLACE_EXPM1.
+       * modules/expm1 (configure.ac): Consider REPLACE_EXPM1.
+       (Depends-on): Update conditions.
+       * doc/posix-functions/expm1.texi: Mention the expm1-ieee module and the
+       AIX problem.
+
 2012-03-06  Bruno Haible  <bruno@clisp.org>
 
        Work around expm1f bug on IRIX 6.5.
index 94d779c582f42d0a6a671d3ece96ffa53dee4154..a363029ade6e03549870b84bc31b772fdccfca8b 100644 (file)
@@ -4,15 +4,23 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/expm1.html}
 
-Gnulib module: expm1
+Gnulib module: expm1 or expm1-ieee
 
-Portability problems fixed by Gnulib:
+Portability problems fixed by either Gnulib module @code{expm1} or @code{expm1-ieee}:
 @itemize
 @item
 This function is missing on some platforms:
 Minix 3.1.8, mingw, MSVC 9.
 @end itemize
 
+Portability problems fixed by Gnulib module @code{expm1-ieee}:
+@itemize
+@item
+This function has problems when the first argument is minus zero on some
+platforms:
+AIX 7.1.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @end itemize
index c57e48bb9ed47b7e1fbfcd11608b64dbf3fe8ed1..bd704b795df75a8d322abac32dbb97fa5d3bf47b 100644 (file)
@@ -556,10 +556,19 @@ _GL_WARN_ON_USE (expm1f, "expm1f is unportable - "
 #endif
 
 #if @GNULIB_EXPM1@
-# if !@HAVE_EXPM1@
+# if @REPLACE_EXPM1@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef expm1
+#   define expm1 rpl_expm1
+#  endif
+_GL_FUNCDECL_RPL (expm1, double, (double x));
+_GL_CXXALIAS_RPL (expm1, double, (double x));
+# else
+#  if !@HAVE_EXPM1@
 _GL_FUNCDECL_SYS (expm1, double, (double x));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (expm1, double, (double x));
+# endif
 _GL_CXXALIASWARN (expm1);
 #elif defined GNULIB_POSIXCHECK
 # undef expm1
diff --git a/m4/expm1-ieee.m4 b/m4/expm1-ieee.m4
new file mode 100644 (file)
index 0000000..1908d73
--- /dev/null
@@ -0,0 +1,15 @@
+# expm1-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 expm1.m4 and not inlined in the
+dnl module description), so that gl_FUNC_EXPM1 can test whether 'aclocal' has
+dnl found uses of this macro.
+
+AC_DEFUN([gl_FUNC_EXPM1_IEEE],
+[
+  m4_divert_text([INIT_PREPARE], [gl_expm1_required=ieee])
+  AC_REQUIRE([gl_FUNC_EXPM1])
+])
index edef4fb3bf4a14215c0716b300ea14451c5c9f19..4f34ef371d0dbcf38fa438cbdcb72a2703929302 100644 (file)
@@ -1,4 +1,4 @@
-# expm1.m4 serial 1
+# expm1.m4 serial 2
 dnl Copyright (C) 2010-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_EXPM1],
 [
+  m4_divert_text([DEFAULTS], [gl_expm1_required=plain])
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
 
   dnl Persuade glibc <math.h> to declare expm1().
@@ -52,9 +53,49 @@ AC_DEFUN([gl_FUNC_EXPM1],
       EXPM1_LIBM=-lm
     fi
   fi
-  if test $gl_cv_func_expm1_no_libm = no \
-     && test $gl_cv_func_expm1_in_libm = no; then
+  if test $gl_cv_func_expm1_no_libm = yes \
+     || test $gl_cv_func_expm1_in_libm = yes; then
+    :
+    m4_ifdef([gl_FUNC_EXPM1_IEEE], [
+      if test $gl_expm1_required = ieee && test $REPLACE_EXPM1 = 0; then
+        AC_CACHE_CHECK([whether expm1 works according to ISO C 99 with IEC 60559],
+          [gl_cv_func_expm1_ieee],
+          [
+            save_LIBS="$LIBS"
+            LIBS="$LIBS $EXPM1_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_expm1) (double) = argc ? expm1 : dummy;
+  double y = my_expm1 (minus_zerod);
+  if (!(y == 0.0) || (signbitd (minus_zerod) && !signbitd (y)))
+    return 1;
+  return 0;
+}
+              ]])],
+              [gl_cv_func_expm1_ieee=yes],
+              [gl_cv_func_expm1_ieee=no],
+              [gl_cv_func_expm1_ieee="guessing no"])
+            LIBS="$save_LIBS"
+          ])
+        case "$gl_cv_func_expm1_ieee" in
+          *yes) ;;
+          *) REPLACE_EXPM1=1 ;;
+        esac
+      fi
+    ])
+  else
     HAVE_EXPM1=0
+  fi
+  if test $HAVE_EXPM1 = 0 || test $REPLACE_EXPM1 = 1; then
     dnl Find libraries needed to link lib/expm1.c.
     AC_REQUIRE([gl_FUNC_ISNAND])
     AC_REQUIRE([gl_FUNC_EXP])
index f49fb232a1a705e190dc05c81aba06ce651a48a6..ce46a24f11937da2d5f8b3cb89f28d008b27ea7c 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 83
+# math_h.m4 serial 84
 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,
@@ -227,6 +227,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   REPLACE_CEIL=0;              AC_SUBST([REPLACE_CEIL])
   REPLACE_CEILF=0;             AC_SUBST([REPLACE_CEILF])
   REPLACE_CEILL=0;             AC_SUBST([REPLACE_CEILL])
+  REPLACE_EXPM1=0;             AC_SUBST([REPLACE_EXPM1])
   REPLACE_EXPM1F=0;            AC_SUBST([REPLACE_EXPM1F])
   REPLACE_FABSL=0;             AC_SUBST([REPLACE_FABSL])
   REPLACE_FLOOR=0;             AC_SUBST([REPLACE_FLOOR])
index dfaac626a4f8d1d541566f088202a5a4f0fbff73..8fac73cdfd3cd73cc4259e88d2d6356256e4bf54 100644 (file)
@@ -9,14 +9,14 @@ m4/mathfunc.m4
 Depends-on:
 math
 extensions
-isnand          [test $HAVE_EXPM1 = 0]
-exp             [test $HAVE_EXPM1 = 0]
-round           [test $HAVE_EXPM1 = 0]
-ldexp           [test $HAVE_EXPM1 = 0]
+isnand          [test $HAVE_EXPM1 = 0 || test $REPLACE_EXPM1 = 1]
+exp             [test $HAVE_EXPM1 = 0 || test $REPLACE_EXPM1 = 1]
+round           [test $HAVE_EXPM1 = 0 || test $REPLACE_EXPM1 = 1]
+ldexp           [test $HAVE_EXPM1 = 0 || test $REPLACE_EXPM1 = 1]
 
 configure.ac:
 gl_FUNC_EXPM1
-if test $HAVE_EXPM1 = 0; then
+if test $HAVE_EXPM1 = 0 || test $REPLACE_EXPM1 = 1; then
   AC_LIBOBJ([expm1])
 fi
 gl_MATH_MODULE_INDICATOR([expm1])
diff --git a/modules/expm1-ieee b/modules/expm1-ieee
new file mode 100644 (file)
index 0000000..216f254
--- /dev/null
@@ -0,0 +1,28 @@
+Description:
+expm1() function according to ISO C 99 with IEC 60559.
+
+Files:
+m4/expm1-ieee.m4
+m4/minus-zero.m4
+m4/signbit.m4
+
+Depends-on:
+expm1
+fpieee
+
+configure.ac:
+gl_FUNC_EXPM1_IEEE
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(EXPM1_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index 2c95248d6eb69b2a6b0dd9862c5b3c4e2b388149..74788f2f7f5ebe49c5e9e83757ee599a7a9c94c4 100644 (file)
@@ -196,6 +196,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \
              -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \
              -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \
+             -e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \
              -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \
              -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \
              -e 's|@''REPLACE_FLOOR''@|$(REPLACE_FLOOR)|g' \