From a461bce78a8a664f77ce1fff4a6c9512347ae124 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 6 Apr 2024 12:01:59 +0200 Subject: [PATCH] expm1l: Work around a NetBSD 10.0/i386 bug. * m4/expm1l.m4 (gl_FUNC_EXPM1L): Test the value of expm1l(2^LDBL_MIN_EXP). * tests/test-expm1.h (test_function): Allow more deviation on NetBSD/i386. --- ChangeLog | 8 ++++++++ m4/expm1l.m4 | 18 +++++++++++++++--- tests/test-expm1.h | 8 ++++++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1700343465..920e0a6a88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-04-06 Bruno Haible + + expm1l: Work around a NetBSD 10.0/i386 bug. + * m4/expm1l.m4 (gl_FUNC_EXPM1L): Test the value of + expm1l(2^LDBL_MIN_EXP). + * tests/test-expm1.h (test_function): Allow more deviation on + NetBSD/i386. + 2024-04-05 Bruno Haible exp2l: Work around a NetBSD 10.0/i386 bug. diff --git a/m4/expm1l.m4 b/m4/expm1l.m4 index 78c7a3d579..437599088e 100644 --- a/m4/expm1l.m4 +++ b/m4/expm1l.m4 @@ -1,5 +1,5 @@ -# expm1l.m4 serial 10 -dnl Copyright (C) 2010-2023 Free Software Foundation, Inc. +# expm1l.m4 serial 10.1 +dnl Copyright (C) 2010-2024 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. @@ -124,7 +124,7 @@ int main (int argc, char *argv[]) long double (* volatile my_expm1l) (long double) = argc ? expm1l : dummy; int result = 0; /* This test fails on musl 1.2.2/arm64, musl 1.2.2/s390x, Mac OS X 10.5, - NetBSD 8.0. */ + NetBSD 10.0/x86_64. */ { const long double TWO_LDBL_MANT_DIG = /* 2^LDBL_MANT_DIG */ (long double) (1U << ((LDBL_MANT_DIG - 1) / 5)) @@ -140,6 +140,18 @@ int main (int argc, char *argv[]) if (!(err >= -100.0L && err <= 100.0L)) result |= 1; } + /* This test fails on NetBSD 10.0/i386. */ + { + int i; + long double x; + volatile long double y; + for (i = -1, x = 0.5L; i > LDBL_MIN_EXP; i--, x *= 0.5L) + ; + /* Here i = LDBL_MIN_EXP, x = 2^LDBL_MIN_EXP. */ + y = my_expm1l (x); + if (!(y >= x)) + result |= 2; + } return result; } ]])], diff --git a/tests/test-expm1.h b/tests/test-expm1.h index 68f3f6be6f..fc92617a05 100644 --- a/tests/test-expm1.h +++ b/tests/test-expm1.h @@ -1,5 +1,5 @@ /* Test of expm1*() function family. - Copyright (C) 2012-2023 Free Software Foundation, Inc. + Copyright (C) 2012-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -52,7 +52,9 @@ test_function (void) /* Error bound, in ulps. */ const DOUBLE err_bound = (sizeof (DOUBLE) > sizeof (double) ? -#if defined __i386__ && defined __FreeBSD__ +#if defined __i386__ && defined __NetBSD__ + L_(1025.0) +#elif defined __i386__ && defined __FreeBSD__ /* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of precision in the compiler but 64 bits of precision at runtime. See . @@ -83,6 +85,8 @@ test_function (void) (sizeof (DOUBLE) > sizeof (double) ? #if defined __i386__ && defined __FreeBSD__ L_(1536.0) +#elif defined __i386__ && defined __NetBSD__ + L_(1026.0) #else L_(11.0) #endif -- 2.39.5