From ef3f971ddf9b91cc6ea3af6e46532ea6b804b9ce Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 11 Mar 2012 02:06:49 +0100 Subject: [PATCH] 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. --- ChangeLog | 10 ++++++++++ doc/posix-functions/log1pf.texi | 11 +++++++++-- m4/log1pf-ieee.m4 | 15 +++++++++++++++ m4/log1pf.m4 | 41 ++++++++++++++++++++++++++++++++++++++++- modules/log1pf-ieee | 5 ++++- 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 m4/log1pf-ieee.m4 diff --git a/ChangeLog b/ChangeLog index 8ce0dcb59..41e1da09c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2012-03-10 Bruno Haible + 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. diff --git a/doc/posix-functions/log1pf.texi b/doc/posix-functions/log1pf.texi index 2e3c49abe..8f13d54c7 100644 --- a/doc/posix-functions/log1pf.texi +++ b/doc/posix-functions/log1pf.texi @@ -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 index 000000000..918da88c0 --- /dev/null +++ b/m4/log1pf-ieee.m4 @@ -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]) +]) diff --git a/m4/log1pf.m4 b/m4/log1pf.m4 index b01243358..0f75e94ce 100644 --- a/m4/log1pf.m4 +++ b/m4/log1pf.m4 @@ -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 +]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 diff --git a/modules/log1pf-ieee b/modules/log1pf-ieee index 7417b543c..1e7999c69 100644 --- a/modules/log1pf-ieee +++ b/modules/log1pf-ieee @@ -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: -- 2.11.0