Work around a MacOS X 10.5 bug in frexpl().
authorBruno Haible <bruno@clisp.org>
Tue, 15 Jan 2008 23:21:10 +0000 (00:21 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 15 Jan 2008 23:21:10 +0000 (00:21 +0100)
ChangeLog
doc/functions/frexpl.texi
m4/frexpl.m4

index 2f8cdb1..a457d34 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-01-15  Bruno Haible  <bruno@clisp.org>
+
+       Work around a MacOS X 10.5 bug in frexpl().
+       * m4/frexpl.m4 (gl_FUNC_FREXPL_WORKS): Also check denormalized numbers.
+       * doc/functions/frexpl.texi: Document the bug.
+       Reported by Elias Pipping <pipping@gentoo.org>.
+
 2008-01-14  Eric Blake  <ebb9@byu.net>
 
        Touch up previous patch.
index 400b51f..7c8b263 100644 (file)
@@ -15,6 +15,9 @@ FreeBSD 5.2.1, NetBSD 3.0, OpenBSD 3.8, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, I
 This function does not work on finite numbers on some platforms:
 MacOS X 10.4/PowerPC, AIX 5.1, BeOS.
 @item
+This function does not work on denormalized numbers on some platforms:
+MacOS X 10.5/i386.
+@item
 This function does not work on infinite numbers on some platforms:
 IRIX 6.5, mingw.
 @end itemize
index 01cb1d9..a4f2bd8 100644 (file)
@@ -1,5 +1,5 @@
-# frexpl.m4 serial 6
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+# frexpl.m4 serial 7
+dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -96,8 +96,9 @@ AC_DEFUN([gl_FUNC_FREXPL_NO_LIBM],
 ])
 
 dnl Test whether frexpl() works on finite numbers (this fails on
-dnl MacOS X 10.4/PowerPC, on AIX 5.1, and on BeOS) and also on infinite numbers
-dnl (this fails e.g. on IRIX 6.5 and mingw).
+dnl MacOS X 10.4/PowerPC, on AIX 5.1, and on BeOS), on denormalized numbers
+dnl (this fails on MacOS X 10.5/i386), and also on infinite numbers (this
+dnl fails e.g. on IRIX 6.5 and mingw).
 AC_DEFUN([gl_FUNC_FREXPL_WORKS],
 [
   AC_REQUIRE([AC_PROG_CC])
@@ -144,6 +145,21 @@ int main()
           return 1;
       }
   }
+  /* Test on denormalized numbers.  */
+  {
+    int i;
+    for (i = 1, x = 1.0L; i >= LDBL_MIN_EXP; i--, x *= 0.5L)
+      ;
+    if (x > 0.0L)
+      {
+        int exp;
+        long double y = frexpl (x, &exp);
+        /* On machines with IEEE854 arithmetic: x = 1.68105e-4932,
+           exp = -16382, y = 0.5.  On MacOS X 10.5: exp = -16384, y = 0.5.  */
+        if (exp != LDBL_MIN_EXP - 1)
+          return 1;
+      }
+  }
   /* Test on infinite numbers.  */
   x = 1.0L / 0.0L;
   {