From 6ead6fb5989d246b06d28ae343cc1e8a319c1676 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 16 Jan 2008 00:21:10 +0100 Subject: [PATCH] Work around a MacOS X 10.5 bug in frexpl(). --- ChangeLog | 7 +++++++ doc/functions/frexpl.texi | 3 +++ m4/frexpl.m4 | 24 ++++++++++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2f8cdb18b..a457d3472 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-01-15 Bruno Haible + + 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 . + 2008-01-14 Eric Blake Touch up previous patch. diff --git a/doc/functions/frexpl.texi b/doc/functions/frexpl.texi index 400b51fc4..7c8b263f5 100644 --- a/doc/functions/frexpl.texi +++ b/doc/functions/frexpl.texi @@ -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 diff --git a/m4/frexpl.m4 b/m4/frexpl.m4 index 01cb1d9ed..a4f2bd8cc 100644 --- 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 @@ 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; { -- 2.11.0