CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Tue May 14 15:31:42 UTC 2024 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: t_ilogb: Nix spurious line break in ATF_CHECK_MSG. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Tue May 14 15:31:42 UTC 2024 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: t_ilogb: Nix spurious line break in ATF_CHECK_MSG. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ilogb.c diff -u src/tests/lib/libm/t_ilogb.c:1.10 src/tests/lib/libm/t_ilogb.c:1.11 --- src/tests/lib/libm/t_ilogb.c:1.10 Thu May 9 12:23:21 2024 +++ src/tests/lib/libm/t_ilogb.c Tue May 14 15:31:42 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ilogb.c,v 1.10 2024/05/09 12:23:21 riastradh Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.11 2024/05/14 15:31:42 riastradh Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: t_ilogb.c,v 1.10 2024/05/09 12:23:21 riastradh Exp $"); +__RCSID("$NetBSD: t_ilogb.c,v 1.11 2024/05/14 15:31:42 riastradh Exp $"); #include #include @@ -50,14 +50,14 @@ __RCSID("$NetBSD: t_ilogb.c,v 1.10 2024/ # define ATF_CHECK_RAISED_INVALID do { \ int r = fetestexcept(FE_ALL_EXCEPT); \ ATF_CHECK_MSG((r & FE_INVALID) != 0, \ - "r & FE_INVALID == 0 (r=%#x, FE_INVALID=%#x)\n", \ + "r & FE_INVALID == 0 (r=%#x, FE_INVALID=%#x)", \ r, FE_INVALID); \ (void)feclearexcept(FE_ALL_EXCEPT); \ } while (/*CONSTCOND*/0) # define ATF_CHECK_RAISED_NOTHING do { \ int r = fetestexcept(FE_ALL_EXCEPT); \ - ATF_CHECK_MSG(r == 0, "r=%#x != 0\n", r); \ + ATF_CHECK_MSG(r == 0, "r=%#x != 0", r); \ (void)feclearexcept(FE_ALL_EXCEPT); \ } while (/*CONSTCOND*/0)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: rillig Date: Mon May 13 20:28:15 UTC 2024 Modified Files: src/tests/lib/libm: t_hypot.c Log Message: tests/t_hypot: actually add nan test To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: rillig Date: Mon May 13 20:28:15 UTC 2024 Modified Files: src/tests/lib/libm: t_hypot.c Log Message: tests/t_hypot: actually add nan test To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_hypot.c diff -u src/tests/lib/libm/t_hypot.c:1.7 src/tests/lib/libm/t_hypot.c:1.8 --- src/tests/lib/libm/t_hypot.c:1.7 Sun May 12 20:58:44 2024 +++ src/tests/lib/libm/t_hypot.c Mon May 13 20:28:15 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_hypot.c,v 1.7 2024/05/12 20:58:44 riastradh Exp $ */ +/* $NetBSD: t_hypot.c,v 1.8 2024/05/13 20:28:15 rillig Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -689,6 +689,7 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, hypot_exact); + ATF_TP_ADD_TC(tp, hypot_nan); ATF_TP_ADD_TC(tp, hypot_trivial); ATF_TP_ADD_TC(tp, hypotf_exact); ATF_TP_ADD_TC(tp, hypotf_trivial);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun May 12 21:53:26 UTC 2024 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: tests/lib/libm/t_fenv: Work around PR 58253. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.16 src/tests/lib/libm/t_fenv.c:1.17 --- src/tests/lib/libm/t_fenv.c:1.16 Mon Mar 18 16:33:54 2024 +++ src/tests/lib/libm/t_fenv.c Sun May 12 21:53:26 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.16 2024/03/18 16:33:54 martin Exp $ */ +/* $NetBSD: t_fenv.c,v 1.17 2024/05/12 21:53:26 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.16 2024/03/18 16:33:54 martin Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.17 2024/05/12 21:53:26 riastradh Exp $"); #include @@ -341,6 +341,17 @@ ATF_TC_BODY(feenableexcept, tc) (int)fpgetmask(), (int)FP_X_INV); } +/* + * Temporary workaround for PR 58253: powerpc has more fenv exception + * bits than it can handle. + */ +#if defined __powerpc__ +#define FE_TRAP_EXCEPT \ + (FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW) +#else +#define FE_TRAP_EXCEPT FE_ALL_EXCEPT +#endif + ATF_TC(fetestexcept_trap); ATF_TC_HEAD(fetestexcept_trap, tc) { @@ -353,21 +364,21 @@ ATF_TC_BODY(fetestexcept_trap, tc) FPU_EXC_PREREQ(); - fedisableexcept(FE_ALL_EXCEPT); + fedisableexcept(FE_TRAP_EXCEPT); ATF_CHECK_EQ_MSG((except = fegetexcept()), 0, "fegetexcept()=0x%x", except); - (void)fetestexcept(FE_ALL_EXCEPT); + (void)fetestexcept(FE_TRAP_EXCEPT); ATF_CHECK_EQ_MSG((except = fegetexcept()), 0, "fegetexcept()=0x%x", except); - feenableexcept(FE_ALL_EXCEPT); - ATF_CHECK_EQ_MSG((except = fegetexcept()), FE_ALL_EXCEPT, - "fegetexcept()=0x%x FE_ALL_EXCEPT=0x%x", except, FE_ALL_EXCEPT); - - (void)fetestexcept(FE_ALL_EXCEPT); - ATF_CHECK_EQ_MSG((except = fegetexcept()), FE_ALL_EXCEPT, - "fegetexcept()=0x%x FE_ALL_EXCEPT=0x%x", except, FE_ALL_EXCEPT); + feenableexcept(FE_TRAP_EXCEPT); + ATF_CHECK_EQ_MSG((except = fegetexcept()), FE_TRAP_EXCEPT, + "fegetexcept()=0x%x FE_TRAP_EXCEPT=0x%x", except, FE_TRAP_EXCEPT); + + (void)fetestexcept(FE_TRAP_EXCEPT); + ATF_CHECK_EQ_MSG((except = fegetexcept()), FE_TRAP_EXCEPT, + "fegetexcept()=0x%x FE_ALL_EXCEPT=0x%x", except, FE_TRAP_EXCEPT); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun May 12 21:53:26 UTC 2024 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: tests/lib/libm/t_fenv: Work around PR 58253. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun May 12 20:58:44 UTC 2024 Modified Files: src/tests/lib/libm: t_hypot.c Log Message: t_hypot: Use an ld80 test case that actually fits in ld80. Also add comments explaining how I generated these test cases. (No autoconf back doors hidden in these magic numbers, I promise! No pythagoreans were harmed in the production of these tests either.) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun May 12 20:58:44 UTC 2024 Modified Files: src/tests/lib/libm: t_hypot.c Log Message: t_hypot: Use an ld80 test case that actually fits in ld80. Also add comments explaining how I generated these test cases. (No autoconf back doors hidden in these magic numbers, I promise! No pythagoreans were harmed in the production of these tests either.) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_hypot.c diff -u src/tests/lib/libm/t_hypot.c:1.6 src/tests/lib/libm/t_hypot.c:1.7 --- src/tests/lib/libm/t_hypot.c:1.6 Sat May 11 20:51:41 2024 +++ src/tests/lib/libm/t_hypot.c Sun May 12 20:58:44 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_hypot.c,v 1.6 2024/05/11 20:51:41 riastradh Exp $ */ +/* $NetBSD: t_hypot.c,v 1.7 2024/05/12 20:58:44 riastradh Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -440,6 +440,23 @@ ATF_TC_BODY(hypotl_trivial, tc) } } +/* + * All primitive Pythagorean triples are generated from coprime + * integers m > n > 0 by Euclid's formula, + * + * a = m^2 - n^2 + * b = 2 m n, + * c = m^2 + n^2. + * + * We test cases with various different numbers and positions of bits, + * generated by this formula. + * + * If you're curious, you can recover m and n from a, b, and c by + * + * m = sqrt((a + c)/2) + * n = b/2m. + */ + __CTASSERT(FLT_MANT_DIG >= 24); static const struct { float a, b, c; @@ -468,7 +485,7 @@ static const struct { long double a, b, c; } exact_casesl[] = { { 3458976450080784639, 4611968592949214720, 5764960744407842561 }, - { 0x1, 0x1fffep0L, 0x1fffe0001p0L }, + { 0x2, 0x7ffe, 0x8002 }, #if LDBL_MANT_DIG >= 113 { 973555668229277869436257492279295.L, 1298074224305703705819019479072768.L,
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun May 12 20:17:57 UTC 2024 Modified Files: src/tests/lib/libm: t_next.c Log Message: tests/lib/libm/t_next: Disable a test if long double is double. This test, to verify nexttoward(x, x*(1 - LDBL_EPSILON/2)) moves in the direction of x*(1 - LDBL_EPSILON/2), only makes sense if long double has more precision than double -- the point of the exercise is to verify that nexttoward moves even if the direction parameter can't be rounded to double. But if long double is just double, this test makes no sense. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_next.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_next.c diff -u src/tests/lib/libm/t_next.c:1.6 src/tests/lib/libm/t_next.c:1.7 --- src/tests/lib/libm/t_next.c:1.6 Sat May 11 02:07:54 2024 +++ src/tests/lib/libm/t_next.c Sun May 12 20:17:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_next.c,v 1.6 2024/05/11 02:07:54 riastradh Exp $ */ +/* $NetBSD: t_next.c,v 1.7 2024/05/12 20:17:57 riastradh Exp $ */ /*- * Copyright (c) 2024 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: t_next.c,v 1.6 2024/05/11 02:07:54 riastradh Exp $"); +__RCSID("$NetBSD: t_next.c,v 1.7 2024/05/12 20:17:57 riastradh Exp $"); #include #include @@ -110,10 +110,12 @@ check(const double *x, unsigned n) for (i = n; i --> 1;) { ATF_REQUIRE_MSG(x[i - 1] < x[i], "i=%u", i); +#ifdef __HAVE_LONG_DOUBLE if (isnormal(x[i])) { CHECK(i, nexttoward, x[i], x[i]*(1 - LDBL_EPSILON/2), x[i - 1]); } +#endif CHECK(i, nextafter, x[i], x[i - 1], x[i - 1]); CHECK(i, nexttoward, x[i], x[i - 1], x[i - 1]);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun May 12 20:17:57 UTC 2024 Modified Files: src/tests/lib/libm: t_next.c Log Message: tests/lib/libm/t_next: Disable a test if long double is double. This test, to verify nexttoward(x, x*(1 - LDBL_EPSILON/2)) moves in the direction of x*(1 - LDBL_EPSILON/2), only makes sense if long double has more precision than double -- the point of the exercise is to verify that nexttoward moves even if the direction parameter can't be rounded to double. But if long double is just double, this test makes no sense. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_next.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat May 11 21:27:53 UTC 2024 Modified Files: src/tests/lib/libm: t_asin.c Log Message: tests/lib/libm/t_asin: Cite PR lib/58246. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_asin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_asin.c diff -u src/tests/lib/libm/t_asin.c:1.4 src/tests/lib/libm/t_asin.c:1.5 --- src/tests/lib/libm/t_asin.c:1.4 Wed Nov 7 03:59:36 2018 +++ src/tests/lib/libm/t_asin.c Sat May 11 21:27:53 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_asin.c,v 1.4 2018/11/07 03:59:36 riastradh Exp $ */ +/* $NetBSD: t_asin.c,v 1.5 2024/05/11 21:27:53 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -240,8 +240,9 @@ ATF_TC_BODY(asinf_inrange, tc) float y = values[i].y; if (fabs(x) == 0.5) - atf_tc_expect_fail("asinf is busted," - " gives ~2ulp error"); + atf_tc_expect_fail("PR lib/58246:" + " asinf gives ~2ulp error" + " when it should give <1ulp"); if (!(fabsf((asinf(x) - y)/y) <= eps)) { atf_tc_fail_nonfatal("asinf(%.8g) = %.8g != %.8g," " error=~%.1fulp",
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat May 11 21:27:53 UTC 2024 Modified Files: src/tests/lib/libm: t_asin.c Log Message: tests/lib/libm/t_asin: Cite PR lib/58246. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_asin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat May 11 20:51:41 UTC 2024 Modified Files: src/tests/lib/libm: t_hypot.c Log Message: tests/lib/libm/t_hypot: Check inf/nan cases too. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat May 11 20:51:41 UTC 2024 Modified Files: src/tests/lib/libm: t_hypot.c Log Message: tests/lib/libm/t_hypot: Check inf/nan cases too. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_hypot.c diff -u src/tests/lib/libm/t_hypot.c:1.5 src/tests/lib/libm/t_hypot.c:1.6 --- src/tests/lib/libm/t_hypot.c:1.5 Sat May 11 20:09:47 2024 +++ src/tests/lib/libm/t_hypot.c Sat May 11 20:51:41 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_hypot.c,v 1.5 2024/05/11 20:09:47 riastradh Exp $ */ +/* $NetBSD: t_hypot.c,v 1.6 2024/05/11 20:51:41 riastradh Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -38,7 +38,18 @@ #define CHECKL_EQ(i, hypot, a, b, c) \ ATF_CHECK_MSG(hypot(a, b) == (c), \ "[%u] %s(%La, %La)=%La, expected %La", \ - (i), #hypot, (a), (b), hypot(a, b), (c)) + (i), #hypot, (long double)(a), (long double)(b), hypot(a, b), \ + (long double)(c)) + +#define CHECK_NAN(i, hypot, a, b) \ + ATF_CHECK_MSG(isnan(hypot(a, b)), \ + "[%u] %s(%a, %a)=%a, expected NaN", \ + (i), #hypot, (a), (b), hypot(a, b)) + +#define CHECKL_NAN(i, hypot, a, b) \ + ATF_CHECK_MSG(isnan(hypot(a, b)), \ + "[%u] %s(%La, %La)=%La, expected NaN", \ + (i), #hypot, (long double)(a), (long double)(b), hypot(a, b)) static const float trivial_casesf[] = { 0, @@ -191,6 +202,31 @@ ATF_TC_BODY(hypotf_trivial, tc) CHECK_EQ(i, hypotf, -x, -0., x); CHECK_EQ(i, hypotf, +0., -x, x); CHECK_EQ(i, hypotf, -0., -x, x); + + if (isinf(INFINITY)) { + CHECK_EQ(i, hypotf, x, +INFINITY, INFINITY); + CHECK_EQ(i, hypotf, x, -INFINITY, INFINITY); + CHECK_EQ(i, hypotf, +INFINITY, x, INFINITY); + CHECK_EQ(i, hypotf, -INFINITY, x, INFINITY); + CHECK_EQ(i, hypotf, -x, +INFINITY, INFINITY); + CHECK_EQ(i, hypotf, -x, -INFINITY, INFINITY); + CHECK_EQ(i, hypotf, +INFINITY, -x, INFINITY); + CHECK_EQ(i, hypotf, -INFINITY, -x, INFINITY); + } + +#ifdef NAN + if (isinf(x)) { + CHECK_EQ(i, hypotf, x, NAN, INFINITY); + CHECK_EQ(i, hypotf, NAN, x, INFINITY); + CHECK_EQ(i, hypotf, -x, NAN, INFINITY); + CHECK_EQ(i, hypotf, NAN, -x, INFINITY); + } else { + CHECK_NAN(i, hypotf, x, NAN); + CHECK_NAN(i, hypotf, NAN, x); + CHECK_NAN(i, hypotf, -x, NAN); + CHECK_NAN(i, hypotf, NAN, -x); + } +#endif } } @@ -214,6 +250,31 @@ ATF_TC_BODY(hypot_trivial, tc) CHECK_EQ(i, hypot, -x, -0., x); CHECK_EQ(i, hypot, +0., -x, x); CHECK_EQ(i, hypot, -0., -x, x); + + if (isinf(INFINITY)) { + CHECK_EQ(i, hypot, x, +INFINITY, INFINITY); + CHECK_EQ(i, hypot, x, -INFINITY, INFINITY); + CHECK_EQ(i, hypot, +INFINITY, x, INFINITY); + CHECK_EQ(i, hypot, -INFINITY, x, INFINITY); + CHECK_EQ(i, hypot, -x, +INFINITY, INFINITY); + CHECK_EQ(i, hypot, -x, -INFINITY, INFINITY); + CHECK_EQ(i, hypot, +INFINITY, -x, INFINITY); + CHECK_EQ(i, hypot, -INFINITY, -x, INFINITY); + } + +#ifdef NAN + if (isinf(x)) { + CHECK_EQ(i, hypot, x, NAN, INFINITY); + CHECK_EQ(i, hypot, NAN, x, INFINITY); + CHECK_EQ(i, hypot, -x, NAN, INFINITY); + CHECK_EQ(i, hypot, NAN, -x, INFINITY); + } else { + CHECK_NAN(i, hypot, x, NAN); + CHECK_NAN(i, hypot, NAN, x); + CHECK_NAN(i, hypot, -x, NAN); + CHECK_NAN(i, hypot, NAN, -x); + } +#endif } for (i = 0; i < __arraycount(trivial_cases); i++) { @@ -227,6 +288,31 @@ ATF_TC_BODY(hypot_trivial, tc) CHECK_EQ(i, hypot, -x, -0., x); CHECK_EQ(i, hypot, +0., -x, x); CHECK_EQ(i, hypot, -0., -x, x); + + if (isinf(INFINITY)) { + CHECK_EQ(i, hypot, x, +INFINITY, INFINITY); + CHECK_EQ(i, hypot, x, -INFINITY, INFINITY); + CHECK_EQ(i, hypot, +INFINITY, x, INFINITY); + CHECK_EQ(i, hypot, -INFINITY, x, INFINITY); + CHECK_EQ(i, hypot, -x, +INFINITY, INFINITY); + CHECK_EQ(i, hypot, -x, -INFINITY, INFINITY); + CHECK_EQ(i, hypot, +INFINITY, -x, INFINITY); + CHECK_EQ(i, hypot, -INFINITY, -x, INFINITY); + } + +#ifdef NAN + if (isinf(x)) { + CHECK_EQ(i, hypot, x, NAN, INFINITY); + CHECK_EQ(i, hypot, NAN, x, INFINITY); + CHECK_EQ(i, hypot, -x, NAN, INFINITY); + CHECK_EQ(i, hypot, NAN, -x, INFINITY); + } else { + CHECK_NAN(i, hypot, x, NAN); + CHECK_NAN(i, hypot, NAN, x); + CHECK_NAN(i, hypot, -x, NAN); + CHECK_NAN(i, hypot, NAN, -x); + } +#endif } } @@ -250,6 +336,31 @@ ATF_TC_BODY(hypotl_trivial, tc) CHECKL_EQ(i, hypotl, -x, -0.L, x); CHECKL_EQ(i, hypotl, +0.L, -x, x); CHECKL_EQ(i, hypotl, -0.L, -x, x); + + if (isinf(INFINITY)) { + CHECKL_EQ(i, hypotl, x, +INFINITY, INFINITY); + CHECKL_EQ(i, hypotl, x, -INFINITY, INFINITY); + CHECKL_EQ(i, hypotl, +INFINITY, x, INFINITY); + CHECKL_EQ(i, hypotl, -INFINITY, x, INFINITY); + CHECKL_EQ(i, hypotl, -x, +INFINITY,
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat May 11 20:09:13 UTC 2024 Modified Files: src/tests/lib/libm: t_hypot.c Log Message: tests/lib/libm/t_hypot: More trivial tests. Check both signs of zero. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_hypot.c diff -u src/tests/lib/libm/t_hypot.c:1.3 src/tests/lib/libm/t_hypot.c:1.4 --- src/tests/lib/libm/t_hypot.c:1.3 Sat May 11 19:08:29 2024 +++ src/tests/lib/libm/t_hypot.c Sat May 11 20:09:13 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_hypot.c,v 1.3 2024/05/11 19:08:29 riastradh Exp $ */ +/* $NetBSD: t_hypot.c,v 1.4 2024/05/11 20:09:13 riastradh Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -181,20 +181,16 @@ ATF_TC_BODY(hypotf_trivial, tc) unsigned i; for (i = 0; i < __arraycount(trivial_casesf); i++) { - volatile float y, x = trivial_casesf[i]; + volatile float x = trivial_casesf[i]; - ATF_CHECK_EQ_MSG((y = hypotf(x, 0)), x, - "[%u] x=%g=%a hypotf(x, 0)=x=%g=%a", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypotf(-x, 0)), x, - "[%u] x=%g=%a hypotf(-x, 0)=x=%g=%a", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypotf(0, x)), x, - "[%u] x=%g=%a hypotf(0, x)=x=%g=%a", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypotf(0, -x)), x, - "[%u] x=%g=%a hypotf(0, -x)=x=%g=%a", - i, x, x, y, y); + CHECK_EQ(i, hypotf, x, +0., x); + CHECK_EQ(i, hypotf, x, -0., x); + CHECK_EQ(i, hypotf, +0., x, x); + CHECK_EQ(i, hypotf, -0., x, x); + CHECK_EQ(i, hypotf, -x, +0., x); + CHECK_EQ(i, hypotf, -x, -0., x); + CHECK_EQ(i, hypotf, +0., -x, x); + CHECK_EQ(i, hypotf, -0., -x, x); } } @@ -208,37 +204,29 @@ ATF_TC_BODY(hypot_trivial, tc) unsigned i; for (i = 0; i < __arraycount(trivial_casesf); i++) { - volatile double y, x = trivial_casesf[i]; + volatile double x = trivial_casesf[i]; - ATF_CHECK_EQ_MSG((y = hypot(x, 0)), x, - "[%u] x=%g=%a hypot(x, 0)=x=%g=%a", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypot(-x, 0)), x, - "[%u] x=%g=%a hypot(-x, 0)=x=%g=%a", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypot(0, x)), x, - "[%u] x=%g=%a hypot(0, x)=x=%g=%a", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypot(0, -x)), x, - "[%u] x=%g=%a hypot(0, -x)=x=%g=%a", - i, x, x, y, y); + CHECK_EQ(i, hypot, x, +0., x); + CHECK_EQ(i, hypot, x, -0., x); + CHECK_EQ(i, hypot, +0., x, x); + CHECK_EQ(i, hypot, -0., x, x); + CHECK_EQ(i, hypot, -x, +0., x); + CHECK_EQ(i, hypot, -x, -0., x); + CHECK_EQ(i, hypot, +0., -x, x); + CHECK_EQ(i, hypot, -0., -x, x); } for (i = 0; i < __arraycount(trivial_cases); i++) { - volatile double y, x = trivial_cases[i]; + volatile double x = trivial_cases[i]; - ATF_CHECK_EQ_MSG((y = hypot(x, 0)), x, - "[%u] x=%g=%a hypot(x, 0)=x=%g=%a", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypot(-x, 0)), x, - "[%u] x=%g=%a hypot(-x, 0)=x=%g=%a", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypot(0, x)), x, - "[%u] x=%g=%a hypot(0, x)=x=%g=%a", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypot(0, -x)), x, - "[%u] x=%g=%a hypot(0, -x)=x=%g=%a", - i, x, x, y, y); + CHECK_EQ(i, hypot, x, +0., x); + CHECK_EQ(i, hypot, x, -0., x); + CHECK_EQ(i, hypot, +0., x, x); + CHECK_EQ(i, hypot, -0., x, x); + CHECK_EQ(i, hypot, -x, +0., x); + CHECK_EQ(i, hypot, -x, -0., x); + CHECK_EQ(i, hypot, +0., -x, x); + CHECK_EQ(i, hypot, -0., -x, x); } } @@ -252,37 +240,29 @@ ATF_TC_BODY(hypotl_trivial, tc) unsigned i; for (i = 0; i < __arraycount(trivial_casesf); i++) { - volatile long double y, x = trivial_casesf[i]; + volatile long double x = trivial_casesf[i]; - ATF_CHECK_EQ_MSG((y = hypotl(x, 0)), x, - "[%u] x=%Lg=%La hypotl(x, 0)=x=%Lg=%La", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypotl(-x, 0)), x, - "[%u] x=%Lg=%La hypotl(-x, 0)=x=%Lg=%La", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypotl(0, x)), x, - "[%u] x=%Lg=%La hypotl(0, x)=x=%Lg=%La", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypotl(0, -x)), x, - "[%u] x=%Lg=%La hypotl(0, -x)=x=%Lg=%La", - i, x, x, y, y); + CHECKL_EQ(i, hypotl, x, +0.L, x); + CHECKL_EQ(i, hypotl, x, -0.L, x); + CHECKL_EQ(i, hypotl, +0.L, x, x); + CHECKL_EQ(i, hypotl, -0.L, x, x); + CHECKL_EQ(i, hypotl, -x, +0.L, x); + CHECKL_EQ(i, hypotl, -x, -0.L, x); + CHECKL_EQ(i, hypotl, +0.L, -x, x); + CHECKL_EQ(i, hypotl, -0.L, -x, x); } for (i = 0; i < __arraycount(trivial_cases); i++) { - volatile long double y, x = trivial_cases[i]; + volatile long double x = trivial_cases[i]; - ATF_CHECK_EQ_MSG((y = hypotl(x, 0)), x, - "[%u] x=%Lg=%La hypotl(x, 0)=x=%Lg=%La", - i, x, x, y, y); - ATF_CHECK_EQ_MSG((y = hypotl(-x, 0)), x, - "[%u] x=%Lg=%La hypotl(-x, 0)=x=%Lg=%La", - i, x, x,
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat May 11 20:09:13 UTC 2024 Modified Files: src/tests/lib/libm: t_hypot.c Log Message: tests/lib/libm/t_hypot: More trivial tests. Check both signs of zero. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat May 11 19:08:30 UTC 2024 Modified Files: src/tests/lib/libm: t_hypot.c Log Message: tests/lib/libm/t_hypot: Expand substantially. PR lib/58245: hypotl is broken on ld128 ports To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_hypot.c diff -u src/tests/lib/libm/t_hypot.c:1.2 src/tests/lib/libm/t_hypot.c:1.3 --- src/tests/lib/libm/t_hypot.c:1.2 Thu Jun 25 11:12:03 2020 +++ src/tests/lib/libm/t_hypot.c Sat May 11 19:08:29 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_hypot.c,v 1.2 2020/06/25 11:12:03 jruoho Exp $ */ +/* $NetBSD: t_hypot.c,v 1.3 2024/05/11 19:08:29 riastradh Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -27,33 +27,486 @@ */ #include +#include #include -ATF_TC(hypot_integer); -ATF_TC_HEAD(hypot_integer, tc) +#define CHECK_EQ(i, hypot, a, b, c) \ + ATF_CHECK_MSG(hypot(a, b) == (c), \ + "[%u] %s(%a, %a)=%a, expected %a", \ + (i), #hypot, (a), (b), hypot(a, b), (c)) + +#define CHECKL_EQ(i, hypot, a, b, c) \ + ATF_CHECK_MSG(hypot(a, b) == (c), \ + "[%u] %s(%La, %La)=%La, expected %La", \ + (i), #hypot, (a), (b), hypot(a, b), (c)) + +static const float trivial_casesf[] = { + 0, +#ifdef __FLT_HAS_DENORM__ + __FLT_DENORM_MIN__, + 2*__FLT_DENORM_MIN__, + 3*__FLT_DENORM_MIN__, + FLT_MIN - 3*__FLT_DENORM_MIN__, + FLT_MIN - 2*__FLT_DENORM_MIN__, + FLT_MIN - __FLT_DENORM_MIN__, +#endif + FLT_MIN, + FLT_MIN*(1 + FLT_EPSILON), + FLT_MIN*(1 + 2*FLT_EPSILON), + 2*FLT_MIN, + FLT_EPSILON/2, + FLT_EPSILON, + 2*FLT_EPSILON, + 1 - 3*FLT_EPSILON/2, + 1 - 2*FLT_EPSILON/2, + 1 - FLT_EPSILON/2, + 1, + 1 + FLT_EPSILON, + 1 + 2*FLT_EPSILON, + 1 + 3*FLT_EPSILON, + 1.5 - 3*FLT_EPSILON, + 1.5 - 2*FLT_EPSILON, + 1.5 - FLT_EPSILON, + 1.5, + 1.5 + FLT_EPSILON, + 1.5 + 2*FLT_EPSILON, + 1.5 + 3*FLT_EPSILON, + 2, + 0.5/FLT_EPSILON - 0.5, + 0.5/FLT_EPSILON, + 0.5/FLT_EPSILON + 0.5, + 1/FLT_EPSILON, + FLT_MAX, + INFINITY, +}; + +static const double trivial_cases[] = { + 0, +#ifdef __DBL_HAS_DENORM__ + __DBL_DENORM_MIN__, + 2*__DBL_DENORM_MIN__, + 3*__DBL_DENORM_MIN__, + DBL_MIN - 3*__DBL_DENORM_MIN__, + DBL_MIN - 2*__DBL_DENORM_MIN__, + DBL_MIN - __DBL_DENORM_MIN__, +#endif + DBL_MIN, + DBL_MIN*(1 + DBL_EPSILON), + DBL_MIN*(1 + 2*DBL_EPSILON), + 2*DBL_MIN, + DBL_EPSILON/2, + DBL_EPSILON, + 2*DBL_EPSILON, + 1 - 3*DBL_EPSILON/2, + 1 - 2*DBL_EPSILON/2, + 1 - DBL_EPSILON/2, + 1, + 1 + DBL_EPSILON, + 1 + 2*DBL_EPSILON, + 1 + 3*DBL_EPSILON, + 1.5 - 3*DBL_EPSILON, + 1.5 - 2*DBL_EPSILON, + 1.5 - DBL_EPSILON, + 1.5, + 1.5 + DBL_EPSILON, + 1.5 + 2*DBL_EPSILON, + 1.5 + 3*DBL_EPSILON, + 2, + 1/FLT_EPSILON - 0.5, + 1/FLT_EPSILON, + 1/FLT_EPSILON + 0.5, + 0.5/DBL_EPSILON - 0.5, + 0.5/DBL_EPSILON, + 0.5/DBL_EPSILON + 0.5, + 1/DBL_EPSILON, + DBL_MAX, + INFINITY, +}; + +static const long double trivial_casesl[] = { + 0, +#ifdef __LDBL_HAS_DENORM__ + __LDBL_DENORM_MIN__, + 2*__LDBL_DENORM_MIN__, + 3*__LDBL_DENORM_MIN__, + LDBL_MIN - 3*__LDBL_DENORM_MIN__, + LDBL_MIN - 2*__LDBL_DENORM_MIN__, + LDBL_MIN - __LDBL_DENORM_MIN__, +#endif + LDBL_MIN, + LDBL_MIN*(1 + LDBL_EPSILON), + LDBL_MIN*(1 + 2*LDBL_EPSILON), + 2*LDBL_MIN, + LDBL_EPSILON/2, + LDBL_EPSILON, + 2*LDBL_EPSILON, + 1 - 3*LDBL_EPSILON/2, + 1 - 2*LDBL_EPSILON/2, + 1 - LDBL_EPSILON/2, + 1, + 1 + LDBL_EPSILON, + 1 + 2*LDBL_EPSILON, + 1 + 3*LDBL_EPSILON, + 1.5 - 3*LDBL_EPSILON, + 1.5 - 2*LDBL_EPSILON, + 1.5 - LDBL_EPSILON, + 1.5, + 1.5 + LDBL_EPSILON, + 1.5 + 2*LDBL_EPSILON, + 1.5 + 3*LDBL_EPSILON, + 2, + 1/FLT_EPSILON - 0.5, + 1/FLT_EPSILON, + 1/FLT_EPSILON + 0.5, +#ifdef __HAVE_LONG_DOUBLE + 1/DBL_EPSILON - 0.5L, + 1/DBL_EPSILON, + 1/DBL_EPSILON + 0.5L, +#endif + 0.5/LDBL_EPSILON - 0.5, + 0.5/LDBL_EPSILON, + 0.5/LDBL_EPSILON + 0.5, + 1/LDBL_EPSILON, + LDBL_MAX, + INFINITY, +}; + +ATF_TC(hypotf_trivial); +ATF_TC_HEAD(hypotf_trivial, tc) +{ + atf_tc_set_md_var(tc, "descr", "hypotf(x,0) and hypotf(0,x)"); +} +ATF_TC_BODY(hypotf_trivial, tc) +{ + unsigned i; + + for (i = 0; i < __arraycount(trivial_casesf); i++) { + volatile float y, x = trivial_casesf[i]; + + ATF_CHECK_EQ_MSG((y = hypotf(x, 0)), x, + "[%u] x=%g=%a hypotf(x, 0)=x=%g=%a", + i, x, x, y, y); + ATF_CHECK_EQ_MSG((y = hypotf(-x, 0)), x, + "[%u] x=%g=%a hypotf(-x, 0)=x=%g=%a", + i, x, x, y, y); + ATF_CHECK_EQ_MSG((y = hypotf(0, x)), x, + "[%u] x=%g=%a hypotf(0, x)=x=%g=%a", + i, x, x, y, y); + ATF_CHECK_EQ_MSG((y = hypotf(0, -x)), x, + "[%u] x=%g=%a hypotf(0, -x)=x=%g=%a", + i, x, x, y, y); + } +} + +ATF_TC(hypot_trivial); +ATF_TC_HEAD(hypot_trivial, tc) +{ + atf_tc_set_md_var(tc, "descr", "hypot(x,0) and hypot(0,x)"); +} +ATF_TC_BODY(hypot_trivial, tc) +{ + unsigned i; + + for (i = 0; i < __arraycount(trivial_casesf); i++) { +
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat May 11 19:08:30 UTC 2024 Modified Files: src/tests/lib/libm: t_hypot.c Log Message: tests/lib/libm/t_hypot: Expand substantially. PR lib/58245: hypotl is broken on ld128 ports To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat May 11 01:44:12 UTC 2024 Modified Files: src/tests/lib/libm: t_next.c Log Message: tests/lib/libm/t_next: nexttoward works if it's just nextafter. It's broken on platforms where long double and double aren't the same and nexttoward isn't an alias for nextafter. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_next.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_next.c diff -u src/tests/lib/libm/t_next.c:1.4 src/tests/lib/libm/t_next.c:1.5 --- src/tests/lib/libm/t_next.c:1.4 Wed May 8 17:27:03 2024 +++ src/tests/lib/libm/t_next.c Sat May 11 01:44:12 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_next.c,v 1.4 2024/05/08 17:27:03 riastradh Exp $ */ +/* $NetBSD: t_next.c,v 1.5 2024/05/11 01:44:12 riastradh Exp $ */ /*- * Copyright (c) 2024 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: t_next.c,v 1.4 2024/05/08 17:27:03 riastradh Exp $"); +__RCSID("$NetBSD: t_next.c,v 1.5 2024/05/11 01:44:12 riastradh Exp $"); #include #include @@ -391,7 +391,9 @@ ATF_TC_BODY(next_near_0, tc) #endif }; +#ifdef __HAVE_LONG_DOUBLE atf_tc_expect_fail("PR 58236: nexttoward(3) is broken on subnormals"); +#endif check(x, __arraycount(x)); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat May 11 01:44:12 UTC 2024 Modified Files: src/tests/lib/libm: t_next.c Log Message: tests/lib/libm/t_next: nexttoward works if it's just nextafter. It's broken on platforms where long double and double aren't the same and nexttoward isn't an alias for nextafter. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_next.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 9 14:00:59 UTC 2024 Modified Files: src/tests/lib/libm: t_infinity.c Log Message: tests/lib/libm/t_infinity: Remove broken long double conditional. LDBL_MAX is always defined, so this branch is dead. (If LDBL_MAX is not defined, that's a bug in the architecture's float.h, not a reason to skip a test.) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_infinity.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 9 14:00:59 UTC 2024 Modified Files: src/tests/lib/libm: t_infinity.c Log Message: tests/lib/libm/t_infinity: Remove broken long double conditional. LDBL_MAX is always defined, so this branch is dead. (If LDBL_MAX is not defined, that's a bug in the architecture's float.h, not a reason to skip a test.) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_infinity.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_infinity.c diff -u src/tests/lib/libm/t_infinity.c:1.6 src/tests/lib/libm/t_infinity.c:1.7 --- src/tests/lib/libm/t_infinity.c:1.6 Wed Sep 26 07:24:38 2012 +++ src/tests/lib/libm/t_infinity.c Thu May 9 14:00:58 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_infinity.c,v 1.6 2012/09/26 07:24:38 jruoho Exp $ */ +/* $NetBSD: t_infinity.c,v 1.7 2024/05/09 14:00:58 riastradh Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_infinity.c,v 1.6 2012/09/26 07:24:38 jruoho Exp $"); +__RCSID("$NetBSD: t_infinity.c,v 1.7 2024/05/09 14:00:58 riastradh Exp $"); #include #include @@ -89,11 +89,6 @@ ATF_TC_HEAD(infinity_long_double, tc) ATF_TC_BODY(infinity_long_double, tc) { - -#ifndef LDBL_MAX - atf_tc_skip("no long double support on this architecture"); - return; -#else long double v; v = LDBL_MAX; @@ -105,7 +100,6 @@ ATF_TC_BODY(infinity_long_double, tc) v *= v; ATF_REQUIRE(isinf(v)); ATF_REQUIRE(fpclassify(v) == FP_INFINITE); -#endif } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 9 12:23:21 UTC 2024 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: tests/lib/libm/t_ilogb: Expand and tidy. 1. Instead of calling out VAX by name, use #ifdef NAN and isinf(INFINITY). (VAX defines INFINITY even though it's not an infinity, not sure if there's a better compile-time test.) 2. Verify ilogbl works on long double on all architectures, not just those with __HAVE_LONG_DOUBLE which means long double is _larger_ than double. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ilogb.c diff -u src/tests/lib/libm/t_ilogb.c:1.9 src/tests/lib/libm/t_ilogb.c:1.10 --- src/tests/lib/libm/t_ilogb.c:1.9 Thu Jun 14 21:57:25 2018 +++ src/tests/lib/libm/t_ilogb.c Thu May 9 12:23:21 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ilogb.c,v 1.9 2018/06/14 21:57:25 maya Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.10 2024/05/09 12:23:21 riastradh Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -28,8 +28,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + #include -__RCSID("$NetBSD: t_ilogb.c,v 1.9 2018/06/14 21:57:25 maya Exp $"); +__RCSID("$NetBSD: t_ilogb.c,v 1.10 2024/05/09 12:23:21 riastradh Exp $"); #include #include @@ -38,10 +39,14 @@ __RCSID("$NetBSD: t_ilogb.c,v 1.9 2018/0 #ifndef __HAVE_FENV -# define ATF_CHECK_RAISED_INVALID -# define ATF_CHECK_RAISED_NOTHING +# define ATF_CLEAR_EXCEPTS __nothing +# define ATF_CHECK_RAISED_INVALID __nothing +# define ATF_CHECK_RAISED_NOTHING __nothing + +#else /* __HAVE_FENV */ + +# define ATF_CLEAR_EXCEPTS (void)feclearexcept(FE_ALL_EXCEPT); -#else # define ATF_CHECK_RAISED_INVALID do { \ int r = fetestexcept(FE_ALL_EXCEPT); \ ATF_CHECK_MSG((r & FE_INVALID) != 0, \ @@ -55,72 +60,65 @@ __RCSID("$NetBSD: t_ilogb.c,v 1.9 2018/0 ATF_CHECK_MSG(r == 0, "r=%#x != 0\n", r); \ (void)feclearexcept(FE_ALL_EXCEPT); \ } while (/*CONSTCOND*/0) -#endif + +#endif /* __HAVE_FENV */ ATF_TC(ilogb); ATF_TC_HEAD(ilogb, tc) { - atf_tc_set_md_var(tc, "descr","Check ilogb family"); + atf_tc_set_md_var(tc, "descr", "Check ilogb family"); } ATF_TC_BODY(ilogb, tc) { + ATF_CLEAR_EXCEPTS; + ATF_CHECK(ilogbf(0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; -#ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; -#endif - ATF_CHECK(ilogbf(-0) == FP_ILOGB0); + ATF_CHECK(ilogbf(-0.) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; - ATF_CHECK(ilogb(-0) == FP_ILOGB0); + ATF_CHECK(ilogb(-0.) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; -#ifdef __HAVE_LONG_DOUBLE - ATF_CHECK(ilogbl(-0) == FP_ILOGB0); + ATF_CHECK(ilogbl(-0.) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; -#endif - ATF_CHECK(ilogbf(INFINITY) == INT_MAX); - ATF_CHECK_RAISED_INVALID; - ATF_CHECK(ilogb(INFINITY) == INT_MAX); - ATF_CHECK_RAISED_INVALID; -#ifdef __HAVE_LONG_DOUBLE - ATF_CHECK(ilogbl(INFINITY) == INT_MAX); - ATF_CHECK_RAISED_INVALID; -#endif - - ATF_CHECK(ilogbf(-INFINITY) == INT_MAX); - ATF_CHECK_RAISED_INVALID; - ATF_CHECK(ilogb(-INFINITY) == INT_MAX); - ATF_CHECK_RAISED_INVALID; -#ifdef __HAVE_LONG_DOUBLE - ATF_CHECK(ilogbl(-INFINITY) == INT_MAX); - ATF_CHECK_RAISED_INVALID; -#endif + if (isinf(INFINITY)) { + ATF_CHECK(ilogbf(INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogbl(INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; + + ATF_CHECK(ilogbf(-INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(-INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogbl(-INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; + } ATF_CHECK(ilogbf(1024) == 10); ATF_CHECK_RAISED_NOTHING; ATF_CHECK(ilogb(1024) == 10); ATF_CHECK_RAISED_NOTHING; -#ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(1024) == 10); ATF_CHECK_RAISED_NOTHING; -#endif -#ifndef __vax__ +#ifdef NAN ATF_CHECK(ilogbf(NAN) == FP_ILOGBNAN); ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(NAN) == FP_ILOGBNAN); ATF_CHECK_RAISED_INVALID; -#ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(NAN) == FP_ILOGBNAN); ATF_CHECK_RAISED_INVALID; #endif -#endif } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 9 12:23:21 UTC 2024 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: tests/lib/libm/t_ilogb: Expand and tidy. 1. Instead of calling out VAX by name, use #ifdef NAN and isinf(INFINITY). (VAX defines INFINITY even though it's not an infinity, not sure if there's a better compile-time test.) 2. Verify ilogbl works on long double on all architectures, not just those with __HAVE_LONG_DOUBLE which means long double is _larger_ than double. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 9 12:18:28 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round.c: Tidy. nextafter/nexttoward tests didn't make much sense, and are now supplanted by t_next. PR misc/58054 To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.18 src/tests/lib/libm/t_fe_round.c:1.19 --- src/tests/lib/libm/t_fe_round.c:1.18 Wed May 8 22:59:07 2024 +++ src/tests/lib/libm/t_fe_round.c Thu May 9 12:18:28 2024 @@ -1,3 +1,5 @@ +/* $NetBSD: t_fe_round.c,v 1.19 2024/05/09 12:18:28 riastradh Exp $ */ + /* * Written by Maya Rashish * Public domain. @@ -5,20 +7,22 @@ * Testing IEEE-754 rounding modes (and lrint) */ +#include +__RCSID("$NetBSD: t_fe_round.c,v 1.19 2024/05/09 12:18:28 riastradh Exp $"); + #include #include -#ifdef __HAVE_FENV #include #include #include #include +#ifdef __HAVE_FENV + /*#pragma STDC FENV_ACCESS ON gcc?? */ #define INT 9223L -#define EPSILON 0.001 - static const char * rmname(int rm) { @@ -36,6 +40,13 @@ rmname(int rm) } } +/* + * Examples are chosen to fit within the smallest single-precision + * format any NetBSD port uses, so that we can write the examples once + * in type double, and convert to single without raising inexact-result + * exceptions when we're trying to test whether the integer-rounding + * functions raise them. + */ static const struct { int round_mode; double input; @@ -44,15 +55,13 @@ static const struct { { FE_DOWNWARD, 3.75, 3}, { FE_DOWNWARD, -3.75, -4}, { FE_DOWNWARD, +0., 0}, + { FE_DOWNWARD, -0., 0}, { FE_DOWNWARD, -INT-0.0625, -INT-1}, { FE_DOWNWARD, +INT-0.0625, INT-1}, { FE_DOWNWARD, -INT+0.0625, -INT}, { FE_DOWNWARD, +INT+0.0625, INT}, -#if 0 /* cpu bugs? */ - { FE_DOWNWARD, -0., -1}, - { FE_UPWARD, +0., 1}, -#endif + { FE_UPWARD, +0., 0}, { FE_UPWARD, -0., 0}, { FE_UPWARD, -123.75, -123}, { FE_UPWARD, 123.75, 124}, @@ -432,68 +441,7 @@ ATF_TC_BODY(fe_nearbyintl_rintl, tc) } } -#endif - -static const struct { - double input; - double toward; - double expected; -} values2[] = { - { 10.0, 11.0, 10.0 }, - { -5.0, -6.0, -5.0 }, -}; - -ATF_TC(fe_nextafter); -ATF_TC_HEAD(fe_nextafter, tc) -{ - atf_tc_set_md_var(tc, "descr", "Checking IEEE 754 rounding using nextafter()"); -} - -ATF_TC_BODY(fe_nextafter, tc) -{ - double received; - int res; - - for (unsigned int i = 0; i < __arraycount(values2); i++) { - received = nextafter(values2[i].input, values2[i].toward); - if (values2[i].input < values2[i].toward) { - res = (received > values2[i].input); - } else { - res = (received < values2[i].input); - } - ATF_CHECK_MSG( - res && (fabs(received - values2[i].expected) < EPSILON), - "nextafter() rounding wrong, difference too large\n" - "input: %f (index %d): got %f, expected %f, res %d\n", - values2[i].input, i, received, values2[i].expected, res); - } -} - -ATF_TC(fe_nexttoward); -ATF_TC_HEAD(fe_nexttoward, tc) -{ - atf_tc_set_md_var(tc, "descr", "Checking IEEE 754 rounding using nexttoward()"); -} - -ATF_TC_BODY(fe_nexttoward, tc) -{ - double received; - int res; - - for (unsigned int i = 0; i < __arraycount(values2); i++) { - received = nexttoward(values2[i].input, values2[i].toward); - if (values2[i].input < values2[i].toward) { - res = (received > values2[i].input); - } else { - res = (received < values2[i].input); - } - ATF_CHECK_MSG( - res && (fabs(received - values2[i].expected) < EPSILON), - "nexttoward() rounding wrong, difference too large\n" - "input: %f (index %d): got %f, expected %f, res %d\n", - values2[i].input, i, received, values2[i].expected, res); - } -} +#endif /* __HAVE_LONG_DOUBLE */ ATF_TP_ADD_TCS(tp) { @@ -503,71 +451,19 @@ ATF_TP_ADD_TCS(tp) #ifdef __HAVE_LONG_DOUBLE ATF_TP_ADD_TC(tp, fe_nearbyintl_rintl); #endif - ATF_TP_ADD_TC(tp, fe_nextafter); - ATF_TP_ADD_TC(tp, fe_nexttoward); return atf_no_error(); } -#else -ATF_TC(t_nofe_round); -ATF_TC_HEAD(t_nofe_round, tc) -{ - atf_tc_set_md_var(tc, "descr", - "dummy test case - no fenv.h support"); -} - -ATF_TC_BODY(t_nofe_round, tc) -{ - atf_tc_skip("no fenv.h support on this architecture"); -} - -ATF_TC(t_nofe_nearbyint); - -ATF_TC_HEAD(t_nofe_nearbyint, tc) -{ - atf_tc_set_md_var(tc, "descr", - "dummy test case - no fenv.h support"); -} - -ATF_TC_BODY(t_nofe_nearbyint, tc) -{ - atf_tc_skip("no fenv.h support on this architecture"); -} - -ATF_TC(t_nofe_nextafter); - -ATF_TC_HEAD(t_nofe_nextafter, tc) -{ - atf_tc_set_md_var(tc, "descr", - "dummy test case - no fenv.h support"); -} - -ATF_TC_BODY(t_nofe_nextafter, tc) -{ - atf_tc_skip("no fenv.h support on this architecture"); -} -
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 9 12:18:28 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round.c: Tidy. nextafter/nexttoward tests didn't make much sense, and are now supplanted by t_next. PR misc/58054 To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Wed May 8 22:59:07 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round: xfail for modfl uses. PR lib/58237: modfl returns wrong answers on ld128 architectures To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Wed May 8 22:59:07 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round: xfail for modfl uses. PR lib/58237: modfl returns wrong answers on ld128 architectures To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.17 src/tests/lib/libm/t_fe_round.c:1.18 --- src/tests/lib/libm/t_fe_round.c:1.17 Sun May 5 23:08:53 2024 +++ src/tests/lib/libm/t_fe_round.c Wed May 8 22:59:07 2024 @@ -391,6 +391,12 @@ ATF_TC_BODY(fe_nearbyintl_rintl, tc) fnname[fn], valuesl[i].input); } +#if __HAVE_LONG_DOUBLE + 0 == 128 + atf_tc_expect_fail("PR lib/58237:" + " modfl returns wrong answers" + " on ld128 architectures"); +#endif + /* * Verify the fractional part of the result is * zero -- the result of rounding to an integer
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Wed May 8 22:57:38 UTC 2024 Modified Files: src/tests/lib/libm: t_modf.c Log Message: tests/lib/libm/t_modf: Mark modfl xfail on ld128. PR lib/58237: modfl returns wrong answers on ld128 architectures To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_modf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Wed May 8 22:57:38 UTC 2024 Modified Files: src/tests/lib/libm: t_modf.c Log Message: tests/lib/libm/t_modf: Mark modfl xfail on ld128. PR lib/58237: modfl returns wrong answers on ld128 architectures To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_modf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_modf.c diff -u src/tests/lib/libm/t_modf.c:1.4 src/tests/lib/libm/t_modf.c:1.5 --- src/tests/lib/libm/t_modf.c:1.4 Mon May 6 18:35:59 2024 +++ src/tests/lib/libm/t_modf.c Wed May 8 22:57:37 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_modf.c,v 1.4 2024/05/06 18:35:59 riastradh Exp $ */ +/* $NetBSD: t_modf.c,v 1.5 2024/05/08 22:57:37 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: t_modf.c,v 1.4 2024/05/06 18:35:59 riastradh Exp $"); +__RCSID("$NetBSD: t_modf.c,v 1.5 2024/05/08 22:57:37 riastradh Exp $"); #include #include @@ -289,6 +289,11 @@ ATF_TC_BODY(modfl, tc) { unsigned n; +#if __HAVE_LONG_DOUBLE + 0 == 128 + atf_tc_expect_fail("PR lib/58237:" + " modfl returns wrong answers on ld128 architectures"); +#endif + for (n = 0; n < __arraycount(casesf); n++) { long double x, i, f;
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Wed May 8 17:27:04 UTC 2024 Modified Files: src/tests/lib/libm: t_next.c Log Message: tests/lib/libm/t_next: Expand substantially. This covers many more potential problem areas -- and includes a new xfail test for PR lib/58236: nexttoward(3) is broken on subnormals. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_next.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_next.c diff -u src/tests/lib/libm/t_next.c:1.3 src/tests/lib/libm/t_next.c:1.4 --- src/tests/lib/libm/t_next.c:1.3 Sun May 5 14:34:58 2024 +++ src/tests/lib/libm/t_next.c Wed May 8 17:27:03 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_next.c,v 1.3 2024/05/05 14:34:58 riastradh Exp $ */ +/* $NetBSD: t_next.c,v 1.4 2024/05/08 17:27:03 riastradh Exp $ */ /*- * Copyright (c) 2024 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: t_next.c,v 1.3 2024/05/05 14:34:58 riastradh Exp $"); +__RCSID("$NetBSD: t_next.c,v 1.4 2024/05/08 17:27:03 riastradh Exp $"); #include #include @@ -50,117 +50,806 @@ ATF_TC_BODY(vaxafter, tc) #else /* !__vax__ */ -#define CHECK(x, y) \ - ATF_CHECK_EQ_MSG((x), (y), #x"=%La=%Lg, "#y"=%La=%Lg", \ - (long double)(x), (long double)(x), \ - (long double)(y), (long double)(y)) +#define CHECK(i, next, x, d, y) do \ +{ \ + volatile __typeof__(x) check_x = (x); \ + volatile __typeof__(d) check_d = (d); \ + volatile __typeof__(y) check_y = (y); \ + const volatile __typeof__(y) check_tmp = (next)(check_x, check_d);\ + ATF_CHECK_MSG(check_tmp == check_y, \ + "[%u] %s(%s=%La=%Lg, %s=%La=%Lg)=%La=%Lg != %s=%La=%Lg", \ + (i), #next, \ + #x, (long double)check_x, (long double)check_x, \ + #d, (long double)check_d, (long double)check_d, \ + (long double)check_tmp, (long double)check_tmp, \ + #y, (long double)check_y, (long double)check_y); \ +} while (0) -ATF_TC(nextafter); -ATF_TC_HEAD(nextafter, tc) +/* + * check(x, n) + * + * x[0], x[1], ..., x[n - 1] are consecutive double floating-point + * numbers. Verify nextafter and nexttoward follow exactly this + * sequence, forward and back, and in negative. + */ +static void +check(const double *x, unsigned n) +{ + unsigned i; + + for (i = 0; i < n; i++) { + CHECK(i, nextafter, x[i], x[i], x[i]); + CHECK(i, nexttoward, x[i], x[i], x[i]); + CHECK(i, nextafter, -x[i], -x[i], -x[i]); + CHECK(i, nexttoward, -x[i], -x[i], -x[i]); + } + + for (i = 0; i < n - 1; i++) { + ATF_REQUIRE_MSG(x[i] < x[i + 1], "i=%u", i); + + if (isnormal(x[i])) { + CHECK(i, nexttoward, x[i], x[i]*(1 + LDBL_EPSILON), + x[i + 1]); + } + + CHECK(i, nextafter, x[i], x[i + 1], x[i + 1]); + CHECK(i, nexttoward, x[i], x[i + 1], x[i + 1]); + CHECK(i, nextafter, x[i], x[n - 1], x[i + 1]); + CHECK(i, nexttoward, x[i], x[n - 1], x[i + 1]); + CHECK(i, nextafter, x[i], INFINITY, x[i + 1]); + CHECK(i, nexttoward, x[i], INFINITY, x[i + 1]); + + CHECK(i, nextafter, -x[i], -x[i + 1], -x[i + 1]); + CHECK(i, nexttoward, -x[i], -x[i + 1], -x[i + 1]); + CHECK(i, nextafter, -x[i], -x[n - 1], -x[i + 1]); + CHECK(i, nexttoward, -x[i], -x[n - 1], -x[i + 1]); + CHECK(i, nextafter, -x[i], -INFINITY, -x[i + 1]); + CHECK(i, nexttoward, -x[i], -INFINITY, -x[i + 1]); + } + + for (i = n; i --> 1;) { + ATF_REQUIRE_MSG(x[i - 1] < x[i], "i=%u", i); + + if (isnormal(x[i])) { + CHECK(i, nexttoward, x[i], x[i]*(1 - LDBL_EPSILON/2), + x[i - 1]); + } + + CHECK(i, nextafter, x[i], x[i - 1], x[i - 1]); + CHECK(i, nexttoward, x[i], x[i - 1], x[i - 1]); + CHECK(i, nextafter, x[i], x[0], x[i - 1]); + CHECK(i, nexttoward, x[i], x[0], x[i - 1]); + CHECK(i, nextafter, x[i], +0., x[i - 1]); + CHECK(i, nexttoward, x[i], +0., x[i - 1]); + CHECK(i, nextafter, x[i], -0., x[i - 1]); + CHECK(i, nexttoward, x[i], -0., x[i - 1]); + CHECK(i, nextafter, x[i], -x[0], x[i - 1]); + CHECK(i, nexttoward, x[i], -x[0], x[i - 1]); + CHECK(i, nextafter, x[i], -x[i], x[i - 1]); + CHECK(i, nexttoward, x[i], -x[i], x[i - 1]); + CHECK(i, nextafter, x[i], -INFINITY, x[i - 1]); + CHECK(i, nexttoward, x[i], -INFINITY, x[i - 1]); + + CHECK(i, nextafter, -x[i], -x[i - 1], -x[i - 1]); + CHECK(i, nexttoward, -x[i], -x[i - 1], -x[i - 1]); + CHECK(i, nextafter, -x[i], -x[0], -x[i - 1]); + CHECK(i, nexttoward, -x[i], -x[0], -x[i - 1]); + CHECK(i, nextafter, -x[i], -0., -x[i - 1]); + CHECK(i, nexttoward, -x[i], -0., -x[i - 1]); + CHECK(i, nextafter, -x[i], +0., -x[i - 1]); + CHECK(i, nexttoward, -x[i], +0., -x[i - 1]); + CHECK(i, nextafter, -x[i], x[0], -x[i - 1]); + CHECK(i, nexttoward, -x[i], x[0], -x[i - 1]); + CHECK(i, nextafter, -x[i], INFINITY, -x[i - 1]); + CHECK(i, nexttoward, -x[i], INFINITY, -x[i - 1]);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Wed May 8 17:27:04 UTC 2024 Modified Files: src/tests/lib/libm: t_next.c Log Message: tests/lib/libm/t_next: Expand substantially. This covers many more potential problem areas -- and includes a new xfail test for PR lib/58236: nexttoward(3) is broken on subnormals. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_next.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 18:41:23 UTC 2024 Modified Files: src/tests/lib/libm: t_bit.c Log Message: tests/lib/libm/t_bit: Expand and tidy. 1. Instead of calling out VAX by name, use #ifdef NAN. 2. Verify signbit works on long double on all architectures, not just those with __HAVE_LONG_DOUBLE which means long double is _larger_ than double. 3. Minor formatting tidying. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_bit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 18:41:23 UTC 2024 Modified Files: src/tests/lib/libm: t_bit.c Log Message: tests/lib/libm/t_bit: Expand and tidy. 1. Instead of calling out VAX by name, use #ifdef NAN. 2. Verify signbit works on long double on all architectures, not just those with __HAVE_LONG_DOUBLE which means long double is _larger_ than double. 3. Minor formatting tidying. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_bit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_bit.c diff -u src/tests/lib/libm/t_bit.c:1.1 src/tests/lib/libm/t_bit.c:1.2 --- src/tests/lib/libm/t_bit.c:1.1 Fri Apr 26 08:52:16 2019 +++ src/tests/lib/libm/t_bit.c Mon May 6 18:41:23 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_bit.c,v 1.1 2019/04/26 08:52:16 maya Exp $ */ +/* $NetBSD: t_bit.c,v 1.2 2024/05/06 18:41:23 riastradh Exp $ */ /* * Written by Maya Rashish @@ -7,6 +7,9 @@ * Testing signbit{,f,l} function correctly */ +#include +__RCSID("$NetBSD: t_bit.c,v 1.2 2024/05/06 18:41:23 riastradh Exp $"); + #include #include #include @@ -18,79 +21,85 @@ static const struct { double input; bool is_negative; } values[] = { - { -1, true}, - { -123, true}, - { -123E6, true}, -#ifdef INFINITY - { -INFINITY, true}, - { INFINITY, false}, -#endif - { 123E6, false}, - { 0, false}, - { -FLT_MIN, true}, - { FLT_MIN, false}, - /* + { -1, true }, + { -123, true }, + { -123E6, true }, + { -INFINITY, true }, + { INFINITY, false }, + { 123E6, false }, + { 0, false }, + { -0., true }, + { -FLT_MIN, true }, + { FLT_MIN, false }, + /* * Cannot be accurately represented as float, * but sign should be preserved */ - { DBL_MAX, false}, - { -DBL_MAX, true}, + { DBL_MAX, false }, + { -DBL_MAX, true }, }; -#ifdef __HAVE_LONG_DOUBLE static const struct { long double input; bool is_negative; } ldbl_values[] = { - { -LDBL_MIN, true}, - { LDBL_MIN, false}, - { LDBL_MAX, false}, - { -LDBL_MAX, true}, + { -LDBL_MIN, true }, + { LDBL_MIN, false }, + { LDBL_MAX, false }, + { -LDBL_MAX, true }, }; -#endif ATF_TC(signbit); ATF_TC_HEAD(signbit, tc) { - atf_tc_set_md_var(tc, "descr","Check that signbit functions correctly"); + atf_tc_set_md_var(tc, "descr", + "Check that signbit functions correctly"); } ATF_TC_BODY(signbit, tc) { - double iterator_d; - float iterator_f; + unsigned i; + + for (i = 0; i < __arraycount(values); i++) { + const float iterator_f = values[i].input; + const double iterator_d = values[i].input; + const long double iterator_l = values[i].input; - for (unsigned int i = 0; i < __arraycount(values); i++) { - iterator_d = values[i].input; - iterator_f = (float) values[i].input; - if (signbit(iterator_f) != values[i].is_negative) + if (signbit(iterator_f) != values[i].is_negative) { atf_tc_fail("%s:%d iteration %d signbitf is wrong" - " about the sign of %f", __func__, - __LINE__, i, iterator_f); - if (signbit(iterator_d) != values[i].is_negative) + " about the sign of %f", __func__, __LINE__, i, + iterator_f); + } + if (signbit(iterator_d) != values[i].is_negative) { atf_tc_fail("%s:%d iteration %d signbit is wrong" - "about the sign of %f", __func__, - __LINE__,i, iterator_d); - -#ifdef __HAVE_LONG_DOUBLE - long double iterator_l = values[i].input; - if (signbit(iterator_l) != values[i].is_negative) + "about the sign of %f", __func__, __LINE__, i, + iterator_d); + } + if (signbit(iterator_l) != values[i].is_negative) { atf_tc_fail("%s:%d iteration %d signbitl is wrong" - " about the sign of %Lf", __func__, - __LINE__, i, iterator_l); -#endif + " about the sign of %Lf", __func__, __LINE__, i, + iterator_l); + } } -#ifdef __HAVE_LONG_DOUBLE - for (unsigned int i = 0; i < __arraycount(ldbl_values); i++) { - if (signbit(ldbl_values[i].input) != ldbl_values[i].is_negative) + for (i = 0; i < __arraycount(ldbl_values); i++) { + if (signbit(ldbl_values[i].input) != + ldbl_values[i].is_negative) { atf_tc_fail("%s:%d iteration %d signbitl is" - "wrong about the sign of %Lf", - __func__, __LINE__, i, - ldbl_values[i].input); + "wrong about the sign of %Lf", + __func__, __LINE__, i, + ldbl_values[i].input); + } } -#endif +#ifdef NAN + ATF_CHECK_EQ(signbit(copysignf(NAN, -1)), true); + ATF_CHECK_EQ(signbit(copysignf(NAN, +1)), false); + ATF_CHECK_EQ(signbit(copysign(NAN, -1)), true); + ATF_CHECK_EQ(signbit(copysign(NAN, +1)), false); + ATF_CHECK_EQ(signbit(copysignl(NAN, -1)), true); + ATF_CHECK_EQ(signbit(copysignl(NAN, +1)), false); +#endif } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 18:35:59 UTC 2024 Modified Files: src/tests/lib/libm: t_modf.c Log Message: tests/lib/libm/t_modf: Use isinf(INFINITY) to detect inf support. Apparently VAX defines the INFINITY macro even though it's not actually an infinity and isinf returns zero for it. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_modf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 18:35:59 UTC 2024 Modified Files: src/tests/lib/libm: t_modf.c Log Message: tests/lib/libm/t_modf: Use isinf(INFINITY) to detect inf support. Apparently VAX defines the INFINITY macro even though it's not actually an infinity and isinf returns zero for it. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_modf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_modf.c diff -u src/tests/lib/libm/t_modf.c:1.3 src/tests/lib/libm/t_modf.c:1.4 --- src/tests/lib/libm/t_modf.c:1.3 Mon May 6 02:21:39 2024 +++ src/tests/lib/libm/t_modf.c Mon May 6 18:35:59 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_modf.c,v 1.3 2024/05/06 02:21:39 riastradh Exp $ */ +/* $NetBSD: t_modf.c,v 1.4 2024/05/06 18:35:59 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: t_modf.c,v 1.3 2024/05/06 02:21:39 riastradh Exp $"); +__RCSID("$NetBSD: t_modf.c,v 1.4 2024/05/06 18:35:59 riastradh Exp $"); #include #include @@ -129,8 +129,7 @@ ATF_TC_BODY(modff, tc) casesf[n].i, casesf[n].i, casesf[n].f, casesf[n].f); } -#ifdef INFINITY - { + if (isinf(INFINITY)) { float x, i, f; x = INFINITY; @@ -151,7 +150,6 @@ ATF_TC_BODY(modff, tc) "modff -inf returned integer %g=%a, frac %g=%a", i, i, f, f); } -#endif /* INFINITY */ #ifdef NAN { @@ -244,8 +242,7 @@ ATF_TC_BODY(modf, tc) cases[n].i, cases[n].i, cases[n].f, cases[n].f); } -#ifdef INFINITY - { + if (isinf(INFINITY)) { double x, i, f; x = INFINITY; @@ -266,7 +263,6 @@ ATF_TC_BODY(modf, tc) "modf -inf returned integer %g=%a, frac %g=%a", i, i, f, f); } -#endif /* INFINITY */ #ifdef NAN { @@ -394,8 +390,7 @@ ATF_TC_BODY(modfl, tc) } #endif /* __HAVE_LONG_DOUBLE */ -#ifdef INFINITY - { + if (isinf(INFINITY)) { long double x, i, f; x = INFINITY; @@ -416,7 +411,6 @@ ATF_TC_BODY(modfl, tc) "modfl -inf returned integer %Lg=%La, frac %Lg=%La", i, i, f, f); } -#endif #ifdef NAN { @@ -431,7 +425,7 @@ ATF_TC_BODY(modfl, tc) "modfl NaN returned integer %Lg=%La, frac %Lg=%La", i, i, f, f); } -#endif +#endif /* NAN */ } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:53:46 UTC 2024 Modified Files: src/tests/lib/libm: t_sincos.c Log Message: tests/lib/libm/t_sincos: Nix __HAVE_LONG_DOUBLE conditionals. sincosl is supposed to be there even if long double is double, as is the case when __HAVE_LONG_DOUBLE is undefined. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_sincos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_sincos.c diff -u src/tests/lib/libm/t_sincos.c:1.1 src/tests/lib/libm/t_sincos.c:1.2 --- src/tests/lib/libm/t_sincos.c:1.1 Sat Aug 27 08:31:58 2022 +++ src/tests/lib/libm/t_sincos.c Mon May 6 15:53:46 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sincos.c,v 1.1 2022/08/27 08:31:58 christos Exp $ */ +/* $NetBSD: t_sincos.c,v 1.2 2024/05/06 15:53:46 riastradh Exp $ */ /*- * Copyright (c) 2011, 2022 The NetBSD Foundation, Inc. @@ -85,7 +85,6 @@ static const struct { { 360, 6.283185307179586, 1., 999 }, }; -#ifdef __HAVE_LONG_DOUBLE /* * sincosl(3) */ @@ -207,7 +206,6 @@ ATF_TC_BODY(sincosl_zero_pos, tc) sincosl(x, , ); ATF_CHECK(s == 0.0 && c == 1.0); } -#endif /* * sincos(3) @@ -451,14 +449,13 @@ ATF_TC_BODY(sincosf_zero_pos, tc) ATF_TP_ADD_TCS(tp) { -#ifdef __HAVE_LONG_DOUBLE + ATF_TP_ADD_TC(tp, sincosl_angles); ATF_TP_ADD_TC(tp, sincosl_nan); ATF_TP_ADD_TC(tp, sincosl_inf_neg); ATF_TP_ADD_TC(tp, sincosl_inf_pos); ATF_TP_ADD_TC(tp, sincosl_zero_neg); ATF_TP_ADD_TC(tp, sincosl_zero_pos); -#endif ATF_TP_ADD_TC(tp, sincos_angles); ATF_TP_ADD_TC(tp, sincos_nan);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:53:46 UTC 2024 Modified Files: src/tests/lib/libm: t_sincos.c Log Message: tests/lib/libm/t_sincos: Nix __HAVE_LONG_DOUBLE conditionals. sincosl is supposed to be there even if long double is double, as is the case when __HAVE_LONG_DOUBLE is undefined. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_sincos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:49:31 UTC 2024 Modified Files: src/tests/lib/libm: t_scalbn.c Log Message: tests/lib/libm/t_scalbn: Nix __HAVE_LONG_DOUBLE conditionals. If long double is the same as double, i.e., __HAVE_LONG_DOUBLE is undefined, these tests should still pass, since they don't rely on extra precision beyond double. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libm/t_scalbn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_scalbn.c diff -u src/tests/lib/libm/t_scalbn.c:1.16 src/tests/lib/libm/t_scalbn.c:1.17 --- src/tests/lib/libm/t_scalbn.c:1.16 Wed Nov 7 03:59:36 2018 +++ src/tests/lib/libm/t_scalbn.c Mon May 6 15:49:31 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_scalbn.c,v 1.16 2018/11/07 03:59:36 riastradh Exp $ */ +/* $NetBSD: t_scalbn.c,v 1.17 2024/05/06 15:49:31 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_scalbn.c,v 1.16 2018/11/07 03:59:36 riastradh Exp $"); +__RCSID("$NetBSD: t_scalbn.c,v 1.17 2024/05/06 15:49:31 riastradh Exp $"); #include #include @@ -376,9 +376,6 @@ ATF_TC_HEAD(scalbnl_val, tc) ATF_TC_BODY(scalbnl_val, tc) { -#ifndef __HAVE_LONG_DOUBLE - atf_tc_skip("Requires long double support"); -#else const struct testcase *tests = test_vals; const size_t tcnt = __arraycount(test_vals); size_t i; @@ -397,7 +394,6 @@ ATF_TC_BODY(scalbnl_val, tc) i, rv, (long double)tests[i].result, fabsl(((long double)tests[i].result - rv)/tests[i].result)); } -#endif } ATF_TC(scalbnl_nan); @@ -408,9 +404,6 @@ ATF_TC_HEAD(scalbnl_nan, tc) ATF_TC_BODY(scalbnl_nan, tc) { -#ifndef __HAVE_LONG_DOUBLE - atf_tc_skip("Requires long double support"); -#else const long double x = 0.0L / 0.0L; long double y; size_t i; @@ -424,7 +417,6 @@ ATF_TC_BODY(scalbnl_nan, tc) y = scalbnl(x, exps[i]); ATF_CHECK(isnan(y) != 0); } -#endif } ATF_TC(scalbnl_inf_neg); @@ -435,15 +427,11 @@ ATF_TC_HEAD(scalbnl_inf_neg, tc) ATF_TC_BODY(scalbnl_inf_neg, tc) { -#ifndef __HAVE_LONG_DOUBLE - atf_tc_skip("Requires long double support"); -#else const long double x = -1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(scalbnl(x, exps[i]) == x); -#endif } ATF_TC(scalbnl_inf_pos); @@ -454,15 +442,11 @@ ATF_TC_HEAD(scalbnl_inf_pos, tc) ATF_TC_BODY(scalbnl_inf_pos, tc) { -#ifndef __HAVE_LONG_DOUBLE - atf_tc_skip("Requires long double support"); -#else const long double x = 1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(scalbnl(x, exps[i]) == x); -#endif } ATF_TC(scalbnl_zero_neg); @@ -473,9 +457,6 @@ ATF_TC_HEAD(scalbnl_zero_neg, tc) ATF_TC_BODY(scalbnl_zero_neg, tc) { -#ifndef __HAVE_LONG_DOUBLE - atf_tc_skip("Requires long double support"); -#else const long double x = -0.0L; long double y; size_t i; @@ -487,7 +468,6 @@ ATF_TC_BODY(scalbnl_zero_neg, tc) ATF_CHECK(x == y); ATF_CHECK(signbit(y) != 0); } -#endif } ATF_TC(scalbnl_zero_pos); @@ -498,9 +478,6 @@ ATF_TC_HEAD(scalbnl_zero_pos, tc) ATF_TC_BODY(scalbnl_zero_pos, tc) { -#ifndef __HAVE_LONG_DOUBLE - atf_tc_skip("Requires long double support"); -#else const long double x = 0.0L; long double y; size_t i; @@ -512,7 +489,6 @@ ATF_TC_BODY(scalbnl_zero_pos, tc) ATF_CHECK(x == y); ATF_CHECK(signbit(y) == 0); } -#endif } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:49:31 UTC 2024 Modified Files: src/tests/lib/libm: t_scalbn.c Log Message: tests/lib/libm/t_scalbn: Nix __HAVE_LONG_DOUBLE conditionals. If long double is the same as double, i.e., __HAVE_LONG_DOUBLE is undefined, these tests should still pass, since they don't rely on extra precision beyond double. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libm/t_scalbn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:46:31 UTC 2024 Modified Files: src/tests/lib/libm: t_precision.c Log Message: tests/lib/libm/t_precision: Nix __HAVE_LONG_DOUBLE conditionals. long double and LDBL_EPSILON work even on architectures where long double is the same as double, i.e., where the confusingly named __HAVE_LONG_DOUBLE is not defined. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_precision.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_precision.c diff -u src/tests/lib/libm/t_precision.c:1.3 src/tests/lib/libm/t_precision.c:1.4 --- src/tests/lib/libm/t_precision.c:1.3 Sat Aug 27 10:07:05 2016 +++ src/tests/lib/libm/t_precision.c Mon May 6 15:46:31 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $ */ +/* $NetBSD: t_precision.c,v 1.4 2024/05/06 15:46:31 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $"); +__RCSID("$NetBSD: t_precision.c,v 1.4 2024/05/06 15:46:31 riastradh Exp $"); #include @@ -45,9 +45,7 @@ ATF_TC_HEAD(t_precision, tc) } volatile double x = 1; -#if __HAVE_LONG_DOUBLE volatile long double y = 1; -#endif ATF_TC_BODY(t_precision, tc) { @@ -60,7 +58,6 @@ ATF_TC_BODY(t_precision, tc) x += DBL_EPSILON; ATF_CHECK(x == 2.0); -#if __HAVE_LONG_DOUBLE y += LDBL_EPSILON; ATF_CHECK(y != 1.0L); y -= 1; @@ -68,7 +65,6 @@ ATF_TC_BODY(t_precision, tc) y = 2; y += LDBL_EPSILON; ATF_CHECK(y == 2.0L); -#endif } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:46:31 UTC 2024 Modified Files: src/tests/lib/libm: t_precision.c Log Message: tests/lib/libm/t_precision: Nix __HAVE_LONG_DOUBLE conditionals. long double and LDBL_EPSILON work even on architectures where long double is the same as double, i.e., where the confusingly named __HAVE_LONG_DOUBLE is not defined. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_precision.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:45:20 UTC 2024 Modified Files: src/tests/lib/libm: t_cos.c Log Message: tests/lib/libm/t_cos: Fix comment about necessity of volatile. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_cos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_cos.c diff -u src/tests/lib/libm/t_cos.c:1.10 src/tests/lib/libm/t_cos.c:1.11 --- src/tests/lib/libm/t_cos.c:1.10 Mon May 6 15:44:08 2024 +++ src/tests/lib/libm/t_cos.c Mon May 6 15:45:20 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cos.c,v 1.10 2024/05/06 15:44:08 riastradh Exp $ */ +/* $NetBSD: t_cos.c,v 1.11 2024/05/06 15:45:20 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -277,9 +277,10 @@ ATF_TC_BODY(cosf_angles, tc) * * The volatile should not be necessary, by C99 Sec. * 5.2.4.2.2. para. 8 on p. 24 which specifies that - * assignment and cast remove all extra range and precision, - * but seems to be needed to work around a compiler bug. - */ + * assignment and cast remove all extra range and + * precision, but is needed when we compile with + * -std=gnu99 which doesn't implement this semantics. + */ volatile float result = cosf(theta); if (cos_theta == 999)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:45:20 UTC 2024 Modified Files: src/tests/lib/libm: t_cos.c Log Message: tests/lib/libm/t_cos: Fix comment about necessity of volatile. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_cos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:44:08 UTC 2024 Modified Files: src/tests/lib/libm: t_cos.c Log Message: tests/lib/libm/t_cos: Nix __HAVE_LONG_DOUBLE. cosl should always be defined even on architectures where long double is the same as double so the confusingly named __HAVE_LONG_DOUBLE is not defined. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_cos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_cos.c diff -u src/tests/lib/libm/t_cos.c:1.9 src/tests/lib/libm/t_cos.c:1.10 --- src/tests/lib/libm/t_cos.c:1.9 Mon May 27 00:10:36 2019 +++ src/tests/lib/libm/t_cos.c Mon May 6 15:44:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cos.c,v 1.9 2019/05/27 00:10:36 maya Exp $ */ +/* $NetBSD: t_cos.c,v 1.10 2024/05/06 15:44:08 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -60,7 +60,6 @@ static const struct { { 360, 6.283185307179586, 1., 999 }, }; -#ifdef __HAVE_LONG_DOUBLE /* * cosl(3) */ @@ -133,7 +132,6 @@ ATF_TC_BODY(cosl_inf_pos, tc) ATF_CHECK(isnan(cosl(x)) != 0); } - ATF_TC(cosl_zero_neg); ATF_TC_HEAD(cosl_zero_neg, tc) { @@ -159,7 +157,6 @@ ATF_TC_BODY(cosl_zero_pos, tc) ATF_CHECK(cosl(x) == 1.0); } -#endif /* * cos(3) @@ -229,7 +226,6 @@ ATF_TC_BODY(cos_inf_pos, tc) ATF_CHECK(isnan(cos(x)) != 0); } - ATF_TC(cos_zero_neg); ATF_TC_HEAD(cos_zero_neg, tc) { @@ -372,14 +368,13 @@ ATF_TC_BODY(cosf_zero_pos, tc) ATF_TP_ADD_TCS(tp) { -#ifdef __HAVE_LONG_DOUBLE + ATF_TP_ADD_TC(tp, cosl_angles); ATF_TP_ADD_TC(tp, cosl_nan); ATF_TP_ADD_TC(tp, cosl_inf_neg); ATF_TP_ADD_TC(tp, cosl_inf_pos); ATF_TP_ADD_TC(tp, cosl_zero_neg); ATF_TP_ADD_TC(tp, cosl_zero_pos); -#endif ATF_TP_ADD_TC(tp, cos_angles); ATF_TP_ADD_TC(tp, cos_nan);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:44:08 UTC 2024 Modified Files: src/tests/lib/libm: t_cos.c Log Message: tests/lib/libm/t_cos: Nix __HAVE_LONG_DOUBLE. cosl should always be defined even on architectures where long double is the same as double so the confusingly named __HAVE_LONG_DOUBLE is not defined. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_cos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:40:55 UTC 2024 Modified Files: src/tests/lib/libm: t_cabsl.cxx Log Message: tests/lib/libm/t_cabsl: Nix __HAVE_LONG_DOUBLE conditionals. __HAVE_LONG_DOUBLE just means long double is different from double. This test should always pass on all ports, even if long double is the same as double; it doesn't test any additional precision. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_cabsl.cxx Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_cabsl.cxx diff -u src/tests/lib/libm/t_cabsl.cxx:1.1 src/tests/lib/libm/t_cabsl.cxx:1.2 --- src/tests/lib/libm/t_cabsl.cxx:1.1 Wed Jun 20 03:51:27 2018 +++ src/tests/lib/libm/t_cabsl.cxx Mon May 6 15:40:55 2024 @@ -43,21 +43,15 @@ ATF_TEST_CASE_BODY(cabsl) { int sum = 0; -#ifdef __HAVE_LONG_DOUBLE std::complex cld(3.0,4.0); sum += std::abs(cld); -#endif std::complex cd(3.0,4.0); sum += std::abs(cd); std::complex cf(3.0,4.0); sum += std::abs(cf); -#ifdef __HAVE_LONG_DOUBLE ATF_REQUIRE_EQ(sum, 3*5); -#else - ATF_REQUIRE_EQ(sum, 2*5); -#endif } ATF_INIT_TEST_CASES(tcs)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 15:40:55 UTC 2024 Modified Files: src/tests/lib/libm: t_cabsl.cxx Log Message: tests/lib/libm/t_cabsl: Nix __HAVE_LONG_DOUBLE conditionals. __HAVE_LONG_DOUBLE just means long double is different from double. This test should always pass on all ports, even if long double is the same as double; it doesn't test any additional precision. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_cabsl.cxx Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 02:21:39 UTC 2024 Modified Files: src/tests/lib/libm: t_modf.c Log Message: tests/lib/libm/t_modf: Check sign of modf on infinities too. Normally I don't like CHECK(A && B) and favour CHECK(A); CHECK(B) instead, so you can see which one failed, but in this case the inputs are displayed anyway so we don't lose anything unless the floating-point printer is broken. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_modf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 02:21:39 UTC 2024 Modified Files: src/tests/lib/libm: t_modf.c Log Message: tests/lib/libm/t_modf: Check sign of modf on infinities too. Normally I don't like CHECK(A && B) and favour CHECK(A); CHECK(B) instead, so you can see which one failed, but in this case the inputs are displayed anyway so we don't lose anything unless the floating-point printer is broken. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_modf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_modf.c diff -u src/tests/lib/libm/t_modf.c:1.2 src/tests/lib/libm/t_modf.c:1.3 --- src/tests/lib/libm/t_modf.c:1.2 Mon May 6 00:54:02 2024 +++ src/tests/lib/libm/t_modf.c Mon May 6 02:21:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_modf.c,v 1.2 2024/05/06 00:54:02 riastradh Exp $ */ +/* $NetBSD: t_modf.c,v 1.3 2024/05/06 02:21:39 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: t_modf.c,v 1.2 2024/05/06 00:54:02 riastradh Exp $"); +__RCSID("$NetBSD: t_modf.c,v 1.3 2024/05/06 02:21:39 riastradh Exp $"); #include #include @@ -138,7 +138,7 @@ ATF_TC_BODY(modff, tc) ATF_CHECK_MSG(f == 0, "modff +inf returned integer %g=%a, frac %g=%a", i, i, f, f); - ATF_CHECK_MSG(isinf(i), + ATF_CHECK_MSG(isinf(i) && i > 0, "modff +inf returned integer %g=%a, frac %g=%a", i, i, f, f); @@ -147,7 +147,7 @@ ATF_TC_BODY(modff, tc) ATF_CHECK_MSG(f == 0, "modff -inf returned integer %g=%a, frac %g=%a", i, i, f, f); - ATF_CHECK_MSG(isinf(i), + ATF_CHECK_MSG(isinf(i) && i < 0, "modff -inf returned integer %g=%a, frac %g=%a", i, i, f, f); } @@ -253,7 +253,7 @@ ATF_TC_BODY(modf, tc) ATF_CHECK_MSG(f == 0, "modf +inf returned integer %g=%a, frac %g=%a", i, i, f, f); - ATF_CHECK_MSG(isinf(i), + ATF_CHECK_MSG(isinf(i) && i > 0, "modf +inf returned integer %g=%a, frac %g=%a", i, i, f, f); @@ -262,7 +262,7 @@ ATF_TC_BODY(modf, tc) ATF_CHECK_MSG(f == 0, "modf -inf returned integer %g=%a, frac %g=%a", i, i, f, f); - ATF_CHECK_MSG(isinf(i), + ATF_CHECK_MSG(isinf(i) && i < 0, "modf -inf returned integer %g=%a, frac %g=%a", i, i, f, f); } @@ -403,7 +403,7 @@ ATF_TC_BODY(modfl, tc) ATF_CHECK_MSG(f == 0, "modfl +inf returned integer %Lg=%La, frac %Lg=%La", i, i, f, f); - ATF_CHECK_MSG(isinf(i), + ATF_CHECK_MSG(isinf(i) && i > 0, "modfl +inf returned integer %Lg=%La, frac %Lg=%La", i, i, f, f); @@ -412,7 +412,7 @@ ATF_TC_BODY(modfl, tc) ATF_CHECK_MSG(f == 0, "modfl -inf returned integer %Lg=%La, frac %Lg=%La", i, i, f, f); - ATF_CHECK_MSG(isinf(i), + ATF_CHECK_MSG(isinf(i) && i < 0, "modfl -inf returned integer %Lg=%La, frac %Lg=%La", i, i, f, f); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 00:54:02 UTC 2024 Modified Files: src/tests/lib/libm: t_modf.c Log Message: tests/lib/libm/t_modf.c: Expand modf/modff/modfl tests. 1. Exercise more edge cases around the largest exponent that can represent non-integers. 2. - Verify modf can handle all cases modff can. - Veriy modf can handle some cases modff can't. - Verify modfl can handle all cases modf or modff can. - If long double isn't just double, verify modfl can handle some cases modf and modff can't. 3. Check infinities and NaN. 4. Verify oddness, i.e., modf(-x) = -modf(x). 5. Display more useful diagnostics in case any of this goes wrong. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_modf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_modf.c diff -u src/tests/lib/libm/t_modf.c:1.1 src/tests/lib/libm/t_modf.c:1.2 --- src/tests/lib/libm/t_modf.c:1.1 Mon Jun 16 12:54:43 2014 +++ src/tests/lib/libm/t_modf.c Mon May 6 00:54:02 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_modf.c,v 1.1 2014/06/16 12:54:43 joerg Exp $ */ +/* $NetBSD: t_modf.c,v 1.2 2024/05/06 00:54:02 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,40 +29,417 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include +__RCSID("$NetBSD: t_modf.c,v 1.2 2024/05/06 00:54:02 riastradh Exp $"); + #include #include #include +__CTASSERT(FLT_RADIX == 2); + +static const struct { + float x, i, f; +} casesf[] = { + { 0, 0, 0 }, + { FLT_MIN, 0, FLT_MIN }, + { 0.5, 0, 0.5 }, + { 1 - FLT_EPSILON/2, 0, 1 - FLT_EPSILON/2 }, + { 1, 1, 0 }, + { 1 + FLT_EPSILON, 1, FLT_EPSILON }, + { 0.5/FLT_EPSILON - 0.5, 0.5/FLT_EPSILON - 1, 0.5 }, + { 0.5/FLT_EPSILON, 0.5/FLT_EPSILON, 0 }, + { 0.5/FLT_EPSILON + 0.5, 0.5/FLT_EPSILON, 0.5 }, + { 1/FLT_EPSILON, 1/FLT_EPSILON, 0 }, +}; + +static const struct { + double x, i, f; +} cases[] = { + { 0, 0, 0 }, + { DBL_MIN, 0, DBL_MIN }, + { 0.5, 0, 0.5 }, + { 1 - DBL_EPSILON/2, 0, 1 - DBL_EPSILON/2 }, + { 1, 1, 0 }, + { 1 + DBL_EPSILON, 1, DBL_EPSILON }, + { 1/FLT_EPSILON + 0.5, 1/FLT_EPSILON, 0.5 }, + { 0.5/DBL_EPSILON - 0.5, 0.5/DBL_EPSILON - 1, 0.5 }, + { 0.5/DBL_EPSILON, 0.5/DBL_EPSILON, 0 }, + { 0.5/DBL_EPSILON + 0.5, 0.5/DBL_EPSILON, 0.5 }, + { 1/DBL_EPSILON, 1/DBL_EPSILON, 0 }, +}; + +#ifdef __HAVE_LONG_DOUBLE +static const struct { + long double x, i, f; +} casesl[] = { + { 0, 0, 0 }, + { LDBL_MIN, 0, LDBL_MIN }, + { 0.5, 0, 0.5 }, + { 1 - LDBL_EPSILON/2, 0, 1 - LDBL_EPSILON/2 }, + { 1, 1, 0 }, + { 1 + LDBL_EPSILON, 1, LDBL_EPSILON }, + { 1.0L/DBL_EPSILON + 0.5L, 1.0L/DBL_EPSILON, 0.5 }, + { 0.5/LDBL_EPSILON - 0.5L, 0.5/LDBL_EPSILON - 1, 0.5 }, + { 0.5/LDBL_EPSILON, 0.5/LDBL_EPSILON, 0 }, + { 0.5/LDBL_EPSILON + 0.5L, 0.5/LDBL_EPSILON, 0.5 }, + { 1/LDBL_EPSILON, 1/LDBL_EPSILON, 0 }, +}; +#endif /* __HAVE_LONG_DOUBLE */ + +ATF_TC(modff); +ATF_TC_HEAD(modff, tc) +{ + atf_tc_set_md_var(tc, "descr", "modff(3)"); +} +ATF_TC_BODY(modff, tc) +{ + unsigned n; + + for (n = 0; n < __arraycount(casesf); n++) { + float x, i, f; + + x = casesf[n].x; + f = modff(x, ); + ATF_CHECK_EQ_MSG(i, casesf[n].i, + "casesf[%u]: modff %g=%a" + " returned integer %g=%a, frac %g=%a;" + " expected integer %g=%a, frac %g=%a", + n, x, x, i, i, f, f, + casesf[n].i, casesf[n].i, casesf[n].f, casesf[n].f); + ATF_CHECK_EQ_MSG(f, casesf[n].f, + "casesf[%u]: modff %g=%a" + " returned integer %g=%a, frac %g=%a;" + " expected integer %g=%a, frac %g=%a", + n, x, x, i, i, f, f, + casesf[n].i, casesf[n].i, casesf[n].f, casesf[n].f); + + f = modff(-x, ); + ATF_CHECK_EQ_MSG(i, -casesf[n].i, + "casesf[%u]: modff %g=%a" + " returned integer %g=%a, frac %g=%a;" + " expected integer %g=%a, frac %g=%a", + n, x, x, i, i, f, f, + casesf[n].i, casesf[n].i, casesf[n].f, casesf[n].f); + ATF_CHECK_EQ_MSG(f, -casesf[n].f, + "casesf[%u]: modff %g=%a" + " returned integer %g=%a, frac %g=%a;" + " expected integer %g=%a, frac %g=%a", + n, x, x, i, i, f, f, + casesf[n].i, casesf[n].i, casesf[n].f, casesf[n].f); + } + +#ifdef INFINITY + { + float x, i, f; + + x = INFINITY; + f = modff(x, ); + ATF_CHECK_MSG(f == 0, + "modff +inf returned integer %g=%a, frac %g=%a", + i, i, f, f); + ATF_CHECK_MSG(isinf(i), + "modff +inf returned integer %g=%a, frac %g=%a", + i, i, f, f); + + x = -INFINITY; + f = modff(x, ); + ATF_CHECK_MSG(f == 0, + "modff -inf returned integer %g=%a, frac %g=%a", + i, i, f, f); + ATF_CHECK_MSG(isinf(i), + "modff -inf returned integer %g=%a, frac %g=%a", + i, i, f, f); + } +#endif /* INFINITY */ + +#ifdef NAN + { + float x, i, f; + + x = NAN; + f = modff(x, ); + ATF_CHECK_MSG(isnan(f), + "modff NaN returned integer %g=%a, frac %g=%a", + i, i, f, f); +
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon May 6 00:54:02 UTC 2024 Modified Files: src/tests/lib/libm: t_modf.c Log Message: tests/lib/libm/t_modf.c: Expand modf/modff/modfl tests. 1. Exercise more edge cases around the largest exponent that can represent non-integers. 2. - Verify modf can handle all cases modff can. - Veriy modf can handle some cases modff can't. - Verify modfl can handle all cases modf or modff can. - If long double isn't just double, verify modfl can handle some cases modf and modff can't. 3. Check infinities and NaN. 4. Verify oddness, i.e., modf(-x) = -modf(x). 5. Display more useful diagnostics in case any of this goes wrong. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_modf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun May 5 14:34:58 UTC 2024 Modified Files: src/tests/lib/libm: t_next.c Log Message: tests/lib/libm/t_next: Fix stub on VAX. Tested building the wrong tree, oops. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_next.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_next.c diff -u src/tests/lib/libm/t_next.c:1.2 src/tests/lib/libm/t_next.c:1.3 --- src/tests/lib/libm/t_next.c:1.2 Sun May 5 14:29:38 2024 +++ src/tests/lib/libm/t_next.c Sun May 5 14:34:58 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_next.c,v 1.2 2024/05/05 14:29:38 riastradh Exp $ */ +/* $NetBSD: t_next.c,v 1.3 2024/05/05 14:34:58 riastradh Exp $ */ /*- * Copyright (c) 2024 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: t_next.c,v 1.2 2024/05/05 14:29:38 riastradh Exp $"); +__RCSID("$NetBSD: t_next.c,v 1.3 2024/05/05 14:34:58 riastradh Exp $"); #include #include @@ -35,11 +35,16 @@ __RCSID("$NetBSD: t_next.c,v 1.2 2024/05 #ifdef __vax__ /* XXX PR 57881: vax libm is missing various symbols */ -ATF_TC(vaxafter) +ATF_TC(vaxafter); ATF_TC_HEAD(vaxafter, tc) { - atf_expect_fail("PR 57881: vax libm is missing various symbols") + atf_tc_set_md_var(tc, "descr", "vax nextafter/nexttoward reminder"); +} +ATF_TC_BODY(vaxafter, tc) +{ + + atf_tc_expect_fail("PR 57881: vax libm is missing various symbols"); atf_tc_fail("missing nextafter{,f,l} and nexttoward{,f,l} on vax"); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun May 5 14:34:58 UTC 2024 Modified Files: src/tests/lib/libm: t_next.c Log Message: tests/lib/libm/t_next: Fix stub on VAX. Tested building the wrong tree, oops. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_next.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun May 5 14:29:38 UTC 2024 Modified Files: src/tests/lib/libm: t_next.c Log Message: tests/lib/libm/t_next: Disable this test on VAX. But leave a replacement xfail test that fails unconditionally, to leave a reminder in the tests of PR 57881: vax libm is missing various symbols. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_next.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_next.c diff -u src/tests/lib/libm/t_next.c:1.1 src/tests/lib/libm/t_next.c:1.2 --- src/tests/lib/libm/t_next.c:1.1 Sun May 5 02:53:02 2024 +++ src/tests/lib/libm/t_next.c Sun May 5 14:29:38 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_next.c,v 1.1 2024/05/05 02:53:02 riastradh Exp $ */ +/* $NetBSD: t_next.c,v 1.2 2024/05/05 14:29:38 riastradh Exp $ */ /*- * Copyright (c) 2024 The NetBSD Foundation, Inc. @@ -27,12 +27,24 @@ */ #include -__RCSID("$NetBSD: t_next.c,v 1.1 2024/05/05 02:53:02 riastradh Exp $"); +__RCSID("$NetBSD: t_next.c,v 1.2 2024/05/05 14:29:38 riastradh Exp $"); #include #include #include +#ifdef __vax__ /* XXX PR 57881: vax libm is missing various symbols */ + +ATF_TC(vaxafter) +ATF_TC_HEAD(vaxafter, tc) +{ + + atf_expect_fail("PR 57881: vax libm is missing various symbols") + atf_tc_fail("missing nextafter{,f,l} and nexttoward{,f,l} on vax"); +} + +#else /* !__vax__ */ + #define CHECK(x, y) \ ATF_CHECK_EQ_MSG((x), (y), #x"=%La=%Lg, "#y"=%La=%Lg", \ (long double)(x), (long double)(x), \ @@ -146,14 +158,20 @@ ATF_TC_BODY(nexttowardl, tc) CHECK(nexttowardl(-1 + LDBL_EPSILON/2, -2), -1); } +#endif /* __vax__ */ + ATF_TP_ADD_TCS(tp) { +#ifdef __vax__ + ATF_TP_ADD_TC(tp, vaxafter); +#else ATF_TP_ADD_TC(tp, nextafter); ATF_TP_ADD_TC(tp, nextafterf); ATF_TP_ADD_TC(tp, nextafterl); ATF_TP_ADD_TC(tp, nexttoward); ATF_TP_ADD_TC(tp, nexttowardf); ATF_TP_ADD_TC(tp, nexttowardl); +#endif return atf_no_error(); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun May 5 14:29:38 UTC 2024 Modified Files: src/tests/lib/libm: t_next.c Log Message: tests/lib/libm/t_next: Disable this test on VAX. But leave a replacement xfail test that fails unconditionally, to leave a reminder in the tests of PR 57881: vax libm is missing various symbols. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_next.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Fri May 3 21:40:52 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round.c: Expand nearbyint/rint tests. PR lib/58054 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.15 src/tests/lib/libm/t_fe_round.c:1.16 --- src/tests/lib/libm/t_fe_round.c:1.15 Thu May 2 16:52:08 2024 +++ src/tests/lib/libm/t_fe_round.c Fri May 3 21:40:51 2024 @@ -41,108 +41,246 @@ static const struct { double input; long int expected; } values[] = { - { FE_DOWNWARD, 3.7, 3}, - { FE_DOWNWARD, -3.7, -4}, - { FE_DOWNWARD, +0, 0}, - { FE_DOWNWARD, -INT-0.01, -INT-1}, - { FE_DOWNWARD, +INT-0.01, INT-1}, - { FE_DOWNWARD, -INT+0.01, -INT}, - { FE_DOWNWARD, +INT+0.01, INT}, + { FE_DOWNWARD, 3.75, 3}, + { FE_DOWNWARD, -3.75, -4}, + { FE_DOWNWARD, +0., 0}, + { FE_DOWNWARD, -INT-0.0625, -INT-1}, + { FE_DOWNWARD, +INT-0.0625, INT-1}, + { FE_DOWNWARD, -INT+0.0625, -INT}, + { FE_DOWNWARD, +INT+0.0625, INT}, #if 0 /* cpu bugs? */ - { FE_DOWNWARD, -0, -1}, + { FE_DOWNWARD, -0., -1}, - { FE_UPWARD, +0, 1}, + { FE_UPWARD, +0., 1}, #endif - { FE_UPWARD, -0, 0}, - { FE_UPWARD, -123.7, -123}, - { FE_UPWARD, 123.999, 124}, - { FE_UPWARD, -INT-0.01, -INT}, - { FE_UPWARD, +INT-0.01, INT}, - { FE_UPWARD, -INT+0.01, -INT+1}, - { FE_UPWARD, +INT+0.01, INT+1}, - - { FE_TOWARDZERO, 1.99, 1}, - { FE_TOWARDZERO, -1.99, -1}, - { FE_TOWARDZERO, 0.2, 0}, - { FE_TOWARDZERO, INT+0.01, INT}, - { FE_TOWARDZERO, INT-0.01, INT - 1}, - { FE_TOWARDZERO, -INT+0.01, -INT + 1}, - { FE_TOWARDZERO, +0, 0}, - { FE_TOWARDZERO, -0, 0}, - - { FE_TONEAREST, -INT-0.01, -INT}, - { FE_TONEAREST, +INT-0.01, INT}, - { FE_TONEAREST, -INT+0.01, -INT}, - { FE_TONEAREST, +INT+0.01, INT}, - { FE_TONEAREST, -INT-0.501, -INT-1}, - { FE_TONEAREST, +INT-0.501, INT-1}, - { FE_TONEAREST, -INT+0.501, -INT+1}, - { FE_TONEAREST, +INT+0.501, INT+1}, - { FE_TONEAREST, +0, 0}, - { FE_TONEAREST, -0, 0}, + { FE_UPWARD, -0., 0}, + { FE_UPWARD, -123.75, -123}, + { FE_UPWARD, 123.75, 124}, + { FE_UPWARD, -INT-0.0625, -INT}, + { FE_UPWARD, +INT-0.0625, INT}, + { FE_UPWARD, -INT+0.0625, -INT+1}, + { FE_UPWARD, +INT+0.0625, INT+1}, + + { FE_TOWARDZERO, 1.9375, 1}, + { FE_TOWARDZERO, -1.9375, -1}, + { FE_TOWARDZERO, 0.25, 0}, + { FE_TOWARDZERO, INT+0.0625, INT}, + { FE_TOWARDZERO, INT-0.0625, INT - 1}, + { FE_TOWARDZERO, -INT+0.0625, -INT + 1}, + { FE_TOWARDZERO, +0., 0}, + { FE_TOWARDZERO, -0., 0}, + + { FE_TONEAREST, -INT-0.0625, -INT}, + { FE_TONEAREST, +INT-0.0625, INT}, + { FE_TONEAREST, -INT+0.0625, -INT}, + { FE_TONEAREST, +INT+0.0625, INT}, + { FE_TONEAREST, -INT-0.53125, -INT-1}, + { FE_TONEAREST, +INT-0.53125, INT-1}, + { FE_TONEAREST, -INT+0.53125, -INT+1}, + { FE_TONEAREST, +INT+0.53125, INT+1}, + { FE_TONEAREST, +0., 0}, + { FE_TONEAREST, -0., 0}, }; -ATF_TC(fe_round); -ATF_TC_HEAD(fe_round, tc) +ATF_TC(fe_lrint); +ATF_TC_HEAD(fe_lrint, tc) { - atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using lrint"); + atf_tc_set_md_var(tc, "descr", + "Checking IEEE 754 rounding modes using lrint(3)"); } -ATF_TC_BODY(fe_round, tc) +ATF_TC_BODY(fe_lrint, tc) { + enum { + LLRINT, + LLRINTF, + LRINT, + LRINTF, + N_FN, + } fn; + static const char *const fnname[] = { + [LLRINT] = "llrint", + [LLRINTF] = "llrintf", + [LRINT] = "lrint", + [LRINTF] = "lrintf", + }; long int received; + unsigned i; - for (unsigned int i = 0; i < __arraycount(values); i++) { - fesetround(values[i].round_mode); - - received = lrint(values[i].input); - ATF_CHECK_MSG( - (labs(received - values[i].expected) < EPSILON), - "lrint rounding wrong, difference too large\n" - "input: %f (index %d): got %ld, expected %ld\n", - values[i].input, i, received, values[i].expected); - - /* Do we get the same rounding mode out? */ - ATF_CHECK_MSG( - (fegetround() == values[i].round_mode), - "Didn't get the same rounding mode out!\n" - "(index %d) fed in %d rounding mode, got %d out\n", - i, values[i].round_mode, fegetround()); + for (i = 0; i < __arraycount(values); i++) { + for (fn = 0; fn < N_FN; fn++) { + /* + * Set the requested rounding mode. + */ + fesetround(values[i].round_mode); + + /* + * Call the lrint(3)-family function. + */ + switch (fn) { + case LLRINT: +received = llrint(values[i].input); +break; + case LLRINTF: +received = llrintf(values[i].input); +break; + case LRINT: +received = lrint(values[i].input); +break; + case LRINTF: +received = lrintf(values[i].input); +break; + default: +atf_tc_fail("impossible"); + } + + /* + *
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Fri May 3 21:40:52 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round.c: Expand nearbyint/rint tests. PR lib/58054 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/tests/lib/libm
> Date: Thu, 2 May 2024 21:04:38 +0200 > From: Roland Illig > > Am 02.05.2024 um 05:30 schrieb Robert Elz: > > Use intmax_t instead of long int when trying to represent very large > > integers (10^50 or so), so we don't exceed the capacity of systems where > > long int is only 32 bits. > > I particularly avoid the types 'long' and 'long double', as they vary > between the platforms. In this case, the whole point of the exercise is to test a long double function nearbyintl distinctly from the double function nearbyint. The integer result could have been int64_t instead of intmax_t (and maybe it should be). I wrote it as long mainly because I copied the nearbyint tests to make the nearbyintl tests and just forgot to update the long to make it work on LP32 platforms -- I tested on amd64 before committing and I was thinking about how sparc64/aarch64 must have broken nearbyintl (which the test has now confirmed they are). > Curiously, intmax_t is a 64-bit type even on amd64, where __int128_t is > also available, but I don't use that because that type is not predefined. Yes, although intmax_t looks convenient for arithmetic, it was a mistake to bake it into any ABI like printf "%jd", because it means expanding intmax_t from 64-bit to 128-bit breaks the ABI. Had the rule been to use PRIdMAX instead of "%jd" in the C standard, and had all intmax_t-related functions been defined as macros or static inlines, this problem could have been avoided. But it's too late for that now, so intmax_t is effectively just a confusingly-named alias for int64_t in practice.
Re: CVS commit: src/tests/lib/libm
Am 02.05.2024 um 05:30 schrieb Robert Elz: > Module Name: src > Committed By: kre > Date: Thu May 2 03:30:07 UTC 2024 > > Modified Files: > src/tests/lib/libm: t_fe_round.c > > Log Message: > Use intmax_t instead of long int when trying to represent very large > integers (10^50 or so), so we don't exceed the capacity of systems where > long int is only 32 bits. In the lint tests (which don't have a C preprocessor available), I use the following typedefs to get fixed-width integer types: typedef signed char int8_t; typedef short int16_t; typedef int int32_t; typedef long long int64_t; These types are the same on all platforms supported by lint, and I guess by NetBSD as a whole. I particularly avoid the types 'long' and 'long double', as they vary between the platforms. Curiously, intmax_t is a 64-bit type even on amd64, where __int128_t is also available, but I don't use that because that type is not predefined. Roland
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 2 16:52:08 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round: Fix a missed cast. Need long long or intmax_t, not long, on LP32. PR lib/58054 To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.14 src/tests/lib/libm/t_fe_round.c:1.15 --- src/tests/lib/libm/t_fe_round.c:1.14 Thu May 2 16:51:55 2024 +++ src/tests/lib/libm/t_fe_round.c Thu May 2 16:52:08 2024 @@ -187,7 +187,7 @@ ATF_TC_BODY(fe_nearbyintl, tc) " (integer part %Lf)", i, rmname(valuesl[i].round_mode), valuesl[i].input, fpart, ipart); - ATF_CHECK_MSG((long int)received == valuesl[i].expected, + ATF_CHECK_MSG((intmax_t)received == valuesl[i].expected, "[%u] %s nearbyintl(%Lf): got %Lf, expected %jd", i, rmname(valuesl[i].round_mode), valuesl[i].input, received, valuesl[i].expected);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 2 16:52:08 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round: Fix a missed cast. Need long long or intmax_t, not long, on LP32. PR lib/58054 To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 2 16:51:55 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round: Tidy up nearbyintl, sync nearbyint test. PR lib/58054 To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.13 src/tests/lib/libm/t_fe_round.c:1.14 --- src/tests/lib/libm/t_fe_round.c:1.13 Thu May 2 11:55:49 2024 +++ src/tests/lib/libm/t_fe_round.c Thu May 2 16:51:55 2024 @@ -128,12 +128,14 @@ ATF_TC_BODY(fe_nearbyint, tc) received = nearbyint(values[i].input); fpart = modf(received, ); ATF_CHECK_MSG(fpart == 0, - "%s nearbyint(%f) has fractional part %f", - rmname(values[i].round_mode), values[i].input, fpart); + "[%u] %s nearbyint(%f) has fractional part %f" + " (integer part %f)", + i, rmname(values[i].round_mode), values[i].input, fpart, + ipart); ATF_CHECK_MSG((long int)received == values[i].expected, - "%s [%u] nearbyint(%f) got %f, expected %ld\n", - rmname(values[i].round_mode), - i, values[i].input, received, values[i].expected); + "[%u] %s nearbyint(%f): got %f, expected %ld", + i, rmname(values[i].round_mode), + values[i].input, received, values[i].expected); /* Do we get the same rounding mode out? */ ATF_CHECK_MSG(fegetround() == values[i].round_mode, @@ -181,11 +183,13 @@ ATF_TC_BODY(fe_nearbyintl, tc) received = nearbyintl(valuesl[i].input); fpart = modfl(received, ); ATF_CHECK_MSG(fpart == 0, - "%s nearbyintl(%Lf) has fractional part %Lf", - rmname(values[i].round_mode), valuesl[i].input, fpart); + "[%u] %s nearbyintl(%Lf) has fractional part %Lf" + " (integer part %Lf)", + i, rmname(valuesl[i].round_mode), valuesl[i].input, fpart, + ipart); ATF_CHECK_MSG((long int)received == valuesl[i].expected, - "%s [%u] nearbyint(%Lf): got %Lf, expected %jd", - rmname(values[i].round_mode), i, + "[%u] %s nearbyintl(%Lf): got %Lf, expected %jd", + i, rmname(valuesl[i].round_mode), valuesl[i].input, received, valuesl[i].expected); /* Do we get the same rounding mode out? */
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 2 16:51:55 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round: Tidy up nearbyintl, sync nearbyint test. PR lib/58054 To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 2 11:55:49 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round.c: Simplify previous. There is never any need to write casts to type T in integer constant initializers for type T. PR lib/58054 To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.12 src/tests/lib/libm/t_fe_round.c:1.13 --- src/tests/lib/libm/t_fe_round.c:1.12 Thu May 2 03:30:07 2024 +++ src/tests/lib/libm/t_fe_round.c Thu May 2 11:55:49 2024 @@ -146,28 +146,24 @@ ATF_TC_BODY(fe_nearbyint, tc) #ifdef __HAVE_LONG_DOUBLE -#define IM intmax_t - /* * Use one bit more than fits in IEEE 754 binary64. */ static const struct { int round_mode; long double input; - IM expected; + intmax_t expected; } valuesl[] = { - { FE_TOWARDZERO, 0x2.08p+52L, (IM)0x20 }, - { FE_DOWNWARD, 0x2.08p+52L, (IM)0x20 }, - { FE_UPWARD, 0x2.08p+52L, (IM)0x21 }, - { FE_TONEAREST, 0x2.08p+52L, (IM)0x20 }, - { FE_TOWARDZERO, 0x2.18p+52L, (IM)0x21 }, - { FE_DOWNWARD, 0x2.18p+52L, (IM)0x21 }, - { FE_UPWARD, 0x2.18p+52L, (IM)0x22 }, - { FE_TONEAREST, 0x2.18p+52L, (IM)0x22 }, + { FE_TOWARDZERO, 0x2.08p+52L, 0x20 }, + { FE_DOWNWARD, 0x2.08p+52L, 0x20 }, + { FE_UPWARD, 0x2.08p+52L, 0x21 }, + { FE_TONEAREST, 0x2.08p+52L, 0x20 }, + { FE_TOWARDZERO, 0x2.18p+52L, 0x21 }, + { FE_DOWNWARD, 0x2.18p+52L, 0x21 }, + { FE_UPWARD, 0x2.18p+52L, 0x22 }, + { FE_TONEAREST, 0x2.18p+52L, 0x22 }, }; -#undef IM - ATF_TC(fe_nearbyintl); ATF_TC_HEAD(fe_nearbyintl, tc) {
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 2 11:55:49 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round.c: Simplify previous. There is never any need to write casts to type T in integer constant initializers for type T. PR lib/58054 To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/tests/lib/libm
And yes, I know, it should have been 2^50 not 10^50... kre
CVS commit: src/tests/lib/libm
Module Name:src Committed By: kre Date: Thu May 2 03:30:07 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: Use intmax_t instead of long int when trying to represent very large integers (10^50 or so), so we don't exceed the capacity of systems where long int is only 32 bits. Hopefully will unbreak the i386 build, perhaps others. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.11 src/tests/lib/libm/t_fe_round.c:1.12 --- src/tests/lib/libm/t_fe_round.c:1.11 Thu May 2 00:01:48 2024 +++ src/tests/lib/libm/t_fe_round.c Thu May 2 03:30:07 2024 @@ -9,6 +9,7 @@ #include #ifdef __HAVE_FENV #include +#include #include #include @@ -145,24 +146,28 @@ ATF_TC_BODY(fe_nearbyint, tc) #ifdef __HAVE_LONG_DOUBLE +#define IM intmax_t + /* * Use one bit more than fits in IEEE 754 binary64. */ static const struct { int round_mode; long double input; - long int expected; + IM expected; } valuesl[] = { - { FE_TOWARDZERO, 0x2.08p+52L, 0x20 }, - { FE_DOWNWARD, 0x2.08p+52L, 0x20 }, - { FE_UPWARD, 0x2.08p+52L, 0x21 }, - { FE_TONEAREST, 0x2.08p+52L, 0x20 }, - { FE_TOWARDZERO, 0x2.18p+52L, 0x21 }, - { FE_DOWNWARD, 0x2.18p+52L, 0x21 }, - { FE_UPWARD, 0x2.18p+52L, 0x22 }, - { FE_TONEAREST, 0x2.18p+52L, 0x22 }, + { FE_TOWARDZERO, 0x2.08p+52L, (IM)0x20 }, + { FE_DOWNWARD, 0x2.08p+52L, (IM)0x20 }, + { FE_UPWARD, 0x2.08p+52L, (IM)0x21 }, + { FE_TONEAREST, 0x2.08p+52L, (IM)0x20 }, + { FE_TOWARDZERO, 0x2.18p+52L, (IM)0x21 }, + { FE_DOWNWARD, 0x2.18p+52L, (IM)0x21 }, + { FE_UPWARD, 0x2.18p+52L, (IM)0x22 }, + { FE_TONEAREST, 0x2.18p+52L, (IM)0x22 }, }; +#undef IM + ATF_TC(fe_nearbyintl); ATF_TC_HEAD(fe_nearbyintl, tc) { @@ -183,7 +188,7 @@ ATF_TC_BODY(fe_nearbyintl, tc) "%s nearbyintl(%Lf) has fractional part %Lf", rmname(values[i].round_mode), valuesl[i].input, fpart); ATF_CHECK_MSG((long int)received == valuesl[i].expected, - "%s [%u] nearbyint(%Lf): got %Lf, expected %ld", + "%s [%u] nearbyint(%Lf): got %Lf, expected %jd", rmname(values[i].round_mode), i, valuesl[i].input, received, valuesl[i].expected);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: kre Date: Thu May 2 03:30:07 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: Use intmax_t instead of long int when trying to represent very large integers (10^50 or so), so we don't exceed the capacity of systems where long int is only 32 bits. Hopefully will unbreak the i386 build, perhaps others. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 2 00:01:48 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round: Test nearbyintl. This uses inputs that can't be distinguished with only 53 bits of precision, so it should work in essentially all long double formats to detect when nearbyintl is incorrectly implemented in terms of nearbyint. PR lib/58054 To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.10 src/tests/lib/libm/t_fe_round.c:1.11 --- src/tests/lib/libm/t_fe_round.c:1.10 Thu May 2 00:00:47 2024 +++ src/tests/lib/libm/t_fe_round.c Thu May 2 00:01:48 2024 @@ -143,6 +143,61 @@ ATF_TC_BODY(fe_nearbyint, tc) } } +#ifdef __HAVE_LONG_DOUBLE + +/* + * Use one bit more than fits in IEEE 754 binary64. + */ +static const struct { + int round_mode; + long double input; + long int expected; +} valuesl[] = { + { FE_TOWARDZERO, 0x2.08p+52L, 0x20 }, + { FE_DOWNWARD, 0x2.08p+52L, 0x20 }, + { FE_UPWARD, 0x2.08p+52L, 0x21 }, + { FE_TONEAREST, 0x2.08p+52L, 0x20 }, + { FE_TOWARDZERO, 0x2.18p+52L, 0x21 }, + { FE_DOWNWARD, 0x2.18p+52L, 0x21 }, + { FE_UPWARD, 0x2.18p+52L, 0x22 }, + { FE_TONEAREST, 0x2.18p+52L, 0x22 }, +}; + +ATF_TC(fe_nearbyintl); +ATF_TC_HEAD(fe_nearbyintl, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Checking IEEE 754 rounding modes using nearbyintl"); +} + +ATF_TC_BODY(fe_nearbyintl, tc) +{ + long double received, ipart, fpart; + + for (unsigned int i = 0; i < __arraycount(valuesl); i++) { + fesetround(valuesl[i].round_mode); + + received = nearbyintl(valuesl[i].input); + fpart = modfl(received, ); + ATF_CHECK_MSG(fpart == 0, + "%s nearbyintl(%Lf) has fractional part %Lf", + rmname(values[i].round_mode), valuesl[i].input, fpart); + ATF_CHECK_MSG((long int)received == valuesl[i].expected, + "%s [%u] nearbyint(%Lf): got %Lf, expected %ld", + rmname(values[i].round_mode), i, + valuesl[i].input, received, valuesl[i].expected); + + /* Do we get the same rounding mode out? */ + ATF_CHECK_MSG(fegetround() == valuesl[i].round_mode, + "[%u] set %d (%s), got %d (%s)", + i, + valuesl[i].round_mode, rmname(valuesl[i].round_mode), + fegetround(), rmname(fegetround())); + } +} + +#endif + static const struct { double input; double toward; @@ -209,6 +264,9 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, fe_round); ATF_TP_ADD_TC(tp, fe_nearbyint); +#ifdef __HAVE_LONG_DOUBLE + ATF_TP_ADD_TC(tp, fe_nearbyintl); +#endif ATF_TP_ADD_TC(tp, fe_nextafter); ATF_TP_ADD_TC(tp, fe_nexttoward);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 2 00:01:48 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round: Test nearbyintl. This uses inputs that can't be distinguished with only 53 bits of precision, so it should work in essentially all long double formats to detect when nearbyintl is incorrectly implemented in terms of nearbyint. PR lib/58054 To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 2 00:00:47 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round: Tidy up nearbyint test. Prompted by PR lib/58054. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.9 src/tests/lib/libm/t_fe_round.c:1.10 --- src/tests/lib/libm/t_fe_round.c:1.9 Mon Aug 21 17:11:18 2017 +++ src/tests/lib/libm/t_fe_round.c Thu May 2 00:00:47 2024 @@ -18,6 +18,23 @@ #define EPSILON 0.001 +static const char * +rmname(int rm) +{ + switch (rm) { + case FE_TOWARDZERO: + return "FE_TOWARDZERO"; + case FE_DOWNWARD: + return "FE_DOWNWARD"; + case FE_UPWARD: + return "FE_UPWARD"; + case FE_TONEAREST: + return "FE_TONEAREST"; + default: + return "unknown"; + } +} + static const struct { int round_mode; double input; @@ -96,29 +113,33 @@ ATF_TC_BODY(fe_round, tc) ATF_TC(fe_nearbyint); ATF_TC_HEAD(fe_nearbyint, tc) { - atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using nearbyint"); + atf_tc_set_md_var(tc, "descr", + "Checking IEEE 754 rounding modes using nearbyint"); } ATF_TC_BODY(fe_nearbyint, tc) { - double received; + double received, ipart, fpart; for (unsigned int i = 0; i < __arraycount(values); i++) { fesetround(values[i].round_mode); received = nearbyint(values[i].input); - ATF_CHECK_MSG( - (fabs(received - values[i].expected) < EPSILON), - "nearbyint rounding wrong, difference too large\n" - "input: %f (index %d): got %f, expected %ld\n", - values[i].input, i, received, values[i].expected); + fpart = modf(received, ); + ATF_CHECK_MSG(fpart == 0, + "%s nearbyint(%f) has fractional part %f", + rmname(values[i].round_mode), values[i].input, fpart); + ATF_CHECK_MSG((long int)received == values[i].expected, + "%s [%u] nearbyint(%f) got %f, expected %ld\n", + rmname(values[i].round_mode), + i, values[i].input, received, values[i].expected); /* Do we get the same rounding mode out? */ - ATF_CHECK_MSG( - (fegetround() == values[i].round_mode), - "Didn't get the same rounding mode out!\n" - "(index %d) fed in %d rounding mode, got %d out\n", - i, values[i].round_mode, fegetround()); + ATF_CHECK_MSG(fegetround() == values[i].round_mode, + "[%u] set %d (%s), got %d (%s)", + i, + values[i].round_mode, rmname(values[i].round_mode), + fegetround(), rmname(fegetround())); } }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu May 2 00:00:47 UTC 2024 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: tests/lib/libm/t_fe_round: Tidy up nearbyint test. Prompted by PR lib/58054. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Wed Apr 3 01:52:28 UTC 2024 Modified Files: src/tests/lib/libm: t_cbrt.c Log Message: fix the cbrtl/powl test To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_cbrt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Wed Apr 3 01:52:28 UTC 2024 Modified Files: src/tests/lib/libm: t_cbrt.c Log Message: fix the cbrtl/powl test To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_cbrt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_cbrt.c diff -u src/tests/lib/libm/t_cbrt.c:1.5 src/tests/lib/libm/t_cbrt.c:1.6 --- src/tests/lib/libm/t_cbrt.c:1.5 Thu Nov 15 00:14:20 2018 +++ src/tests/lib/libm/t_cbrt.c Tue Apr 2 21:52:28 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cbrt.c,v 1.5 2018/11/15 05:14:20 riastradh Exp $ */ +/* $NetBSD: t_cbrt.c,v 1.6 2024/04/03 01:52:28 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_cbrt.c,v 1.5 2018/11/15 05:14:20 riastradh Exp $"); +__RCSID("$NetBSD: t_cbrt.c,v 1.6 2024/04/03 01:52:28 christos Exp $"); #include #include @@ -285,12 +285,9 @@ ATF_TC_BODY(cbrtl_powl, tc) const long double eps = 2*LDBL_EPSILON; size_t i; -#if LDBL_MANT_DIG > DBL_MANT_DIG - atf_tc_expect_fail("powl not yet implemented with full precision"); -#endif for (i = 0; i < __arraycount(x); i++) { long double x_cbrt = cbrtl(x[i]); - long double x_pow13 = powl(x[i], 1.0 / 3.0); + long double x_pow13 = powl(x[i], 1.0L / 3.0L); bool ok; if (x[i] == 0) {
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Mon Mar 18 16:33:54 UTC 2024 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: The fetestexcept_trap test case only makes sense on FPUs that implement exceptions. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.15 src/tests/lib/libm/t_fenv.c:1.16 --- src/tests/lib/libm/t_fenv.c:1.15 Tue Feb 20 03:53:48 2024 +++ src/tests/lib/libm/t_fenv.c Mon Mar 18 16:33:54 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.15 2024/02/20 03:53:48 riastradh Exp $ */ +/* $NetBSD: t_fenv.c,v 1.16 2024/03/18 16:33:54 martin Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.15 2024/02/20 03:53:48 riastradh Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.16 2024/03/18 16:33:54 martin Exp $"); #include @@ -351,6 +351,8 @@ ATF_TC_BODY(fetestexcept_trap, tc) { int except; + FPU_EXC_PREREQ(); + fedisableexcept(FE_ALL_EXCEPT); ATF_CHECK_EQ_MSG((except = fegetexcept()), 0, "fegetexcept()=0x%x", except);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Mon Mar 18 16:33:54 UTC 2024 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: The fetestexcept_trap test case only makes sense on FPUs that implement exceptions. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon Feb 19 23:19:11 UTC 2024 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: fenv(3): Add test for PR port-amd64/57949. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon Feb 19 23:19:11 UTC 2024 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: fenv(3): Add test for PR port-amd64/57949. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.13 src/tests/lib/libm/t_fenv.c:1.14 --- src/tests/lib/libm/t_fenv.c:1.13 Mon Nov 6 13:48:12 2023 +++ src/tests/lib/libm/t_fenv.c Mon Feb 19 23:19:10 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.13 2023/11/06 13:48:12 riastradh Exp $ */ +/* $NetBSD: t_fenv.c,v 1.14 2024/02/19 23:19:10 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.13 2023/11/06 13:48:12 riastradh Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.14 2024/02/19 23:19:10 riastradh Exp $"); #include @@ -341,12 +341,43 @@ ATF_TC_BODY(feenableexcept, tc) (int)fpgetmask(), (int)FP_X_INV); } +ATF_TC(fetestexcept_trap); +ATF_TC_HEAD(fetestexcept_trap, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify fetestexcept doesn't affect the trapped excpetions"); +} +ATF_TC_BODY(fetestexcept_trap, tc) +{ + int except; + + fedisableexcept(FE_ALL_EXCEPT); + ATF_CHECK_EQ_MSG((except = fegetexcept()), 0, + "fegetexcept()=0x%x", except); + + (void)fetestexcept(FE_ALL_EXCEPT); + ATF_CHECK_EQ_MSG((except = fegetexcept()), 0, + "fegetexcept()=0x%x", except); + + feenableexcept(FE_ALL_EXCEPT); + ATF_CHECK_EQ_MSG((except = fegetexcept()), FE_ALL_EXCEPT, + "fegetexcept()=0x%x FE_ALL_EXCEPT=0x%x", except, FE_ALL_EXCEPT); + + (void)fetestexcept(FE_ALL_EXCEPT); +#ifdef __x86_64__ + atf_tc_expect_fail("PR port-amd64/57949"); +#endif + ATF_CHECK_EQ_MSG((except = fegetexcept()), FE_ALL_EXCEPT, + "fegetexcept()=0x%x FE_ALL_EXCEPT=0x%x", except, FE_ALL_EXCEPT); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fegetround); ATF_TP_ADD_TC(tp, fesetround); ATF_TP_ADD_TC(tp, fegetexcept); ATF_TP_ADD_TC(tp, feenableexcept); + ATF_TP_ADD_TC(tp, fetestexcept_trap); return atf_no_error(); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon Nov 6 13:48:13 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Factor checks out of switch in checkrounding. No functional change intended, just tidies up a bit. PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.12 src/tests/lib/libm/t_fenv.c:1.13 --- src/tests/lib/libm/t_fenv.c:1.12 Mon Nov 6 13:48:00 2023 +++ src/tests/lib/libm/t_fenv.c Mon Nov 6 13:48:12 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.12 2023/11/06 13:48:00 riastradh Exp $ */ +/* $NetBSD: t_fenv.c,v 1.13 2023/11/06 13:48:12 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.12 2023/11/06 13:48:00 riastradh Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.13 2023/11/06 13:48:12 riastradh Exp $"); #include @@ -128,52 +128,33 @@ checkrounding(int feround, const char *n volatile double y1 = -1 + ulp1/4; volatile double y2 = 1 + 3*(ulp1/2); + double z1, z2; + switch (feround) { - case FE_TONEAREST: { - double z1 = -1; - double z2 = 1 + 2*ulp1; - ATF_CHECK_EQ_MSG(y1, z1, "%s[-1 + ulp(1)/4]" - " expected=%a actual=%a", - name, y1, z1); - ATF_CHECK_EQ_MSG(y2, z2, "%s[1 + 3*(ulp(1)/2)]" - " expected=%a actual=%a", - name, y2, z2); + case FE_TONEAREST: + z1 = -1; + z2 = 1 + 2*ulp1; break; - } - case FE_TOWARDZERO: { - double z1 = -1 + ulp1/2; - double z2 = 1 + ulp1; - ATF_CHECK_EQ_MSG(y1, z1, "%s[-1 + ulp(1)/4]" - " expected=%a actual=%a", - name, y1, z1); - ATF_CHECK_EQ_MSG(y2, z2, "%s[1 + 3*(ulp(1)/2)]" - " expected=%a actual=%a", - name, y2, z2); + case FE_TOWARDZERO: + z1 = -1 + ulp1/2; + z2 = 1 + ulp1; break; - } - case FE_UPWARD: { - double z1 = -1 + ulp1/2; - double z2 = 1 + 2*ulp1; - ATF_CHECK_EQ_MSG(y1, z1, "%s[-1 + ulp(1)/4]" - " expected=%a actual=%a", - name, y1, z1); - ATF_CHECK_EQ_MSG(y2, z2, "%s[1 + 3*(ulp(1)/2)]" - " expected=%a actual=%a", - name, y2, z2); + case FE_UPWARD: + z1 = -1 + ulp1/2; + z2 = 1 + 2*ulp1; break; - } - case FE_DOWNWARD: { - double z1 = -1; - double z2 = 1 + ulp1; - ATF_CHECK_EQ_MSG(y1, z1, "%s[-1 + ulp(1)/4]" - " expected=%a actual=%a", - name, y1, z1); - ATF_CHECK_EQ_MSG(y2, z2, "%s[1 + 3*(ulp(1)/2)]" - " expected=%a actual=%a", - name, y2, z2); + case FE_DOWNWARD: + z1 = -1; + z2 = 1 + ulp1; break; + default: + atf_tc_fail("unknown rounding mode %d (%s)", feround, name); } - } + + ATF_CHECK_EQ_MSG(y1, z1, "%s[-1 + ulp(1)/4] expected=%a actual=%a", + name, y1, z1); + ATF_CHECK_EQ_MSG(y2, z2, "%s[1 + 3*(ulp(1)/2)] expected=%a actual=%a", + name, y2, z2); } ATF_TC(fegetround);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon Nov 6 13:48:13 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Factor checks out of switch in checkrounding. No functional change intended, just tidies up a bit. PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon Nov 6 13:48:00 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Use volatile intermediate to force rounding to double. See comment for details about why this is necessary. Should fix these tests on i386 (and perhaps m68k too). PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.11 src/tests/lib/libm/t_fenv.c:1.12 --- src/tests/lib/libm/t_fenv.c:1.11 Sun Nov 5 21:13:06 2023 +++ src/tests/lib/libm/t_fenv.c Mon Nov 6 13:48:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.11 2023/11/05 21:13:06 riastradh Exp $ */ +/* $NetBSD: t_fenv.c,v 1.12 2023/11/06 13:48:00 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.11 2023/11/05 21:13:06 riastradh Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.12 2023/11/06 13:48:00 riastradh Exp $"); #include @@ -114,8 +114,19 @@ static void checkrounding(int feround, const char *name) { volatile double ulp1 = DBL_EPSILON; - double y1 = -1 + ulp1/4; - double y2 = 1 + 3*(ulp1/2); + + /* + * XXX These must be volatile to force rounding to double when + * the intermediate quantities are evaluated in long double + * precision, e.g. on 32-bit x86 with x87 long double. Under + * the C standard (C99, C11, C17, ), cast and assignment + * operators are required to remove all extra range and + * precision, i.e., round double to long double. But we build + * this code with -std=gnu99, which diverges from this + * requirement -- unless you add a volatile qualifier. + */ + volatile double y1 = -1 + ulp1/4; + volatile double y2 = 1 + 3*(ulp1/2); switch (feround) { case FE_TONEAREST: {
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Mon Nov 6 13:48:00 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Use volatile intermediate to force rounding to double. See comment for details about why this is necessary. Should fix these tests on i386 (and perhaps m68k too). PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun Nov 5 21:13:07 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Improve diagnostics when rounding mode tests fail. Print the correct input, and print the rounding mode for clarity so you don't have to cross-reference it by line number. PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.10 src/tests/lib/libm/t_fenv.c:1.11 --- src/tests/lib/libm/t_fenv.c:1.10 Sun Nov 5 16:28:05 2023 +++ src/tests/lib/libm/t_fenv.c Sun Nov 5 21:13:06 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.10 2023/11/05 16:28:05 riastradh Exp $ */ +/* $NetBSD: t_fenv.c,v 1.11 2023/11/05 21:13:06 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.10 2023/11/05 16:28:05 riastradh Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.11 2023/11/05 21:13:06 riastradh Exp $"); #include @@ -37,7 +37,7 @@ __RCSID("$NetBSD: t_fenv.c,v 1.10 2023/1 #ifdef __HAVE_FENV /* XXXGCC gcc lacks #pragma STDC FENV_ACCESS */ -/* XXXCLANG clang lacks #pragma STDC FENV_ACCESS on some ports */ +/* XXXclang clang lacks #pragma STDC FENV_ACCESS on some ports */ #if !defined(__GNUC__) #pragma STDC FENV_ACCESS ON #endif @@ -111,7 +111,7 @@ checkfltrounds(void) } static void -checkrounding(int feround) +checkrounding(int feround, const char *name) { volatile double ulp1 = DBL_EPSILON; double y1 = -1 + ulp1/4; @@ -121,29 +121,45 @@ checkrounding(int feround) case FE_TONEAREST: { double z1 = -1; double z2 = 1 + 2*ulp1; - ATF_CHECK_EQ_MSG(y1, z1, "expected=%a actual=%a", y1, z1); - ATF_CHECK_EQ_MSG(y2, z2, "expected=%a actual=%a", y1, z2); + ATF_CHECK_EQ_MSG(y1, z1, "%s[-1 + ulp(1)/4]" + " expected=%a actual=%a", + name, y1, z1); + ATF_CHECK_EQ_MSG(y2, z2, "%s[1 + 3*(ulp(1)/2)]" + " expected=%a actual=%a", + name, y2, z2); break; } case FE_TOWARDZERO: { double z1 = -1 + ulp1/2; double z2 = 1 + ulp1; - ATF_CHECK_EQ_MSG(y1, z1, "expected=%a actual=%a", y1, z1); - ATF_CHECK_EQ_MSG(y2, z2, "expected=%a actual=%a", y1, z2); + ATF_CHECK_EQ_MSG(y1, z1, "%s[-1 + ulp(1)/4]" + " expected=%a actual=%a", + name, y1, z1); + ATF_CHECK_EQ_MSG(y2, z2, "%s[1 + 3*(ulp(1)/2)]" + " expected=%a actual=%a", + name, y2, z2); break; } case FE_UPWARD: { double z1 = -1 + ulp1/2; double z2 = 1 + 2*ulp1; - ATF_CHECK_EQ_MSG(y1, z1, "expected=%a actual=%a", y1, z1); - ATF_CHECK_EQ_MSG(y2, z2, "expected=%a actual=%a", y1, z2); + ATF_CHECK_EQ_MSG(y1, z1, "%s[-1 + ulp(1)/4]" + " expected=%a actual=%a", + name, y1, z1); + ATF_CHECK_EQ_MSG(y2, z2, "%s[1 + 3*(ulp(1)/2)]" + " expected=%a actual=%a", + name, y2, z2); break; } case FE_DOWNWARD: { double z1 = -1; double z2 = 1 + ulp1; - ATF_CHECK_EQ_MSG(y1, z1, "expected=%a actual=%a", y1, z1); - ATF_CHECK_EQ_MSG(y2, z2, "expected=%a actual=%a", y1, z2); + ATF_CHECK_EQ_MSG(y1, z1, "%s[-1 + ulp(1)/4]" + " expected=%a actual=%a", + name, y1, z1); + ATF_CHECK_EQ_MSG(y2, z2, "%s[1 + 3*(ulp(1)/2)]" + " expected=%a actual=%a", + name, y2, z2); break; } } @@ -162,35 +178,35 @@ ATF_TC_BODY(fegetround, tc) { FPU_RND_PREREQ(); - checkrounding(FE_TONEAREST); + checkrounding(FE_TONEAREST, "FE_TONEAREST"); fpsetround(FP_RZ); ATF_CHECK_EQ_MSG(fegetround(), FE_TOWARDZERO, "fegetround()=%d FE_TOWARDZERO=%d", fegetround(), FE_TOWARDZERO); checkfltrounds(); - checkrounding(FE_TOWARDZERO); + checkrounding(FE_TOWARDZERO, "FE_TOWARDZERO"); fpsetround(FP_RM); ATF_CHECK_EQ_MSG(fegetround(), FE_DOWNWARD, "fegetround()=%d FE_DOWNWARD=%d", fegetround(), FE_DOWNWARD); checkfltrounds(); - checkrounding(FE_DOWNWARD); + checkrounding(FE_DOWNWARD, "FE_DOWNWARD"); fpsetround(FP_RN); ATF_CHECK_EQ_MSG(fegetround(), FE_TONEAREST, "fegetround()=%d FE_TONEAREST=%d", fegetround(), FE_TONEAREST); checkfltrounds(); - checkrounding(FE_TONEAREST); + checkrounding(FE_TONEAREST, "FE_TONEAREST"); fpsetround(FP_RP); ATF_CHECK_EQ_MSG(fegetround(), FE_UPWARD, "fegetround()=%d FE_UPWARD=%d", fegetround(), FE_UPWARD); checkfltrounds(); - checkrounding(FE_UPWARD); + checkrounding(FE_UPWARD, "FE_UPWARD"); } ATF_TC(fesetround); @@ -206,35 +222,35 @@ ATF_TC_BODY(fesetround, tc) { FPU_RND_PREREQ(); - checkrounding(FE_TONEAREST); + checkrounding(FE_TONEAREST, "FE_TONEAREST"); fesetround(FE_TOWARDZERO); ATF_CHECK_EQ_MSG(fpgetround(), FP_RZ, "fpgetround()=%d FP_RZ=%d", (int)fpgetround(), (int)FP_RZ); checkfltrounds(); -
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun Nov 5 21:13:07 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Improve diagnostics when rounding mode tests fail. Print the correct input, and print the rounding mode for clarity so you don't have to cross-reference it by line number. PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun Nov 5 16:28:05 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Add #pragma STDC FENV_ACCESS ON and verify FLT_RADIX is 2. Except gcc doesn't implement this pragma, so make it conditional. And clang only supports it on some architectures, so just leave it out for now with a comment about why. PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun Nov 5 16:28:05 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Add #pragma STDC FENV_ACCESS ON and verify FLT_RADIX is 2. Except gcc doesn't implement this pragma, so make it conditional. And clang only supports it on some architectures, so just leave it out for now with a comment about why. PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.9 src/tests/lib/libm/t_fenv.c:1.10 --- src/tests/lib/libm/t_fenv.c:1.9 Sun Nov 5 16:06:27 2023 +++ src/tests/lib/libm/t_fenv.c Sun Nov 5 16:28:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.9 2023/11/05 16:06:27 riastradh Exp $ */ +/* $NetBSD: t_fenv.c,v 1.10 2023/11/05 16:28:05 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,17 +29,26 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.9 2023/11/05 16:06:27 riastradh Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.10 2023/11/05 16:28:05 riastradh Exp $"); #include #include #ifdef __HAVE_FENV +/* XXXGCC gcc lacks #pragma STDC FENV_ACCESS */ +/* XXXCLANG clang lacks #pragma STDC FENV_ACCESS on some ports */ +#if !defined(__GNUC__) +#pragma STDC FENV_ACCESS ON +#endif + #include #include #include +#if FLT_RADIX != 2 +#error This test assumes binary floating-point arithmetic. +#endif #if (__arm__ && !__SOFTFP__) || __aarch64__ /*
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun Nov 5 16:06:27 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Verify rounding mode takes effect. At least for addition operations, anyway. Somewhat redundant with the test t_fe_round added by maya@ but this gives two minimal pairs to easily diagnose exactly what the rounding mode is when the wrong one was selected. PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.8 src/tests/lib/libm/t_fenv.c:1.9 --- src/tests/lib/libm/t_fenv.c:1.8 Sun Nov 5 15:28:17 2023 +++ src/tests/lib/libm/t_fenv.c Sun Nov 5 16:06:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.8 2023/11/05 15:28:17 riastradh Exp $ */ +/* $NetBSD: t_fenv.c,v 1.9 2023/11/05 16:06:27 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.8 2023/11/05 15:28:17 riastradh Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.9 2023/11/05 16:06:27 riastradh Exp $"); #include @@ -101,6 +101,45 @@ checkfltrounds(void) FLT_ROUNDS, expected, feround); } +static void +checkrounding(int feround) +{ + volatile double ulp1 = DBL_EPSILON; + double y1 = -1 + ulp1/4; + double y2 = 1 + 3*(ulp1/2); + + switch (feround) { + case FE_TONEAREST: { + double z1 = -1; + double z2 = 1 + 2*ulp1; + ATF_CHECK_EQ_MSG(y1, z1, "expected=%a actual=%a", y1, z1); + ATF_CHECK_EQ_MSG(y2, z2, "expected=%a actual=%a", y1, z2); + break; + } + case FE_TOWARDZERO: { + double z1 = -1 + ulp1/2; + double z2 = 1 + ulp1; + ATF_CHECK_EQ_MSG(y1, z1, "expected=%a actual=%a", y1, z1); + ATF_CHECK_EQ_MSG(y2, z2, "expected=%a actual=%a", y1, z2); + break; + } + case FE_UPWARD: { + double z1 = -1 + ulp1/2; + double z2 = 1 + 2*ulp1; + ATF_CHECK_EQ_MSG(y1, z1, "expected=%a actual=%a", y1, z1); + ATF_CHECK_EQ_MSG(y2, z2, "expected=%a actual=%a", y1, z2); + break; + } + case FE_DOWNWARD: { + double z1 = -1; + double z2 = 1 + ulp1; + ATF_CHECK_EQ_MSG(y1, z1, "expected=%a actual=%a", y1, z1); + ATF_CHECK_EQ_MSG(y2, z2, "expected=%a actual=%a", y1, z2); + break; + } + } +} + ATF_TC(fegetround); ATF_TC_HEAD(fegetround, tc) @@ -114,29 +153,35 @@ ATF_TC_BODY(fegetround, tc) { FPU_RND_PREREQ(); + checkrounding(FE_TONEAREST); + fpsetround(FP_RZ); ATF_CHECK_EQ_MSG(fegetround(), FE_TOWARDZERO, "fegetround()=%d FE_TOWARDZERO=%d", fegetround(), FE_TOWARDZERO); checkfltrounds(); + checkrounding(FE_TOWARDZERO); fpsetround(FP_RM); ATF_CHECK_EQ_MSG(fegetround(), FE_DOWNWARD, "fegetround()=%d FE_DOWNWARD=%d", fegetround(), FE_DOWNWARD); checkfltrounds(); + checkrounding(FE_DOWNWARD); fpsetround(FP_RN); ATF_CHECK_EQ_MSG(fegetround(), FE_TONEAREST, "fegetround()=%d FE_TONEAREST=%d", fegetround(), FE_TONEAREST); checkfltrounds(); + checkrounding(FE_TONEAREST); fpsetround(FP_RP); ATF_CHECK_EQ_MSG(fegetround(), FE_UPWARD, "fegetround()=%d FE_UPWARD=%d", fegetround(), FE_UPWARD); checkfltrounds(); + checkrounding(FE_UPWARD); } ATF_TC(fesetround); @@ -152,29 +197,35 @@ ATF_TC_BODY(fesetround, tc) { FPU_RND_PREREQ(); + checkrounding(FE_TONEAREST); + fesetround(FE_TOWARDZERO); ATF_CHECK_EQ_MSG(fpgetround(), FP_RZ, "fpgetround()=%d FP_RZ=%d", (int)fpgetround(), (int)FP_RZ); checkfltrounds(); + checkrounding(FE_TOWARDZERO); fesetround(FE_DOWNWARD); ATF_CHECK_EQ_MSG(fpgetround(), FP_RM, "fpgetround()=%d FP_RM=%d", (int)fpgetround(), (int)FP_RM); checkfltrounds(); + checkrounding(FE_DOWNWARD); fesetround(FE_TONEAREST); ATF_CHECK_EQ_MSG(fpgetround(), FP_RN, "fpgetround()=%d FP_RN=%d", (int)fpgetround(), (int)FP_RN); checkfltrounds(); + checkrounding(FE_TONEAREST); fesetround(FE_UPWARD); ATF_CHECK_EQ_MSG(fpgetround(), FP_RP, "fpgetround()=%d FP_RP=%d", (int)fpgetround(), (int)FP_RP); checkfltrounds(); + checkrounding(FE_UPWARD); } ATF_TC(fegetexcept);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun Nov 5 16:06:27 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Verify rounding mode takes effect. At least for addition operations, anyway. Somewhat redundant with the test t_fe_round added by maya@ but this gives two minimal pairs to easily diagnose exactly what the rounding mode is when the wrong one was selected. PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun Nov 5 15:28:17 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Check FLT_ROUNDS whenever we touch the rounding mode. PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun Nov 5 15:28:17 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Check FLT_ROUNDS whenever we touch the rounding mode. PR port-mips/57680 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.7 src/tests/lib/libm/t_fenv.c:1.8 --- src/tests/lib/libm/t_fenv.c:1.7 Sun Nov 5 15:27:40 2023 +++ src/tests/lib/libm/t_fenv.c Sun Nov 5 15:28:17 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.7 2023/11/05 15:27:40 riastradh Exp $ */ +/* $NetBSD: t_fenv.c,v 1.8 2023/11/05 15:28:17 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,13 +29,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.7 2023/11/05 15:27:40 riastradh Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.8 2023/11/05 15:28:17 riastradh Exp $"); #include #include #ifdef __HAVE_FENV +#include #include #include @@ -67,6 +68,39 @@ __RCSID("$NetBSD: t_fenv.c,v 1.7 2023/11 #endif +static int +feround_to_fltrounds(int feround) +{ + + /* + * C99, Sec. 5.2.4.2.2 Characteristics of floating types + * , p. 24, clause 7 + */ + switch (feround) { + case FE_TOWARDZERO: + return 0; + case FE_TONEAREST: + return 1; + case FE_UPWARD: + return 2; + case FE_DOWNWARD: + return 3; + default: + return -1; + } +} + +static void +checkfltrounds(void) +{ + int feround = fegetround(); + int expected = feround_to_fltrounds(feround); + + ATF_CHECK_EQ_MSG(FLT_ROUNDS, expected, + "FLT_ROUNDS=%d expected=%d fegetround()=%d", + FLT_ROUNDS, expected, feround); +} + ATF_TC(fegetround); ATF_TC_HEAD(fegetround, tc) @@ -84,18 +118,25 @@ ATF_TC_BODY(fegetround, tc) ATF_CHECK_EQ_MSG(fegetround(), FE_TOWARDZERO, "fegetround()=%d FE_TOWARDZERO=%d", fegetround(), FE_TOWARDZERO); + checkfltrounds(); + fpsetround(FP_RM); ATF_CHECK_EQ_MSG(fegetround(), FE_DOWNWARD, "fegetround()=%d FE_DOWNWARD=%d", fegetround(), FE_DOWNWARD); + checkfltrounds(); + fpsetround(FP_RN); ATF_CHECK_EQ_MSG(fegetround(), FE_TONEAREST, "fegetround()=%d FE_TONEAREST=%d", fegetround(), FE_TONEAREST); + checkfltrounds(); + fpsetround(FP_RP); ATF_CHECK_EQ_MSG(fegetround(), FE_UPWARD, "fegetround()=%d FE_UPWARD=%d", fegetround(), FE_UPWARD); + checkfltrounds(); } ATF_TC(fesetround); @@ -115,18 +156,25 @@ ATF_TC_BODY(fesetround, tc) ATF_CHECK_EQ_MSG(fpgetround(), FP_RZ, "fpgetround()=%d FP_RZ=%d", (int)fpgetround(), (int)FP_RZ); + checkfltrounds(); + fesetround(FE_DOWNWARD); ATF_CHECK_EQ_MSG(fpgetround(), FP_RM, "fpgetround()=%d FP_RM=%d", (int)fpgetround(), (int)FP_RM); + checkfltrounds(); + fesetround(FE_TONEAREST); ATF_CHECK_EQ_MSG(fpgetround(), FP_RN, "fpgetround()=%d FP_RN=%d", (int)fpgetround(), (int)FP_RN); + checkfltrounds(); + fesetround(FE_UPWARD); ATF_CHECK_EQ_MSG(fpgetround(), FP_RP, "fpgetround()=%d FP_RP=%d", (int)fpgetround(), (int)FP_RP); + checkfltrounds(); } ATF_TC(fegetexcept);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun Nov 5 15:27:40 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Print wrong values if tests fail. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.6 src/tests/lib/libm/t_fenv.c:1.7 --- src/tests/lib/libm/t_fenv.c:1.6 Thu Apr 25 20:48:54 2019 +++ src/tests/lib/libm/t_fenv.c Sun Nov 5 15:27:40 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.6 2019/04/25 20:48:54 kamil Exp $ */ +/* $NetBSD: t_fenv.c,v 1.7 2023/11/05 15:27:40 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.6 2019/04/25 20:48:54 kamil Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.7 2023/11/05 15:27:40 riastradh Exp $"); #include @@ -81,13 +81,21 @@ ATF_TC_BODY(fegetround, tc) FPU_RND_PREREQ(); fpsetround(FP_RZ); - ATF_CHECK(fegetround() == FE_TOWARDZERO); + ATF_CHECK_EQ_MSG(fegetround(), FE_TOWARDZERO, + "fegetround()=%d FE_TOWARDZERO=%d", + fegetround(), FE_TOWARDZERO); fpsetround(FP_RM); - ATF_CHECK(fegetround() == FE_DOWNWARD); + ATF_CHECK_EQ_MSG(fegetround(), FE_DOWNWARD, + "fegetround()=%d FE_DOWNWARD=%d", + fegetround(), FE_DOWNWARD); fpsetround(FP_RN); - ATF_CHECK(fegetround() == FE_TONEAREST); + ATF_CHECK_EQ_MSG(fegetround(), FE_TONEAREST, + "fegetround()=%d FE_TONEAREST=%d", + fegetround(), FE_TONEAREST); fpsetround(FP_RP); - ATF_CHECK(fegetround() == FE_UPWARD); + ATF_CHECK_EQ_MSG(fegetround(), FE_UPWARD, + "fegetround()=%d FE_UPWARD=%d", + fegetround(), FE_UPWARD); } ATF_TC(fesetround); @@ -104,13 +112,21 @@ ATF_TC_BODY(fesetround, tc) FPU_RND_PREREQ(); fesetround(FE_TOWARDZERO); - ATF_CHECK(fpgetround() == FP_RZ); + ATF_CHECK_EQ_MSG(fpgetround(), FP_RZ, + "fpgetround()=%d FP_RZ=%d", + (int)fpgetround(), (int)FP_RZ); fesetround(FE_DOWNWARD); - ATF_CHECK(fpgetround() == FP_RM); + ATF_CHECK_EQ_MSG(fpgetround(), FP_RM, + "fpgetround()=%d FP_RM=%d", + (int)fpgetround(), (int)FP_RM); fesetround(FE_TONEAREST); - ATF_CHECK(fpgetround() == FP_RN); + ATF_CHECK_EQ_MSG(fpgetround(), FP_RN, + "fpgetround()=%d FP_RN=%d", + (int)fpgetround(), (int)FP_RN); fesetround(FE_UPWARD); - ATF_CHECK(fpgetround() == FP_RP); + ATF_CHECK_EQ_MSG(fpgetround(), FP_RP, + "fpgetround()=%d FP_RP=%d", + (int)fpgetround(), (int)FP_RP); } ATF_TC(fegetexcept); @@ -127,26 +143,38 @@ ATF_TC_BODY(fegetexcept, tc) FPU_EXC_PREREQ(); fpsetmask(0); - ATF_CHECK(fegetexcept() == 0); + ATF_CHECK_EQ_MSG(fegetexcept(), 0, + "fegetexcept()=%d", + fegetexcept()); fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP); ATF_CHECK(fegetexcept() == (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW |FE_UNDERFLOW|FE_INEXACT)); fpsetmask(FP_X_INV); - ATF_CHECK(fegetexcept() == FE_INVALID); + ATF_CHECK_EQ_MSG(fegetexcept(), FE_INVALID, + "fegetexcept()=%d FE_INVALID=%d", + fegetexcept(), FE_INVALID); fpsetmask(FP_X_DZ); - ATF_CHECK(fegetexcept() == FE_DIVBYZERO); + ATF_CHECK_EQ_MSG(fegetexcept(), FE_DIVBYZERO, + "fegetexcept()=%d FE_DIVBYZERO=%d", + fegetexcept(), FE_DIVBYZERO); fpsetmask(FP_X_OFL); - ATF_CHECK(fegetexcept() == FE_OVERFLOW); + ATF_CHECK_EQ_MSG(fegetexcept(), FE_OVERFLOW, + "fegetexcept()=%d FE_OVERFLOW=%d", + fegetexcept(), FE_OVERFLOW); fpsetmask(FP_X_UFL); - ATF_CHECK(fegetexcept() == FE_UNDERFLOW); + ATF_CHECK_EQ_MSG(fegetexcept(), FE_UNDERFLOW, + "fegetexcept()=%d FE_UNDERFLOW=%d", + fegetexcept(), FE_UNDERFLOW); fpsetmask(FP_X_IMP); - ATF_CHECK(fegetexcept() == FE_INEXACT); + ATF_CHECK_EQ_MSG(fegetexcept(), FE_INEXACT, + "fegetexcept()=%d FE_INEXACT=%d", + fegetexcept(), FE_INEXACT); } ATF_TC(feenableexcept); @@ -163,26 +191,38 @@ ATF_TC_BODY(feenableexcept, tc) FPU_EXC_PREREQ(); fedisableexcept(FE_ALL_EXCEPT); - ATF_CHECK(fpgetmask() == 0); + ATF_CHECK_EQ_MSG(fpgetmask(), 0, + "fpgetmask()=%d", + (int)fpgetmask()); feenableexcept(FE_UNDERFLOW); - ATF_CHECK(fpgetmask() == FP_X_UFL); + ATF_CHECK_EQ_MSG(fpgetmask(), FP_X_UFL, + "fpgetmask()=%d FP_X_UFL=%d", + (int)fpgetmask(), (int)FP_X_UFL); fedisableexcept(FE_ALL_EXCEPT); feenableexcept(FE_OVERFLOW); - ATF_CHECK(fpgetmask() == FP_X_OFL); + ATF_CHECK_EQ_MSG(fpgetmask(), FP_X_OFL, + "fpgetmask()=%d FP_X_OFL=%d", + (int)fpgetmask(), (int)FP_X_OFL); fedisableexcept(FE_ALL_EXCEPT); feenableexcept(FE_DIVBYZERO); - ATF_CHECK(fpgetmask() == FP_X_DZ); + ATF_CHECK_EQ_MSG(fpgetmask(), FP_X_DZ, + "fpgetmask()=%d FP_X_DZ=%d", + (int)fpgetmask(), (int)FP_X_DZ); fedisableexcept(FE_ALL_EXCEPT); feenableexcept(FE_INEXACT); -
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sun Nov 5 15:27:40 UTC 2023 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: t_fenv: Print wrong values if tests fail. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: gson Date: Tue Aug 25 13:39:16 UTC 2020 Modified Files: src/tests/lib/libm: t_fmod.c Log Message: Only expect the fmod test case to fail when using qemu's TCG CPU emulation, and not under hardware virtualization such as qemu -accel nvmm. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_fmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: gson Date: Tue Aug 25 13:39:16 UTC 2020 Modified Files: src/tests/lib/libm: t_fmod.c Log Message: Only expect the fmod test case to fail when using qemu's TCG CPU emulation, and not under hardware virtualization such as qemu -accel nvmm. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_fmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fmod.c diff -u src/tests/lib/libm/t_fmod.c:1.3 src/tests/lib/libm/t_fmod.c:1.4 --- src/tests/lib/libm/t_fmod.c:1.3 Sat Jan 3 14:23:53 2015 +++ src/tests/lib/libm/t_fmod.c Tue Aug 25 13:39:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fmod.c,v 1.3 2015/01/03 14:23:53 gson Exp $ */ +/* $NetBSD: t_fmod.c,v 1.4 2020/08/25 13:39:16 gson Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ ATF_TC_HEAD(fmod, tc) ATF_TC_BODY(fmod, tc) { - if (isQEMU()) + if (isQEMU_TCG()) atf_tc_expect_fail("PR misc/44767"); ATF_CHECK(fmodf(2.0, 1.0) == 0);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: lukem Date: Sun Jun 21 06:58:16 UTC 2020 Modified Files: src/tests/lib/libm: Makefile Log Message: fix build of t_cabsl from t_cabsl.cxx t_cabsl source is in t_cabsl.cxx not t_cabsl.cc - the latter is what bsd.tests.mk defaults to. This only broke after my commit of share/mk/bsd.dep.mk rev 1.85 but I don't know why it didn't cause a problem previously. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.46 src/tests/lib/libm/Makefile:1.47 --- src/tests/lib/libm/Makefile:1.46 Fri Apr 26 08:52:16 2019 +++ src/tests/lib/libm/Makefile Sun Jun 21 06:58:16 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.46 2019/04/26 08:52:16 maya Exp $ +# $NetBSD: Makefile,v 1.47 2020/06/21 06:58:16 lukem Exp $ .include @@ -46,6 +46,8 @@ TESTS_C+= t_tan TESTS_C+= t_tanh TESTS_CXX+= t_cabsl +SRCS.t_cabsl= t_cabsl.cxx + LDADD+= -lm #COPTS+= -Wfloat-equal
CVS commit: src/tests/lib/libm
Module Name:src Committed By: lukem Date: Sun Jun 21 06:58:16 UTC 2020 Modified Files: src/tests/lib/libm: Makefile Log Message: fix build of t_cabsl from t_cabsl.cxx t_cabsl source is in t_cabsl.cxx not t_cabsl.cc - the latter is what bsd.tests.mk defaults to. This only broke after my commit of share/mk/bsd.dep.mk rev 1.85 but I don't know why it didn't cause a problem previously. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Mon May 27 00:24:37 UTC 2019 Modified Files: src/tests/lib/libm: t_sin.c Log Message: Print result of function we tested (sinf), not of function we didn't test (sin). no need to print 17 digits for a float. from Riastradh. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_sin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_sin.c diff -u src/tests/lib/libm/t_sin.c:1.6 src/tests/lib/libm/t_sin.c:1.7 --- src/tests/lib/libm/t_sin.c:1.6 Wed Nov 7 04:00:13 2018 +++ src/tests/lib/libm/t_sin.c Mon May 27 00:24:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sin.c,v 1.6 2018/11/07 04:00:13 riastradh Exp $ */ +/* $NetBSD: t_sin.c,v 1.7 2019/05/27 00:24:37 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -194,8 +194,8 @@ ATF_TC_BODY(sinf_angles, tc) } if (!ok) { - atf_tc_fail_nonfatal("sinf(%d deg) = %.17g != %.17g", - deg, (double)sin(theta), (double)sin_theta); + atf_tc_fail_nonfatal("sinf(%d deg) = %.8g != %.8g", + deg, sinf(theta), sin_theta); } } }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Mon May 27 00:24:37 UTC 2019 Modified Files: src/tests/lib/libm: t_sin.c Log Message: Print result of function we tested (sinf), not of function we didn't test (sin). no need to print 17 digits for a float. from Riastradh. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_sin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Mon May 27 00:10:36 UTC 2019 Modified Files: src/tests/lib/libm: t_cos.c Log Message: on i386 with FLT_EVAL_METHOD=2, the computation inside cosf was done in binary80 arithmetic and never rounded to binary32 at the end, so it appeared farther from the correctly rounded result in binary32 than expected. Force binary32 using volatile float. PR lib/54232: lib/libm/t_cos:cosf_angles regression on i386 >From Riastradh. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_cos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.