Module Name: src Committed By: riastradh Date: Tue Oct 29 20:04:30 UTC 2024
Modified Files: src/lib/libc/arch/aarch64/gen: fpsetround.c src/tests/lib/libc/gen: t_fpsetround.c Log Message: fpsetround(3): Don't toggle all the other bits in fpcr on aarch64. PR port-arm/58782: fpsetround flips all the other fpcsr bits on aarch64 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/aarch64/gen/fpsetround.c cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/gen/t_fpsetround.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/arch/aarch64/gen/fpsetround.c diff -u src/lib/libc/arch/aarch64/gen/fpsetround.c:1.3 src/lib/libc/arch/aarch64/gen/fpsetround.c:1.4 --- src/lib/libc/arch/aarch64/gen/fpsetround.c:1.3 Fri Jun 7 20:50:13 2024 +++ src/lib/libc/arch/aarch64/gen/fpsetround.c Tue Oct 29 20:04:30 2024 @@ -29,7 +29,7 @@ #include <sys/cdefs.h> -__RCSID("$NetBSD: fpsetround.c,v 1.3 2024/06/07 20:50:13 riastradh Exp $"); +__RCSID("$NetBSD: fpsetround.c,v 1.4 2024/10/29 20:04:30 riastradh Exp $"); #include <sys/param.h> #include <sys/bitops.h> @@ -46,7 +46,7 @@ fp_rnd_t fpsetround(fp_rnd_t rnd) { const uint32_t old_fpcr = reg_fpcr_read(); - const uint32_t new_fpcr = (~old_fpcr & ~FPCR_RMODE) + const uint32_t new_fpcr = (old_fpcr & ~FPCR_RMODE) | __SHIFTIN(rnd, FPCR_RMODE); reg_fpcr_write(new_fpcr); return __SHIFTOUT(old_fpcr, FPCR_RMODE); Index: src/tests/lib/libc/gen/t_fpsetround.c diff -u src/tests/lib/libc/gen/t_fpsetround.c:1.7 src/tests/lib/libc/gen/t_fpsetround.c:1.8 --- src/tests/lib/libc/gen/t_fpsetround.c:1.7 Mon Oct 28 21:48:55 2024 +++ src/tests/lib/libc/gen/t_fpsetround.c Tue Oct 29 20:04:30 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fpsetround.c,v 1.7 2024/10/28 21:48:55 riastradh Exp $ */ +/* $NetBSD: t_fpsetround.c,v 1.8 2024/10/29 20:04:30 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_fpsetround.c,v 1.7 2024/10/28 21:48:55 riastradh Exp $"); +__RCSID("$NetBSD: t_fpsetround.c,v 1.8 2024/10/29 20:04:30 riastradh Exp $"); #include <float.h> #include <math.h> @@ -173,10 +173,12 @@ ATF_TC_BODY(fpsetround_noftz, tc) y = x/2; ATF_CHECK_MSG(y != 0, "machine runs flush-to-zero by default"); -#ifdef __aarch64__ - atf_tc_expect_fail("PR port-arm/58782:" - " fpsetround flips all the other fpcsr bits on aarch64"); -#endif + /* + * This curious test is a regression test for: + * + * PR port-arm/58782: fpsetround flips all the other fpcsr bits + * on aarch64 + */ ATF_CHECK_EQ_MSG((r = fpsetround(FP_RN)), FP_RN, "r=%d FP_RN=%d", r, FP_RN);