From 990643f1f6877f4abc7e1eaff7d93507e41e4fcb Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 1 Jul 2017 17:10:31 +0200 Subject: [PATCH] logbl: Work around a glibc bug on PowerPC64LE. * m4/logbl.m4 (gl_FUNC_LOGBL_WORKS): Test also negative subnormal numbers. * doc/posix-functions/logbl.texi: Update. --- ChangeLog | 7 +++++++ doc/posix-functions/logbl.texi | 3 ++- m4/logbl.m4 | 13 ++++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7cce6df797..c10c2c328d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2017-07-01 Bruno Haible + + logbl: Work around a glibc bug on PowerPC64LE. + * m4/logbl.m4 (gl_FUNC_LOGBL_WORKS): Test also negative subnormal + numbers. + * doc/posix-functions/logbl.texi: Update. + 2017-06-29 Bruno Haible stat, fstat: Compile stat-w32.c only on platforms that need it. diff --git a/doc/posix-functions/logbl.texi b/doc/posix-functions/logbl.texi index fd9c384d98..857c776bd6 100644 --- a/doc/posix-functions/logbl.texi +++ b/doc/posix-functions/logbl.texi @@ -13,7 +13,8 @@ This function is missing on some platforms: FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, older IRIX 6.5, Solaris 9, Cygwin, MSVC 9, Interix 3.5, BeOS. @item This function produces wrong results for subnormal numbers on some platforms: -glibc 2.11/ppc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 11 2011-11. +glibc 2.11/powerpc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 11 2011-11, +glibc 2.23/powerpc64le. @end itemize Portability problems not fixed by Gnulib: diff --git a/m4/logbl.m4 b/m4/logbl.m4 index db0a36d5ed..5e236f5de6 100644 --- a/m4/logbl.m4 +++ b/m4/logbl.m4 @@ -1,4 +1,4 @@ -# logbl.m4 serial 2 +# logbl.m4 serial 3 dnl Copyright (C) 2012-2017 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -54,8 +54,10 @@ AC_DEFUN([gl_FUNC_LOGBL], ]) dnl Test whether logbl() works. -dnl On glibc 2.11/ppc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 10/SPARC, the -dnl return value for subnormal (denormalized) arguments is too large. +dnl On glibc 2.11/powerpc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 10/SPARC, +dnl the return value for subnormal (denormalized) arguments is too large. +dnl On glibc 2.23/powerpc64le, the return value for negative subnormal arguments +dnl is too large. AC_DEFUN([gl_FUNC_LOGBL_WORKS], [ AC_REQUIRE([AC_PROG_CC]) @@ -94,6 +96,11 @@ int main () if ((i == LDBL_MIN_EXP - 1 || i == LDBL_MIN_EXP - 54) && (x > 0.0L && !(logbl (x) == (long double)(i - 1)))) return 1; + for (i = 1, x = -1.0L; i >= LDBL_MIN_EXP - 54; i--, x *= 0.5L) + /* Either x = -2^(i-1) or x = 0.0. */ + if ((i == LDBL_MIN_EXP - 1 || i == LDBL_MIN_EXP - 54) + && (x < 0.0L && !(logbl (x) == (long double)(i - 1)))) + return 1; return 0; } ]])], -- 2.39.5