>From 6065f427d616ccc578b38d92a5ef27bc4b6286ea Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 29 Oct 2017 11:16:56 +0100 Subject: [PATCH 2/7] expl: Ensure replacement on Haiku. * m4/expl.m4 (gl_FUNC_EXPL): Test whether an expl() return value is zero. * doc/posix-functions/expl.texi: Mention the Haiku problem. --- ChangeLog | 7 ++++++ doc/posix-functions/expl.texi | 5 ++++- m4/expl.m4 | 50 ++++++++++++++++++++++++------------------- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index bae2722..53745fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2017-10-29 Bruno Haible + expl: Ensure replacement on Haiku. + * m4/expl.m4 (gl_FUNC_EXPL): Test whether an expl() return value is + zero. + * doc/posix-functions/expl.texi: Mention the Haiku problem. + +2017-10-29 Bruno Haible + math: Fix test failure on Haiku. * lib/math.in.h (FP_ILOGB0, FP_ILOGBNAN): Override on Haiku. * m4/ilogb.m4 (gl_FUNC_ILOGB_WORKS): Update accordingly. diff --git a/doc/posix-functions/expl.texi b/doc/posix-functions/expl.texi index 0a70d20..92d7ed6 100644 --- a/doc/posix-functions/expl.texi +++ b/doc/posix-functions/expl.texi @@ -12,7 +12,10 @@ Portability problems fixed by Gnulib: This function is missing on some platforms: FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, Interix 3.5, BeOS. @item -This function returns NaN for small operands: +This function returns 0.0 for all arguments on some platforms: +Haiku 2017. address@hidden +This function returns NaN for small operands on some platforms: OpenBSD 5.4. @item This function is only defined as a macro with arguments on some platforms: diff --git a/m4/expl.m4 b/m4/expl.m4 index 2eddf0a..42db88b 100644 --- a/m4/expl.m4 +++ b/m4/expl.m4 @@ -1,4 +1,4 @@ -# expl.m4 serial 10 +# expl.m4 serial 11 dnl Copyright (C) 2010-2017 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -54,31 +54,37 @@ AC_DEFUN([gl_FUNC_EXPL], EXPL_LIBM=-lm fi fi - dnl On OpenBSD5.4 the system's native expl() is buggy: + dnl On Haiku 2017 the system's native expl() is just a stub: it returns 0.0 + dnl and prints "__expl not implemented" for all arguments. + dnl On OpenBSD 5.4 the system's native expl() is buggy: dnl it returns 'nan' for small values. Test for this anomaly. if test $gl_cv_func_expl_no_libm = yes \ || test $gl_cv_func_expl_in_libm = yes; then AC_CACHE_CHECK([whether expl() breaks with small values], - [gl_cv_func_expl_buggy], - [ - save_LIBS="$LIBS" - LIBS="$EXPL_LIBM" - AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[return isnan(expl(-1.0))|| - isnan(expl(-0.8))|| - isnan(expl(-0.4)); ]])], - [gl_cv_func_expl_buggy=no], [gl_cv_func_expl_buggy=yes], - [case $host_os in - openbsd*) gl_cv_func_expl_buggy="guessing yes" ;; - # Guess no on native Windows. - mingw*) gl_cv_func_expl_buggy="guessing no" ;; - *) gl_cv_func_expl_buggy="guessing no" ;; - esac - ]) - LIBS="$save_LIBS" - ]) + [gl_cv_func_expl_buggy], + [save_LIBS="$LIBS" + LIBS="$EXPL_LIBM" + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[volatile long double x1 = -1.0; + volatile long double x2 = -0.8; + volatile long double x3 = -0.4; + return expl(x1) == 0.0 || isnan(expl(x1)) + || isnan(expl(x2)) || isnan(expl(x3)); + ]]) + ], + [gl_cv_func_expl_buggy=no], [gl_cv_func_expl_buggy=yes], + [case $host_os in + haiku* | openbsd*) + gl_cv_func_expl_buggy="guessing yes" ;; + # Guess no on native Windows. + mingw*) gl_cv_func_expl_buggy="guessing no" ;; + *) gl_cv_func_expl_buggy="guessing no" ;; + esac + ]) + LIBS="$save_LIBS" + ]) case "$gl_cv_func_expl_buggy" in *yes) gl_cv_func_expl_in_libm=no -- 2.7.4