Hello,
On 04/15/2014 05:20 AM, Pádraig Brady wrote:
On 04/15/2014 12:54 AM, Assaf Gordon wrote:
It seems "expl()" is broken on OpenBSD5.4.
You can set an override var for the configure run,
<...>
However, since you have a simple enough test
it seems it would be better to incorporate that to
the gnulib check, so that all can benefit.
Attached is my attempt at detecting buggy expl() in the "expl.m4" file.
The test runs correctly in multiple environments, and sets a variable (gl_cv_func_expl_buggy) to
"yes" or "no" .
However, I do not know how to overturn the gnulib detection of the native expl (see the
"TODO" comment in the patch) - so it's a no-op at the moment.
While this test works in its current form, there might be some portability
issues (since it uses 'fabs', 'exp' and 'expl') and those might require
additional headers or libraries or special declarations.
The tests runs correctly on:
Debian 7, x86_64, gcc 4.7.2
CentOS, x84_64, gcc 4.4.7
FreeBSD 10, x86_64, clang 3.3
OpenBSD 5.4, X84_64, gcc 4.2.1
Hurd, i386, gcc 4.8.2
DilOS 1.3.5 (akin to SunOS 5.11), gcc 4.7.3
In OpenBSD it is set to "yes" (indicating buggy expl). In all others - "no".
>From 9003e0a643aef003c8858db4936c3f57607d450b Mon Sep 17 00:00:00 2001
From: "A. Gordon" <agor...@wi.mit.edu>
Date: Tue, 15 Apr 2014 11:58:11 -0400
Subject: [PATCH] m4: tests for buggy expl() implementations
On some systems (OpenBSD 5.4), expl() incorrectly returns 'nan' for
small values. Compare the result of exp() with expl(), and
use Gnulib's expl if needed.
---
m4/expl.m4 | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/m4/expl.m4 b/m4/expl.m4
index 247bc6e..1d78534 100644
--- a/m4/expl.m4
+++ b/m4/expl.m4
@@ -87,5 +87,36 @@ AC_DEFUN([gl_FUNC_EXPL],
esac
fi
fi
+ dnl On some systems (OpenBSD5.4) the system's native expl() is buggy:
+ dnl it returns 'nan' for small values. This test compares expl() to exp() .
+ if test $gl_cv_func_expl_no_libm = yes \
+ || test $gl_cv_func_expl_in_libm = yes; then
+ AC_CACHE_CHECK([checks whether expl is buggy],
+ [gl_cv_func_expl_buggy],
+ [
+ save_LIBS="$LIBS"
+ LIBS="$EXPL_LIBM $FABS_LIBM"
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <math.h>
+]], [[ double l ;
+ int expl_ok = 1 ;
+ for (l=-3 ; l < 3 ; l+=0.001)
+ expl_ok &= (fabs(exp(l)-expl(l))<1e-10);
+ return expl_ok?0:1 ; ]])],
+ [gl_cv_func_func_expl_buggy=no], [gl_cv_func_expl_buggy=yes],
+ [case $host_os in
+ mingw*) gl_cv_func_expl_buggy="guessing no";;
+ *) gl_cv_func_expl_buggy="guessing yes";;
+ esac])
+ LIBS="$save_LIBS"
+ ])
+ if test $gl_cv_func_expl_buggy = yes; then
+ dnl TODO: Use gnulib's expl instead of the system's expl
+ AC_MSG_NOTICE([Detected buggy expl(), using gnulib's implementatin])
+ gl_cv_func_expl_in_libm=no
+ gl_cv_func_expl_no_libm=no
+ fi
+ fi
AC_SUBST([EXPL_LIBM])
])
--
1.9.1