On Wed, Aug 12, 2015 at 11:26:33AM -0700, Paul Eggert wrote:
Assaf Gordon wrote:
2. Similar to 'gl_cv_func_expl_buggy' in 'm4/expl.m4',
add 'gl_cv_func_ceill_buggy' in 'm4/ceill.m4'.
<...>
Can you redo the patch so that it detects the bug with the default
CFLAGS and GCC? Something like the following, say:
Attached an improved version.
Tested to set 'buggy=yes' on OpenBSD 5.6 and 5.7, and 'buggy=no' on
other OSes (FreeBSD 9/10, NetBSD 7RC1, Hurd, Solaris and GNU/Linuxes
with gcc and clang).
>From a2abacb8133f07c9aa629db03a8e9008d0d15931 Mon Sep 17 00:00:00 2001
From: Assaf Gordon <assafgor...@gmail.com>
Date: Wed, 12 Aug 2015 13:56:32 -0400
Subject: [PATCH] ceill: detect buggy OpenBSD implementation
* m4/ceill.m4: detect buggy openBSD implementation which returns zero
for small values. discussed here:
http://lists.gnu.org/archive/html/bug-gnulib/2015-08/msg00010.html
---
m4/ceill.m4 | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/m4/ceill.m4 b/m4/ceill.m4
index 51c0c56..756d29a 100644
--- a/m4/ceill.m4
+++ b/m4/ceill.m4
@@ -69,6 +69,31 @@ int main (int argc, char *argv[])
else
HAVE_DECL_CEILL=0
fi
+ dnl On OpenBSD5.6 the system's native ceill() is buggy:
+ dnl it returns '0' for small values. Test for this anomaly.
+ if test $REPLACE_CEILL = 0 ; then
+ AC_CACHE_CHECK([whether ceill() breaks with small values],
+ [gl_cv_func_ceill_buggy],
+ [
+ save_LIBS="$LIBS"
+ LIBS="$CEILL_LIBM"
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <math.h>
+long double d = 0.3L;]],
+ [[return (!(ceill(d)==1)); ]])],
+ [gl_cv_func_ceill_buggy=no], [gl_cv_func_ceill_buggy=yes],
+ [case $host_os in
+ openbsd*) gl_cv_func_ceill_buggy="guessing yes";;
+ *) gl_cv_func_ceill_buggy="guessing no";;
+ esac])
+ LIBS="$save_LIBS"
+ ])
+ case "$gl_cv_func_ceill_buggy" in
+ *yes)
+ REPLACE_CEILL=1 ;;
+ esac
+ fi
if test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1; then
dnl Find libraries needed to link lib/ceill.c.
if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
--
1.9.1