math: Provide FP_ILOGB0 and FP_ILOGBNAN.
authorBruno Haible <bruno@clisp.org>
Tue, 3 Apr 2012 15:04:46 +0000 (17:04 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 3 Apr 2012 16:58:51 +0000 (18:58 +0200)
* lib/math.in.h (FP_ILOGB0, FP_ILOGBNAN): Define fallback.
* tests/test-math.c: Check that FP_ILOGB0, FP_ILOGBNAN are defined.
(main): Check their values.
* doc/posix-headers/math.texi: Mention the FP_ILOGB0, FP_ILOGBNAN
problem.

ChangeLog
doc/posix-headers/math.texi
lib/math.in.h
tests/test-math.c

index b3ec015..00493ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2012-04-03  Bruno Haible  <bruno@clisp.org>
 
+       math: Provide FP_ILOGB0 and FP_ILOGBNAN.
+       * lib/math.in.h (FP_ILOGB0, FP_ILOGBNAN): Define fallback.
+       * tests/test-math.c: Check that FP_ILOGB0, FP_ILOGBNAN are defined.
+       (main): Check their values.
+       * doc/posix-headers/math.texi: Mention the FP_ILOGB0, FP_ILOGBNAN
+       problem.
+
+2012-04-03  Bruno Haible  <bruno@clisp.org>
+
        Tests for module 'logbl-ieee'.
        * modules/logbl-ieee-tests: New file.
        * tests/test-logbl-ieee.c: New file.
index d4578d1..e640663 100644 (file)
@@ -30,6 +30,11 @@ Solaris 10.
 The macros @code{HUGE_VALF} and @code{HUGE_VALL} are not defined on some
 platforms:
 glibc/HPPA, glibc/SPARC, AIX 5.1, IRIX 6.5, Solaris 9, MSVC 9.
+
+@item
+The macros @code{FP_ILOGB0} and @code{FP_ILOGBNAN} are not defined on some
+platforms:
+NetBSD 5.1, AIX 5.1, IRIX 6.5, Solaris 9, MSVC 9.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 10cabe0..b87aacb 100644 (file)
@@ -179,6 +179,29 @@ _NaN ()
 # endif
 #endif
 
+
+/* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined.  */
+#if !(defined FP_ILOGB0 && defined FP_ILOGBNAN)
+# if defined __NetBSD__ || defined __sgi
+  /* NetBSD, IRIX 6.5: match what ilogb() does */
+#  define FP_ILOGB0   (- 2147483647 - 1) /* INT_MIN */
+#  define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
+# elif defined _AIX
+  /* AIX 5.1: match what ilogb() does in AIX >= 5.2 */
+#  define FP_ILOGB0   (- 2147483647 - 1) /* INT_MIN */
+#  define FP_ILOGBNAN 2147483647 /* INT_MAX */
+# elif defined __sun
+  /* Solaris 9: match what ilogb() does */
+#  define FP_ILOGB0   (- 2147483647) /* - INT_MAX */
+#  define FP_ILOGBNAN 2147483647 /* INT_MAX */
+# else
+  /* Gnulib defined values.  */
+#  define FP_ILOGB0   (- 2147483647) /* - INT_MAX */
+#  define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
+# endif
+#endif
+
+
 #if @GNULIB_ACOSF@
 # if !@HAVE_ACOSF@
 #  undef acosf
index 25be63a..1375e76 100644 (file)
@@ -40,6 +40,18 @@ choke me
 choke me
 #endif
 
+#ifndef FP_ILOGB0
+# error FP_ILOGB0 should be defined
+choke me
+#endif
+
+#ifndef FP_ILOGBNAN
+# error FP_ILOGBNAN should be defined
+choke me
+#endif
+
+#include <limits.h>
+
 #include "macros.h"
 
 #if 0
@@ -82,5 +94,11 @@ main (void)
 
   ASSERT (numeric_equall (HUGE_VALL, HUGE_VALL + HUGE_VALL));
 
+  /* Check the value of FP_ILOGB0.  */
+  ASSERT (FP_ILOGB0 == INT_MIN || FP_ILOGB0 == - INT_MAX);
+
+  /* Check the value of FP_ILOGBNAN.  */
+  ASSERT (FP_ILOGBNAN == INT_MIN || FP_ILOGBNAN == INT_MAX);
+
   return 0;
 }