]> Savannah Git Hosting - gnulib.git/commitdiff
ceill: detect buggy OpenBSD implementation
authorAssaf Gordon <assafgordon@gmail.com>
Tue, 8 Sep 2015 23:43:32 +0000 (19:43 -0400)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 9 Sep 2015 00:21:52 +0000 (17:21 -0700)
* m4/ceill.m4 (gl_FUNC_CEILL): Detect buggy openBSD implementation
which returns zero for small values.  Discussed here:
http://lists.gnu.org/archive/html/bug-gnulib/2015-08/msg00010.html

ChangeLog
m4/ceill.m4

index 04e8f1b08a559a1d4116a157b25d28b028c828f0..de20d36abb85de1b0474476978482187b625ce93 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-09-08   Assaf Gordon  <assafgordon@gmail.com>
+
+       ceill: detect buggy OpenBSD implementation
+       * m4/ceill.m4 (gl_FUNC_CEILL): Detect buggy openBSD implementation
+       which returns zero for small values.  Discussed here:
+       http://lists.gnu.org/archive/html/bug-gnulib/2015-08/msg00010.html
+
 2015-09-08  Dave Chiluk  <chiluk@canonical.com>
 
        mountlist: add me_mntroot field on Linux machines
index 51c0c56c4ff62cf3a8af47b0ecac50d66938ba57..b4afe62dfc8a4ad7b7c24c5551a52be1178605ee 100644 (file)
@@ -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