changeset 38918:9675e3175444

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.
author Bruno Haible <bruno@clisp.org>
date Sun, 29 Oct 2017 11:16:56 +0100
parents 35d659fed9b4
children b8611026be0c
files ChangeLog doc/posix-functions/expl.texi m4/expl.m4
diffstat 3 files changed, 39 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Oct 29 10:49:55 2017 +0100
+++ b/ChangeLog	Sun Oct 29 11:16:56 2017 +0100
@@ -1,3 +1,10 @@
+2017-10-29  Bruno Haible  <bruno@clisp.org>
+
+	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  <bruno@clisp.org>
 
 	math: Fix test failure on Haiku.
--- a/doc/posix-functions/expl.texi	Sun Oct 29 10:49:55 2017 +0100
+++ b/doc/posix-functions/expl.texi	Sun Oct 29 11:16:56 2017 +0100
@@ -12,7 +12,10 @@
 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.
+@item
+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:
--- a/m4/expl.m4	Sun Oct 29 10:49:55 2017 +0100
+++ b/m4/expl.m4	Sun Oct 29 11:16:56 2017 +0100
@@ -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 @@
       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 <math.h>]],
-             [[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 <math.h>]],
+            [[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