# HG changeset patch # User Bruno Haible # Date 1331072751 -3600 # Node ID d71dacc1f7e0a6accd6e5082a86478944fc4eca6 # Parent 79c22773e9b799ebce1dcb4510e7a338b837b3e9 Work around expm1f bug on IRIX 6.5. * lib/math.in.h (expm1f): Override if REPLACE_EXPM1F is 1. * m4/expm1f.m4 (gl_FUNC_EXPM1F_WORKS): New macro. (gl_FUNC_EXPM1F): Invoke it. Set REPLACE_EXPM1F to 1 if expm1f() does not work. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_EXPM1F. * modules/math (Makefile.am): Substitute REPLACE_EXPM1F. * modules/expm1f (configure.ac): Consider REPLACE_EXPM1F. (Depends-on): Update conditions. * doc/posix-functions/expm1f.texi: Mention the IRIX 6.5 bug. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2012-03-06 Bruno Haible + + Work around expm1f bug on IRIX 6.5. + * lib/math.in.h (expm1f): Override if REPLACE_EXPM1F is 1. + * m4/expm1f.m4 (gl_FUNC_EXPM1F_WORKS): New macro. + (gl_FUNC_EXPM1F): Invoke it. Set REPLACE_EXPM1F to 1 if expm1f() does + not work. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_EXPM1F. + * modules/math (Makefile.am): Substitute REPLACE_EXPM1F. + * modules/expm1f (configure.ac): Consider REPLACE_EXPM1F. + (Depends-on): Update conditions. + * doc/posix-functions/expm1f.texi: Mention the IRIX 6.5 bug. + 2012-03-06 Bruno Haible Tests for module 'expm1l'. diff --git a/doc/posix-functions/expm1f.texi b/doc/posix-functions/expm1f.texi --- a/doc/posix-functions/expm1f.texi +++ b/doc/posix-functions/expm1f.texi @@ -11,6 +11,9 @@ @item This function is missing on some platforms: Minix 3.1.8, AIX 5.1, HP-UX 11, Solaris 9, mingw, MSVC 9. +@item +This function produces wrong results for arguments <= -17.32868 on some platforms: +IRIX 6.5. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/math.in.h b/lib/math.in.h --- a/lib/math.in.h +++ b/lib/math.in.h @@ -533,10 +533,19 @@ #if @GNULIB_EXPM1F@ -# if !@HAVE_EXPM1F@ +# if @REPLACE_EXPM1F@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef expm1f +# define expm1f rpl_expm1f +# endif +_GL_FUNCDECL_RPL (expm1f, float, (float x)); +_GL_CXXALIAS_RPL (expm1f, float, (float x)); +# else +# if !@HAVE_EXPM1F@ _GL_FUNCDECL_SYS (expm1f, float, (float x)); +# endif +_GL_CXXALIAS_SYS (expm1f, float, (float x)); # endif -_GL_CXXALIAS_SYS (expm1f, float, (float x)); _GL_CXXALIASWARN (expm1f); #elif defined GNULIB_POSIXCHECK # undef expm1f diff --git a/m4/expm1f.m4 b/m4/expm1f.m4 --- a/m4/expm1f.m4 +++ b/m4/expm1f.m4 @@ -1,4 +1,4 @@ -# expm1f.m4 serial 1 +# expm1f.m4 serial 2 dnl Copyright (C) 2011-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, @@ -20,10 +20,52 @@ 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 + LIBS="$save_LIBS" + case "$gl_cv_func_expm1f_works" in + *yes) ;; + *) REPLACE_EXPM1F=1 ;; + esac else HAVE_EXPM1F=0 + fi + if test $HAVE_EXPM1F = 0 || test $REPLACE_EXPM1F = 1; then dnl Find libraries needed to link lib/expm1f.c. EXPM1F_LIBM="$EXPM1_LIBM" fi AC_SUBST([EXPM1F_LIBM]) ]) + +dnl Test whether expm1f() works. +dnl On IRIX 6.5, for arguments <= -17.32868, it returns -5.6295e14. +AC_DEFUN([gl_FUNC_EXPM1F_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether expm1f works], [gl_cv_func_expm1f_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +volatile float x; +float y; +int main () +{ + x = -100.0f; + y = expm1f (x); + if (y < -1.0f) + return 1; + return 0; +} +]])], + [gl_cv_func_expm1f_works=yes], + [gl_cv_func_expm1f_works=no], + [case "$host_os" in + irix*) gl_cv_func_expm1f_works="guessing no";; + *) gl_cv_func_expm1f_works="guessing yes";; + esac + ]) + ]) +]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 82 +# math_h.m4 serial 83 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 @@ REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL]) REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) + REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F]) REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL]) REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR]) REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) diff --git a/modules/expm1f b/modules/expm1f --- a/modules/expm1f +++ b/modules/expm1f @@ -8,11 +8,11 @@ Depends-on: math extensions -expm1 [test $HAVE_EXPM1F = 0] +expm1 [test $HAVE_EXPM1F = 0 || test $REPLACE_EXPM1F = 1] configure.ac: gl_FUNC_EXPM1F -if test $HAVE_EXPM1F = 0; then +if test $HAVE_EXPM1F = 0 || test $REPLACE_EXPM1F = 1; then AC_LIBOBJ([expm1f]) fi gl_MATH_MODULE_INDICATOR([expm1f]) diff --git a/modules/math b/modules/math --- a/modules/math +++ b/modules/math @@ -196,6 +196,7 @@ -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \ -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ + -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \ -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \ -e 's|@''REPLACE_FLOOR''@|$(REPLACE_FLOOR)|g' \ -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \