From: Bruno Haible Date: Tue, 6 Mar 2012 23:38:50 +0000 (+0100) Subject: New module 'expm1-ieee'. X-Git-Tag: v0.1~938 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=232b64ac929c3675c345d1b6003fc7ad725840a3;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index f70e98ebe1..56dd9fe3d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2012-03-06 Bruno Haible + + 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 Work around expm1f bug on IRIX 6.5. diff --git a/doc/posix-functions/expm1.texi b/doc/posix-functions/expm1.texi index 94d779c582..a363029ade 100644 --- a/doc/posix-functions/expm1.texi +++ b/doc/posix-functions/expm1.texi @@ -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 diff --git a/lib/math.in.h b/lib/math.in.h index c57e48bb9e..bd704b795d 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -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 index 0000000000..1908d73b05 --- /dev/null +++ b/m4/expm1-ieee.m4 @@ -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]) +]) diff --git a/m4/expm1.m4 b/m4/expm1.m4 index edef4fb3bf..4f34ef371d 100644 --- a/m4/expm1.m4 +++ b/m4/expm1.m4 @@ -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 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 +]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]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index f49fb232a1..ce46a24f11 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -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]) diff --git a/modules/expm1 b/modules/expm1 index dfaac626a4..8fac73cdfd 100644 --- a/modules/expm1 +++ b/modules/expm1 @@ -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 index 0000000000..216f25431e --- /dev/null +++ b/modules/expm1-ieee @@ -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: + + +Link: +$(EXPM1_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/modules/math b/modules/math index 2c95248d6e..74788f2f7f 100644 --- a/modules/math +++ b/modules/math @@ -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' \