changeset 9625:a64830157230

Work around a MacOS X 10.5 bug in frexpl().
author Bruno Haible <bruno@clisp.org>
date Wed, 16 Jan 2008 00:21:10 +0100
parents 1e2b5f620c05
children def4f669ceac
files ChangeLog doc/functions/frexpl.texi m4/frexpl.m4
diffstat 3 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/doc/functions/frexpl.texi
+++ b/doc/functions/frexpl.texi
@@ -15,6 +15,9 @@
 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
--- a/m4/frexpl.m4
+++ b/m4/frexpl.m4
@@ -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 @@
 ])
 
 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 @@
           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;
   {