>From 5beeeb81c77cbcf72a7b9635fbad87e69432e6fd Mon Sep 17 00:00:00 2001
From: Bruno Haible
Date: Sun, 29 Oct 2017 10:49:55 +0100
Subject: [PATCH 1/7] math: Fix test failure on Haiku.
---
ChangeLog | 8 ++++++++
doc/posix-headers/math.texi | 5 +++++
lib/math.in.h | 13 +++++++++++--
m4/ilogb.m4 | 12 ++++++++++--
m4/ilogbf.m4 | 12 ++++++++++--
5 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3102b6b..bae2722 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
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.
+ * m4/ilogbf.m4 (gl_FUNC_ILOGBF_WORKS): Likewise.
+ * doc/posix-headers/math.texi: Mention the Haiku problem.
+
+2017-10-29 Bruno Haible
+
gnulib-tool: Avoid unnecessary config.h.in remaking in testdirs.
* gnulib-tool (func_create_testdir): Use workaround against 'autoheader'
bug reported at .
diff --git a/doc/posix-headers/math.texi b/doc/posix-headers/math.texi
index 0cf56a0..bc89238 100644
--- a/doc/posix-headers/math.texi
+++ b/doc/posix-headers/math.texi
@@ -37,6 +37,11 @@ platforms:
NetBSD 5.1, AIX 5.1, IRIX 6.5, Solaris 9, MSVC 9.
@item
+The macros @code{FP_ILOGB0} and @code{FP_ILOGBNAN} have wrong values on some
+platforms:
+Haiku 2017.
+
address@hidden
The macros @code{NAN}, @code{HUGE_VALL}, and @code{INFINITY} are not
defined on some platforms:
OpenVMS.
diff --git a/lib/math.in.h b/lib/math.in.h
index f220151..09f822a 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -194,8 +194,17 @@ _NaN ()
#endif
-/* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */
-#if !(defined FP_ILOGB0 && defined FP_ILOGBNAN)
+#if defined FP_ILOGB0 && defined FP_ILOGBNAN
+ /* Ensure FP_ILOGB0 and FP_ILOGBNAN are correct. */
+# if defined __HAIKU__
+ /* Haiku: match what ilogb() does */
+# undef FP_ILOGB0
+# undef FP_ILOGBNAN
+# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
+# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
+# endif
+#else
+ /* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */
# if defined __NetBSD__ || defined __sgi
/* NetBSD, IRIX 6.5: match what ilogb() does */
# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
diff --git a/m4/ilogb.m4 b/m4/ilogb.m4
index 1d56ecb..a73d7ad 100644
--- a/m4/ilogb.m4
+++ b/m4/ilogb.m4
@@ -1,4 +1,4 @@
-# ilogb.m4 serial 2
+# ilogb.m4 serial 3
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,
@@ -57,7 +57,15 @@ AC_DEFUN([gl_FUNC_ILOGB_WORKS],
#include
#include
/* Provide FP_ILOGB0, FP_ILOGBNAN, like in math.in.h. */
-#if !(defined FP_ILOGB0 && defined FP_ILOGBNAN)
+#if defined FP_ILOGB0 && defined FP_ILOGBNAN
+# if defined __HAIKU__
+ /* Haiku: match what ilogb() does */
+# undef FP_ILOGB0
+# undef FP_ILOGBNAN
+# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
+# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
+# endif
+#else
# if defined __NetBSD__ || defined __sgi
/* NetBSD, IRIX 6.5: match what ilogb() does */
# define FP_ILOGB0 INT_MIN
diff --git a/m4/ilogbf.m4 b/m4/ilogbf.m4
index 4e16e07..a660108 100644
--- a/m4/ilogbf.m4
+++ b/m4/ilogbf.m4
@@ -1,4 +1,4 @@
-# ilogbf.m4 serial 2
+# ilogbf.m4 serial 3
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,
@@ -59,7 +59,15 @@ AC_DEFUN([gl_FUNC_ILOGBF_WORKS],
#include
#include
/* Provide FP_ILOGB0, FP_ILOGBNAN, like in math.in.h. */
-#if !(defined FP_ILOGB0 && defined FP_ILOGBNAN)
+#if defined FP_ILOGB0 && defined FP_ILOGBNAN
+# if defined __HAIKU__
+ /* Haiku: match what ilogb() does */
+# undef FP_ILOGB0
+# undef FP_ILOGBNAN
+# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
+# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
+# endif
+#else
# if defined __NetBSD__ || defined __sgi
/* NetBSD, IRIX 6.5: match what ilogbf() does */
# define FP_ILOGB0 INT_MIN
--
2.7.4