From 38489e5cfd83f49b21b7d3d27b1cb405c8df28b4 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 18 Apr 2023 13:24:42 +0200 Subject: ilogbl: Work around a Cygwin 3.4.6 bug. * m4/ilogbl.m4 (gl_FUNC_ILOGBL_WORKS): Also test the value of ilogbl(NaN). * doc/posix-functions/ilogbl.texi: Mention the new Cygwin bug. --- ChangeLog | 7 +++++++ doc/posix-functions/ilogbl.texi | 4 ++++ m4/ilogbl.m4 | 24 +++++++++++++++++++++--- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 11de1e7d2e..0acab2a640 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-04-18 Bruno Haible + + ilogbl: Work around a Cygwin 3.4.6 bug. + * m4/ilogbl.m4 (gl_FUNC_ILOGBL_WORKS): Also test the value of + ilogbl(NaN). + * doc/posix-functions/ilogbl.texi: Mention the new Cygwin bug. + 2023-04-18 Bruno Haible file-has-acl tests: Avoid test failures on Cygwin 3.4.6. diff --git a/doc/posix-functions/ilogbl.texi b/doc/posix-functions/ilogbl.texi index a038376f88..dab44c8367 100644 --- a/doc/posix-functions/ilogbl.texi +++ b/doc/posix-functions/ilogbl.texi @@ -16,6 +16,10 @@ This function returns a wrong result for a zero argument on some platforms: @c https://cygwin.com/ml/cygwin/2019-12/msg00074.html Cygwin 2.9. @item +This function returns a wrong result for a NaN argument on some platforms: +@c https://cygwin.com/pipermail/cygwin/2023-April/253511.html +Cygwin 3.4.6. +@item This function returns a wrong result for denormalized arguments on some platforms: AIX 7.1 64-bit, Haiku 2017. @end itemize diff --git a/m4/ilogbl.m4 b/m4/ilogbl.m4 index 9081724b66..b25323e95f 100644 --- a/m4/ilogbl.m4 +++ b/m4/ilogbl.m4 @@ -1,4 +1,4 @@ -# ilogbl.m4 serial 5 +# ilogbl.m4 serial 6 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -72,6 +72,7 @@ AC_DEFUN([gl_FUNC_ILOGBL], dnl Test whether ilogbl() works. dnl On Cygwin 2.9, ilogbl(0.0L) is wrong. +dnl On Cygwin 3.4.6, ilogbl(NaN) is wrong. dnl On AIX 7.1 in 64-bit mode, ilogbl(2^(LDBL_MIN_EXP-1)) is wrong. dnl On Haiku 2017, it returns i-2 instead of i-1 for values between dnl ca. 2^-16444 and ca. 2^-16382. @@ -104,6 +105,17 @@ AC_DEFUN([gl_FUNC_ILOGBL_WORKS], # define LDBL_MIN_EXP DBL_MIN_EXP # endif #endif +/* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the + runtime type conversion. */ +#ifdef __sgi +static long double NaNl () +{ + double zero = 0.0; + return zero / zero; +} +#else +# define NaNl() (0.0L / 0.0L) +#endif volatile long double x; static int dummy (long double x) { return 0; } int main (int argc, char *argv[]) @@ -116,6 +128,12 @@ int main (int argc, char *argv[]) if (my_ilogbl (x) != FP_ILOGB0) result |= 1; } + /* This test fails on Cygwin 3.4.6. */ + { + x = NaNl (); + if (my_ilogbl (x) != FP_ILOGBNAN) + result |= 2; + } /* This test fails on AIX 7.1 in 64-bit mode. */ { int i; @@ -123,7 +141,7 @@ int main (int argc, char *argv[]) for (i = LDBL_MIN_EXP - 1; i < 0; i++) x = x * 0.5L; if (x > 0.0L && my_ilogbl (x) != LDBL_MIN_EXP - 2) - result |= 2; + result |= 4; } /* This test fails on Haiku 2017. */ { @@ -131,7 +149,7 @@ int main (int argc, char *argv[]) for (i = 1, x = (long double)1.0; i >= LDBL_MIN_EXP-100 && x > (long double)0.0; i--, x *= (long double)0.5) if (my_ilogbl (x) != i - 1) { - result |= 4; + result |= 8; break; } } -- cgit v1.2.1