CVS commit: src/tests/lib/libc/gen

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 16:10:54 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
t_siginfo: Use volatile to prevent optimization.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/tests/lib/libc/gen/t_siginfo.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/libc/gen/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.50 src/tests/lib/libc/gen/t_siginfo.c:1.51
--- src/tests/lib/libc/gen/t_siginfo.c:1.50	Tue May 14 16:10:14 2024
+++ src/tests/lib/libc/gen/t_siginfo.c	Tue May 14 16:10:54 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.50 2024/05/14 16:10:14 riastradh Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.51 2024/05/14 16:10:54 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -386,7 +386,7 @@ ATF_TC_BODY(sigfpe_int, tc)
 		 * Do not use constant 1 here. GCC >= 12 optimizes
 		 * (1 / i) to (abs(i) == 1 ? i : 0), even for -O0.
 		 */
-		long unity = strtol("1", NULL, 10),
+		volatile long unity = strtol("1", NULL, 10),
 		 zero  = strtol("0", NULL, 10);
 		printf("%ld\n", unity / zero);
 	}



CVS commit: src/tests/lib/libc/gen

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 16:10:54 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
t_siginfo: Use volatile to prevent optimization.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/tests/lib/libc/gen/t_siginfo.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/libc/gen

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 16:10:15 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
t_siginfo: No SIGFPE on RISC-V.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/tests/lib/libc/gen/t_siginfo.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/libc/gen/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.49 src/tests/lib/libc/gen/t_siginfo.c:1.50
--- src/tests/lib/libc/gen/t_siginfo.c:1.49	Fri Aug  4 03:31:13 2023
+++ src/tests/lib/libc/gen/t_siginfo.c	Tue May 14 16:10:14 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.49 2023/08/04 03:31:13 rin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.50 2024/05/14 16:10:14 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -318,6 +318,8 @@ ATF_TC_BODY(sigfpe_flt, tc)
 	 */
 	if (0 == fpsetmask(fpsetmask(FP_X_INV)))
 		atf_tc_skip("FPU does not implement traps on FP exceptions");
+#elif defined __riscv__
+	atf_tc_skip("RISC-V does not support floating-point exception traps");
 #endif
 	if (sigsetjmp(sigfpe_flt_env, 0) == 0) {
 		sa.sa_flags = SA_SIGINFO;
@@ -366,7 +368,8 @@ ATF_TC_BODY(sigfpe_int, tc)
 {
 	struct sigaction sa;
 
-#if defined(__aarch64__) || defined(__powerpc__) || defined(__sh3__)
+#if defined(__aarch64__) || defined(__powerpc__) || defined(__sh3__) || \
+defined(__riscv__)
 	atf_tc_skip("Integer division by zero doesn't trap");
 #endif
 	if (sigsetjmp(sigfpe_int_env, 0) == 0) {



CVS commit: src/tests/lib/libc/gen

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 16:10:15 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
t_siginfo: No SIGFPE on RISC-V.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/tests/lib/libc/gen/t_siginfo.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/libc/sys

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 16:06:20 UTC 2024

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
t_ptrace_wait: No FPU exception traps on RISC-V.

This macro is not named correctly -- RISC-V does implement
floating-point exceptions, but only via sticky status bits, not via
machine traps.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/tests/lib/libc/sys/t_ptrace_wait.h

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/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.35 src/tests/lib/libc/sys/t_ptrace_wait.h:1.36
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.35	Tue May 14 16:04:17 2024
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Tue May 14 16:06:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.35 2024/05/14 16:04:17 riastradh Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.36 2024/05/14 16:06:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -673,6 +673,8 @@ are_fpu_exceptions_supported(void)
 		return false;
 	return true;
 }
+#elif defined __riscv__
+#define are_fpu_exceptions_supported() 0
 #else
 #define are_fpu_exceptions_supported() 1
 #endif



CVS commit: src/tests/lib/libc/sys

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 16:06:20 UTC 2024

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
t_ptrace_wait: No FPU exception traps on RISC-V.

This macro is not named correctly -- RISC-V does implement
floating-point exceptions, but only via sticky status bits, not via
machine traps.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/tests/lib/libc/sys/t_ptrace_wait.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/lib/libc/sys

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 16:04:18 UTC 2024

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
t_ptrace_wait: Force result by write to volatile, not call to usleep.

This is causing each FPE-related test to time out because it's
actually passinga large number to usleep, which now respects large
numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/tests/lib/libc/sys/t_ptrace_wait.h

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/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.34 src/tests/lib/libc/sys/t_ptrace_wait.h:1.35
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.34	Tue May 24 20:08:38 2022
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Tue May 14 16:04:17 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.34 2022/05/24 20:08:38 andvar Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.35 2024/05/14 16:04:17 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -677,6 +677,8 @@ are_fpu_exceptions_supported(void)
 #define are_fpu_exceptions_supported() 1
 #endif
 
+volatile double ignore_result;
+
 static void __used
 trigger_fpe(void)
 {
@@ -701,7 +703,7 @@ trigger_fpe(void)
 #endif
 
 	/* Division by zero causes CPU trap, translated to SIGFPE */
-	usleep((int)(a / b));
+	ignore_result = (int)(a / b);
 }
 
 static void __used



CVS commit: src/tests/lib/libc/sys

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 16:04:18 UTC 2024

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
t_ptrace_wait: Force result by write to volatile, not call to usleep.

This is causing each FPE-related test to time out because it's
actually passinga large number to usleep, which now respects large
numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/tests/lib/libc/sys/t_ptrace_wait.h

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

2024-05-14 Thread Taylor R Campbell
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

2024-05-14 Thread Taylor R Campbell
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

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 14:55:44 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_fpsetmask.c
src/tests/lib/libm: t_fenv.c

Log Message:
t_fpsetmask, t_fenv: Skip fp exception trap tests on RISC-V.

No architectural support for fp exception traps.

While here, make the macros behave a little better as C statements.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/tests/lib/libc/gen/t_fpsetmask.c
cvs rdiff -u -r1.17 -r1.18 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/libc/gen/t_fpsetmask.c
diff -u src/tests/lib/libc/gen/t_fpsetmask.c:1.21 src/tests/lib/libc/gen/t_fpsetmask.c:1.22
--- src/tests/lib/libc/gen/t_fpsetmask.c:1.21	Sun Aug 23 11:04:58 2020
+++ src/tests/lib/libc/gen/t_fpsetmask.c	Tue May 14 14:55:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fpsetmask.c,v 1.21 2020/08/23 11:04:58 gson Exp $ */
+/*	$NetBSD: t_fpsetmask.c,v 1.22 2024/05/14 14:55:43 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -61,16 +61,25 @@ ATF_TC_BODY(no_test, tc)
 #if (__arm__ && !__SOFTFP__) || __aarch64__
 	/*
 	 * Some NEON fpus do not trap on IEEE 754 FP exceptions.
-	 * skip these tests if running on them and compiled for
+	 * Skip these tests if running on them and compiled for
 	 * hard float.
 	 */
-#define	FPU_PREREQ()			\
-	if (0 == fpsetmask(fpsetmask(FP_X_INV)))			\
-		atf_tc_skip("FPU does not implement traps on FP exceptions");
+#define	FPU_PREREQ() do			  \
+{	  \
+	if (0 == fpsetmask(fpsetmask(FP_X_INV)))			  \
+		atf_tc_skip("FPU does not implement traps on FP exceptions"); \
+} while (0)
+#endif
+
+#ifdef __riscv__
+#ifdef __riscv__
+#define	FPU_PREREQ()			  \
+	atf_tc_skip("RISC-V does not support floating-point exception traps")
+#endif
 #endif
 
 #ifndef FPU_PREREQ
-#define	FPU_PREREQ()	/* nothing */
+#define	FPU_PREREQ()	__nothing
 #endif
 
 void		sigfpe(int, siginfo_t *, void *);

Index: src/tests/lib/libm/t_fenv.c
diff -u src/tests/lib/libm/t_fenv.c:1.17 src/tests/lib/libm/t_fenv.c:1.18
--- src/tests/lib/libm/t_fenv.c:1.17	Sun May 12 21:53:26 2024
+++ src/tests/lib/libm/t_fenv.c	Tue May 14 14:55:44 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fenv.c,v 1.17 2024/05/12 21:53:26 riastradh Exp $ */
+/* $NetBSD: t_fenv.c,v 1.18 2024/05/14 14:55:44 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.17 2024/05/12 21:53:26 riastradh Exp $");
+__RCSID("$NetBSD: t_fenv.c,v 1.18 2024/05/14 14:55:44 riastradh Exp $");
 
 #include 
 
@@ -52,28 +52,37 @@ __RCSID("$NetBSD: t_fenv.c,v 1.17 2024/0
 
 #if (__arm__ && !__SOFTFP__) || __aarch64__
 	/*
-	 * Some NEON fpus  do not trap on IEEE 754 FP exceptions.
+	 * Some NEON fpus do not trap on IEEE 754 FP exceptions.
 	 * Skip these tests if running on them and compiled for
 	 * hard float.
 	 */
-#define	FPU_EXC_PREREQ()		\
-	if (0 == fpsetmask(fpsetmask(FP_X_INV)))			\
-		atf_tc_skip("FPU does not implement traps on FP exceptions");
+#define	FPU_EXC_PREREQ() do		  \
+{	  \
+	if (0 == fpsetmask(fpsetmask(FP_X_INV)))			  \
+		atf_tc_skip("FPU does not implement traps on FP exceptions"); \
+} while (0)
 
 	/*
 	 * Same as above: some don't allow configuring the rounding mode.
 	 */
-#define	FPU_RND_PREREQ()		\
-	if (0 == fpsetround(fpsetround(FP_RZ)))\
-		atf_tc_skip("FPU does not implement configurable "	\
-		"rounding modes");
+#define	FPU_RND_PREREQ() do		  \
+{	  \
+	if (0 == fpsetround(fpsetround(FP_RZ)))  \
+		atf_tc_skip("FPU does not implement configurable "	  \
+		"rounding modes");	  \
+} while (0)
+#endif
+
+#ifdef __riscv__
+#define	FPU_EXC_PREREQ()		  \
+	atf_tc_skip("RISC-V does not support floating-point exception traps")
 #endif
 
 #ifndef FPU_EXC_PREREQ
-#define	FPU_EXC_PREREQ()	/* nothing */
+#define	FPU_EXC_PREREQ()	__nothing
 #endif
 #ifndef FPU_RND_PREREQ
-#define	FPU_RND_PREREQ()	/* nothing */
+#define	FPU_RND_PREREQ()	__nothing
 #endif
 
 



CVS commit: src/tests/lib

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 14:55:44 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_fpsetmask.c
src/tests/lib/libm: t_fenv.c

Log Message:
t_fpsetmask, t_fenv: Skip fp exception trap tests on RISC-V.

No architectural support for fp exception traps.

While here, make the macros behave a little better as C statements.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/tests/lib/libc/gen/t_fpsetmask.c
cvs rdiff -u -r1.17 -r1.18 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

2024-05-13 Thread Roland Illig
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

2024-05-13 Thread Roland Illig
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

2024-05-12 Thread Taylor R Campbell
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

2024-05-12 Thread Taylor R Campbell
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

2024-05-12 Thread Taylor R Campbell
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

2024-05-12 Thread Taylor R Campbell
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

2024-05-12 Thread Taylor R Campbell
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

2024-05-12 Thread Taylor R Campbell
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

2024-05-11 Thread Taylor R Campbell
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

2024-05-11 Thread Taylor R Campbell
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

2024-05-11 Thread Taylor R Campbell
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

2024-05-11 Thread Taylor R Campbell
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

2024-05-11 Thread Taylor R Campbell
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

2024-05-11 Thread Taylor R Campbell
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

2024-05-11 Thread Taylor R Campbell
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

2024-05-11 Thread Taylor R Campbell
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/libc/stdio

2024-05-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 11 14:39:53 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Fix sign error in ld128 case.

Also link back to where the test case came from.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libc/stdio/t_printf.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/libc/stdio/t_printf.c
diff -u src/tests/lib/libc/stdio/t_printf.c:1.17 src/tests/lib/libc/stdio/t_printf.c:1.18
--- src/tests/lib/libc/stdio/t_printf.c:1.17	Sat May 11 14:33:23 2024
+++ src/tests/lib/libc/stdio/t_printf.c	Sat May 11 14:39:53 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_printf.c,v 1.17 2024/05/11 14:33:23 riastradh Exp $ */
+/* $NetBSD: t_printf.c,v 1.18 2024/05/11 14:39:53 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -231,6 +231,11 @@ ATF_TC_BODY(snprintf_long_double_a, tc)
 		strcmp(buf, "0x8p-6") == 0),
 	"buf=%s", buf);
 
+	/*
+	 * Test case adapted from:
+	 *
+	 * https://mail-index.netbsd.org/tech-userlevel/2020/04/11/msg012329.html
+	 */
 #if LDBL_MAX_EXP >= 16384 && LDBL_MANT_DIG >= 64
 	snprintf(buf, sizeof buf, "%La", -0xc.ecececececececep+3788L);
 	ATF_CHECK_MSG((strcmp(buf, "-0x1.9d9d9d9d9d9d9d9cp+3791") == 0 ||
@@ -242,7 +247,7 @@ ATF_TC_BODY(snprintf_long_double_a, tc)
 
 #if LDBL_MAX_EXP >= 16384 && LDBL_MANT_DIG >= 113
 	snprintf(buf, sizeof buf, "%La",
-	0x1.cecececececececececececececep+3791L);
+	-0x1.cecececececececececececececep+3791L);
 	ATF_CHECK_MSG((strcmp(buf,
 		"-0x1.cecececececececececececececep+3791") == 0 ||
 		strcmp(buf, "-0x3.3338p+3790") == 0 ||



CVS commit: src/tests/lib/libc/stdio

2024-05-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 11 14:39:53 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Fix sign error in ld128 case.

Also link back to where the test case came from.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libc/stdio/t_printf.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/libc/stdio

2024-05-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 11 14:33:23 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Fix typo in ld128 case.

printf %La does not write the `L' suffix.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libc/stdio/t_printf.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/libc/stdio/t_printf.c
diff -u src/tests/lib/libc/stdio/t_printf.c:1.16 src/tests/lib/libc/stdio/t_printf.c:1.17
--- src/tests/lib/libc/stdio/t_printf.c:1.16	Thu May  9 22:38:29 2024
+++ src/tests/lib/libc/stdio/t_printf.c	Sat May 11 14:33:23 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_printf.c,v 1.16 2024/05/09 22:38:29 riastradh Exp $ */
+/* $NetBSD: t_printf.c,v 1.17 2024/05/11 14:33:23 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -244,7 +244,7 @@ ATF_TC_BODY(snprintf_long_double_a, tc)
 	snprintf(buf, sizeof buf, "%La",
 	0x1.cecececececececececececececep+3791L);
 	ATF_CHECK_MSG((strcmp(buf,
-		"-0x1.cecececececececececececececep+3791L") == 0 ||
+		"-0x1.cecececececececececececececep+3791") == 0 ||
 		strcmp(buf, "-0x3.3338p+3790") == 0 ||
 		strcmp(buf, "-0x6.767676767676767p+3789") == 0 ||
 		strcmp(buf, "-0xc.ecececececececep+3788") == 0),



CVS commit: src/tests/lib/libc/stdio

2024-05-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 11 14:33:23 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Fix typo in ld128 case.

printf %La does not write the `L' suffix.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libc/stdio/t_printf.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

2024-05-10 Thread Taylor R Campbell
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

2024-05-10 Thread Taylor R Campbell
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/libc/stdio

2024-05-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  9 22:38:29 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Fix another rounding error.

Noted by kre.

This doesn't break a passing test or fix a failed test, at least on
x86 -- our printf produces `0x1.533p+3' for the double case and
`0xa.99ap+0' for the long double case.  But of the hexadecimal number
literals that that start with 0x5 having three hexadigits to the
right of the fractional point, 0x5.4cdp+1 closest to the IEEE 754
binary64, VAX D, x86 extended precision, and IEEE 754 binary128
floating-point numbers closest to 10.6.

The reason is that the number 10.6 (or the nearest floating-point
number in any format with enough precision) is:

101.0100 1100 1100|1100... * 2^1 = 0x5.4cc|c...p+1

If we round at the vertical bar to the _nearest_ output with three
hexadigits of precision, the result is:

101.0100 1100 1101 * 2^1 = 0x5.4cdp+1


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libc/stdio/t_printf.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/libc/stdio/t_printf.c
diff -u src/tests/lib/libc/stdio/t_printf.c:1.15 src/tests/lib/libc/stdio/t_printf.c:1.16
--- src/tests/lib/libc/stdio/t_printf.c:1.15	Thu May  9 12:24:24 2024
+++ src/tests/lib/libc/stdio/t_printf.c	Thu May  9 22:38:29 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_printf.c,v 1.15 2024/05/09 12:24:24 riastradh Exp $ */
+/* $NetBSD: t_printf.c,v 1.16 2024/05/09 22:38:29 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -195,7 +195,7 @@ ATF_TC_BODY(snprintf_double_a, tc)
 	snprintf(buf, sizeof buf, "%.3a", (double)10.6);
 	ATF_CHECK_MSG((strcmp(buf, "0x1.533p+3") == 0 ||
 		strcmp(buf, "0x2.a66p+2") == 0 ||
-		strcmp(buf, "0x5.4ccp+1") == 0 ||
+		strcmp(buf, "0x5.4cdp+1") == 0 ||
 		strcmp(buf, "0xa.99ap+0") == 0),
 	"buf=%s", buf);
 
@@ -220,7 +220,7 @@ ATF_TC_BODY(snprintf_long_double_a, tc)
 	snprintf(buf, sizeof buf, "%.3La", 10.6L);
 	ATF_CHECK_MSG((strcmp(buf, "0x1.533p+3") == 0 ||
 		strcmp(buf, "0x2.a66p+2") == 0 ||
-		strcmp(buf, "0x5.4ccp+1") == 0 ||
+		strcmp(buf, "0x5.4cdp+1") == 0 ||
 		strcmp(buf, "0xa.99ap+0") == 0),
 	"buf=%s", buf);
 



CVS commit: src/tests/lib/libc/stdio

2024-05-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  9 22:38:29 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Fix another rounding error.

Noted by kre.

This doesn't break a passing test or fix a failed test, at least on
x86 -- our printf produces `0x1.533p+3' for the double case and
`0xa.99ap+0' for the long double case.  But of the hexadecimal number
literals that that start with 0x5 having three hexadigits to the
right of the fractional point, 0x5.4cdp+1 closest to the IEEE 754
binary64, VAX D, x86 extended precision, and IEEE 754 binary128
floating-point numbers closest to 10.6.

The reason is that the number 10.6 (or the nearest floating-point
number in any format with enough precision) is:

101.0100 1100 1100|1100... * 2^1 = 0x5.4cc|c...p+1

If we round at the vertical bar to the _nearest_ output with three
hexadigits of precision, the result is:

101.0100 1100 1101 * 2^1 = 0x5.4cdp+1


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libc/stdio/t_printf.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/libc/gen

2024-05-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  9 14:44:40 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_fpclassify.c

Log Message:
tests/lib/libc/gen/t_fpclassify: Test fpclassify on non-IEEE754 too.

Just exclude the subnormal parts on non-IEEE754 architectures
according to __FLT/DBL/LDBL_HAS_DENORM__.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/gen/t_fpclassify.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/libc/gen

2024-05-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  9 14:44:40 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_fpclassify.c

Log Message:
tests/lib/libc/gen/t_fpclassify: Test fpclassify on non-IEEE754 too.

Just exclude the subnormal parts on non-IEEE754 architectures
according to __FLT/DBL/LDBL_HAS_DENORM__.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/gen/t_fpclassify.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/libc/gen/t_fpclassify.c
diff -u src/tests/lib/libc/gen/t_fpclassify.c:1.5 src/tests/lib/libc/gen/t_fpclassify.c:1.6
--- src/tests/lib/libc/gen/t_fpclassify.c:1.5	Thu May  9 14:13:08 2024
+++ src/tests/lib/libc/gen/t_fpclassify.c	Thu May  9 14:44:39 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fpclassify.c,v 1.5 2024/05/09 14:13:08 riastradh Exp $ */
+/* $NetBSD: t_fpclassify.c,v 1.6 2024/05/09 14:44:39 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -33,21 +33,6 @@
 #include 
 #include 
 
-#ifndef _FLOAT_IEEE754
-
-ATF_TC(no_test);
-ATF_TC_HEAD(no_test, tc)
-{
-	atf_tc_set_md_var(tc, "descr", "Dummy test");
-}
-
-ATF_TC_BODY(no_test,tc)
-{
-	atf_tc_skip("Test not available on this architecture");
-}
-
-#else /* defined(_FLOAT_IEEE754) */
-
 ATF_TC(fpclassify_float);
 ATF_TC_HEAD(fpclassify_float, tc)
 {
@@ -75,6 +60,7 @@ ATF_TC_BODY(fpclassify_float, tc)
 	d0, f, e, 0.5, FLT_MIN_EXP);
 	d1 = d0;
 
+#ifdef __FLT_HAS_DENORM__
 	/* shift a "1" bit through the mantissa (skip the implicit bit) */
 	for (i = 1; i < FLT_MANT_DIG; i++) {
 		d1 /= 2;
@@ -108,6 +94,7 @@ ATF_TC_BODY(fpclassify_float, tc)
 		" expected normalized %a, exponent %d",
 		i, d1, f, e, 0.5, FLT_MIN_EXP - i);
 	}
+#endif
 
 	d1 /= 2;
 	ATF_CHECK_EQ_MSG(fpclassify(d1), FP_ZERO,
@@ -151,6 +138,7 @@ ATF_TC_BODY(fpclassify_double, tc)
 	d0, f, e, 0.5, DBL_MIN_EXP);
 	d1 = d0;
 
+#ifdef __DBL_HAS_DENORM__
 	/* shift a "1" bit through the mantissa (skip the implicit bit) */
 	for (i = 1; i < DBL_MANT_DIG; i++) {
 		d1 /= 2;
@@ -184,6 +172,7 @@ ATF_TC_BODY(fpclassify_double, tc)
 		" expected normalized %a, exponent %d",
 		i, d1, f, e, 0.5, DBL_MIN_EXP - i);
 	}
+#endif
 
 	d1 /= 2;
 	ATF_CHECK_EQ_MSG(fpclassify(d1), FP_ZERO,
@@ -227,6 +216,7 @@ ATF_TC_BODY(fpclassify_long_double, tc)
 	d0, f, e, 0.5L, LDBL_MIN_EXP);
 	d1 = d0;
 
+#ifdef __LDBL_HAS_DENORM__
 	/* shift a "1" bit through the mantissa (skip the implicit bit) */
 	for (i = 1; i < LDBL_MANT_DIG; i++) {
 		d1 /= 2;
@@ -260,6 +250,7 @@ ATF_TC_BODY(fpclassify_long_double, tc)
 		" expected normalized %La, exponent %d",
 		i, d1, f, e, 0.5L, LDBL_MIN_EXP - i);
 	}
+#endif
 
 	d1 /= 2;
 	ATF_CHECK_EQ_MSG(fpclassify(d1), FP_ZERO,
@@ -276,18 +267,12 @@ ATF_TC_BODY(fpclassify_long_double, tc)
 	d1, f, e, 0.L, 0);
 }
 
-#endif /* _FLOAT_IEEE754 */
-
 ATF_TP_ADD_TCS(tp)
 {
 
-#ifndef _FLOAT_IEEE754
-	ATF_TP_ADD_TC(tp, no_test);
-#else
 	ATF_TP_ADD_TC(tp, fpclassify_float);
 	ATF_TP_ADD_TC(tp, fpclassify_double);
 	ATF_TP_ADD_TC(tp, fpclassify_long_double);
-#endif /* _FLOAT_IEEE754 */
 
 	return atf_no_error();
 }



CVS commit: src/tests/lib/libc/gen

2024-05-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  9 14:13:09 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_fpclassify.c

Log Message:
tests/lib/libc/gen/t_fpclassify: Spruce this up a bit.

Provide more useful diagnostics when tests fail.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/t_fpclassify.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/libc/gen

2024-05-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  9 14:13:09 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_fpclassify.c

Log Message:
tests/lib/libc/gen/t_fpclassify: Spruce this up a bit.

Provide more useful diagnostics when tests fail.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/t_fpclassify.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/libc/gen/t_fpclassify.c
diff -u src/tests/lib/libc/gen/t_fpclassify.c:1.4 src/tests/lib/libc/gen/t_fpclassify.c:1.5
--- src/tests/lib/libc/gen/t_fpclassify.c:1.4	Tue May  7 21:00:00 2024
+++ src/tests/lib/libc/gen/t_fpclassify.c	Thu May  9 14:13:08 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fpclassify.c,v 1.4 2024/05/07 21:00:00 riastradh Exp $ */
+/* $NetBSD: t_fpclassify.c,v 1.5 2024/05/09 14:13:08 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -61,35 +61,67 @@ ATF_TC_BODY(fpclassify_float, tc)
 	int e, i;
 
 	d0 = FLT_MIN;
-	ATF_REQUIRE_EQ(fpclassify(d0), FP_NORMAL);
+	ATF_CHECK_EQ_MSG(fpclassify(d0), FP_NORMAL,
+	"fpclassify(%a)=%d FP_NORMAL=%d",
+	d0, fpclassify(d0), FP_NORMAL);
 	f = frexpf(d0, );
-	ATF_REQUIRE_EQ(e, FLT_MIN_EXP);
-	ATF_REQUIRE_EQ(f, 0.5);
+	ATF_CHECK_EQ_MSG(e, FLT_MIN_EXP,
+	"frexpf(%a) returned normalized %a, exponent %d;"
+	" expected normalized %a, exponent %d",
+	d0, f, e, 0.5, FLT_MIN_EXP);
+	ATF_CHECK_EQ_MSG(f, 0.5,
+	"frexpf(%a) returned normalized %a, exponent %d;"
+	" expected normalized %a, exponent %d",
+	d0, f, e, 0.5, FLT_MIN_EXP);
 	d1 = d0;
 
 	/* shift a "1" bit through the mantissa (skip the implicit bit) */
 	for (i = 1; i < FLT_MANT_DIG; i++) {
 		d1 /= 2;
-		ATF_REQUIRE_EQ(fpclassify(d1), FP_SUBNORMAL);
-		ATF_REQUIRE(d1 > 0 && d1 < d0);
+		ATF_CHECK_EQ_MSG(fpclassify(d1), FP_SUBNORMAL,
+		"[%d] fpclassify(%a)=%d FP_SUBNORMAL=%d",
+		i, d1, fpclassify(d1), FP_SUBNORMAL);
+		ATF_CHECK_MSG(d1 > 0 && d1 < d0,
+		"[%d] d1=%a d0=%a", i, d1, d0);
 
 		d2 = ldexpf(d0, -i);
-		ATF_REQUIRE_EQ(d2, d1);
+		ATF_CHECK_EQ_MSG(d2, d1, "[%d] ldexpf(%a, -%d)=%a != %a",
+		i, d0, i, d2, d1);
 
 		d2 = modff(d1, );
-		ATF_REQUIRE_EQ(d2, d1);
-		ATF_REQUIRE_EQ(ip, 0);
+		ATF_CHECK_EQ_MSG(d2, d1,
+		"[%d] modff(%a) returned int %a, frac %a;"
+		" expected int %a, frac %a",
+		i, d1, ip, d2, 0., d1);
+		ATF_CHECK_EQ_MSG(ip, 0,
+		"[%d] modff(%a) returned int %a, frac %a;"
+		" expected int %a, frac %a",
+		i, d1, ip, d2, 0., d1);
 
 		f = frexpf(d1, );
-		ATF_REQUIRE_EQ(e, FLT_MIN_EXP - i);
-		ATF_REQUIRE_EQ(f, 0.5);
+		ATF_CHECK_EQ_MSG(e, FLT_MIN_EXP - i,
+		"[%d] frexpf(%a) returned normalized %a, exponent %d;"
+		" expected normalized %a, exponent %d",
+		i, d1, f, e, 0.5, FLT_MIN_EXP - i);
+		ATF_CHECK_EQ_MSG(f, 0.5,
+		"[%d] frexpf(%a) returned normalized %a, exponent %d;"
+		" expected normalized %a, exponent %d",
+		i, d1, f, e, 0.5, FLT_MIN_EXP - i);
 	}
 
 	d1 /= 2;
-	ATF_REQUIRE_EQ(fpclassify(d1), FP_ZERO);
+	ATF_CHECK_EQ_MSG(fpclassify(d1), FP_ZERO,
+	"fpclassify(%a)=%d FP_ZERO=%d",
+	d1, fpclassify(d1), FP_ZERO);
 	f = frexpf(d1, );
-	ATF_REQUIRE_EQ(e, 0);
-	ATF_REQUIRE_EQ(f, 0);
+	ATF_CHECK_EQ_MSG(e, 0,
+	"frexpf(%a) returned normalized %a, exponent %d;"
+	" expected normalized %a, exponent %d",
+	d1, f, e, 0., 0);
+	ATF_CHECK_EQ_MSG(f, 0,
+	"frexpf(%a) returned normalized %a, exponent %d;"
+	" expected normalized %a, exponent %d",
+	d1, f, e, 0., 0);
 }
 
 ATF_TC(fpclassify_double);
@@ -105,35 +137,67 @@ ATF_TC_BODY(fpclassify_double, tc)
 	int e, i;
 
 	d0 = DBL_MIN;
-	ATF_REQUIRE_EQ(fpclassify(d0), FP_NORMAL);
+	ATF_CHECK_EQ_MSG(fpclassify(d0), FP_NORMAL,
+	"fpclassify(%a)=%d FP_NORMAL=%d",
+	d0, fpclassify(d0), FP_NORMAL);
 	f = frexp(d0, );
-	ATF_REQUIRE_EQ(e, DBL_MIN_EXP);
-	ATF_REQUIRE_EQ(f, 0.5);
+	ATF_CHECK_EQ_MSG(e, DBL_MIN_EXP,
+	"frexp(%a) returned normalized %a, exponent %d;"
+	" expected normalized %a, exponent %d",
+	d0, f, e, 0.5, DBL_MIN_EXP);
+	ATF_CHECK_EQ_MSG(f, 0.5,
+	"frexp(%a) returned normalized %a, exponent %d;"
+	" expected normalized %a, exponent %d",
+	d0, f, e, 0.5, DBL_MIN_EXP);
 	d1 = d0;
 
 	/* shift a "1" bit through the mantissa (skip the implicit bit) */
 	for (i = 1; i < DBL_MANT_DIG; i++) {
 		d1 /= 2;
-		ATF_REQUIRE_EQ(fpclassify(d1), FP_SUBNORMAL);
-		ATF_REQUIRE(d1 > 0 && d1 < d0);
+		ATF_CHECK_EQ_MSG(fpclassify(d1), FP_SUBNORMAL,
+		"[%d] fpclassify(%a)=%d FP_SUBNORMAL=%d",
+		i, d1, fpclassify(d1), FP_SUBNORMAL);
+		ATF_CHECK_MSG(d1 > 0 && d1 < d0,
+		"[%d] d1=%a d0=%a", i, d1, d0);
 
 		d2 = ldexp(d0, -i);
-		ATF_REQUIRE_EQ(d2, d1);
+		ATF_CHECK_EQ_MSG(d2, d1, "[%d] ldexp(%a, -%d)=%a != %a",
+		i, d0, i, d2, d1);
 
 		d2 = modf(d1, );
-		ATF_REQUIRE_EQ(d2, d1);
-		ATF_REQUIRE_EQ(ip, 0);
+		ATF_CHECK_EQ_MSG(d2, d1,
+	

CVS commit: src/tests/lib/libm

2024-05-09 Thread Taylor R Campbell
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

2024-05-09 Thread Taylor R Campbell
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

2024-05-09 Thread Taylor R Campbell
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

2024-05-09 Thread Taylor R Campbell
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

2024-05-09 Thread Taylor R Campbell
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

2024-05-09 Thread Taylor R Campbell
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

2024-05-08 Thread Taylor R Campbell
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

2024-05-08 Thread Taylor R Campbell
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

2024-05-08 Thread Taylor R Campbell
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

2024-05-08 Thread Taylor R Campbell
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/libc/stdio

2024-05-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May  8 20:23:15 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Add another %La test.

This one was adapted from the screw case shown in

https://mail-index.netbsd.org/tech-userlevel/2020/04/11/msg012329.html

which wasn't broken in our libc, but which nevertheless prompted us
to commit a wrong and apparently untested patch that has rendered
printf %La broken for the last four years, which is a little
embarrassing.  (The part of that patch that led to a buffer overrun
has been worked around, so now the output is just incorrect.)

PR lib/56937: printf(3) long double %a formatting is broken


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libc/stdio/t_printf.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/libc/stdio/t_printf.c
diff -u src/tests/lib/libc/stdio/t_printf.c:1.13 src/tests/lib/libc/stdio/t_printf.c:1.14
--- src/tests/lib/libc/stdio/t_printf.c:1.13	Wed May  8 20:19:37 2024
+++ src/tests/lib/libc/stdio/t_printf.c	Wed May  8 20:23:15 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_printf.c,v 1.13 2024/05/08 20:19:37 riastradh Exp $ */
+/* $NetBSD: t_printf.c,v 1.14 2024/05/08 20:23:15 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -233,6 +233,26 @@ ATF_TC_BODY(snprintf_long_double_a, tc)
 		strcmp(buf, "0x4p-5") == 0 ||
 		strcmp(buf, "0x8p-6") == 0),
 	"buf=%s", buf);
+
+#if LDBL_MAX_EXP >= 16384 && LDBL_MANT_DIG >= 64
+	snprintf(buf, sizeof buf, "%La", -0xc.ecececececececep+3788L);
+	ATF_CHECK_MSG((strcmp(buf, "-0x1.9d9d9d9d9d9d9d9cp+3791") == 0 ||
+		strcmp(buf, "-0x3.3b3b3b3b3b3b3b38p+3790") == 0 ||
+		strcmp(buf, "-0x6.7676767676767674p+3789") == 0 ||
+		strcmp(buf, "-0xc.ecececececececep+3788") == 0),
+	"buf=%s", buf);
+#endif
+
+#if LDBL_MAX_EXP >= 16384 && LDBL_MANT_DIG >= 113
+	snprintf(buf, sizeof buf, "%La",
+	0x1.cecececececececececececececep+3791L);
+	ATF_CHECK_MSG((strcmp(buf,
+		"-0x1.cecececececececececececececep+3791L") == 0 ||
+		strcmp(buf, "-0x3.3338p+3790") == 0 ||
+		strcmp(buf, "-0x6.767676767676767p+3789") == 0 ||
+		strcmp(buf, "-0xc.ecececececececep+3788") == 0),
+	"buf=%s", buf);
+#endif
 }
 
 /* is "long double" and "double" different? */



CVS commit: src/tests/lib/libc/stdio

2024-05-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May  8 20:23:15 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Add another %La test.

This one was adapted from the screw case shown in

https://mail-index.netbsd.org/tech-userlevel/2020/04/11/msg012329.html

which wasn't broken in our libc, but which nevertheless prompted us
to commit a wrong and apparently untested patch that has rendered
printf %La broken for the last four years, which is a little
embarrassing.  (The part of that patch that led to a buffer overrun
has been worked around, so now the output is just incorrect.)

PR lib/56937: printf(3) long double %a formatting is broken


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libc/stdio/t_printf.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/libc/stdio

2024-05-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May  8 20:19:37 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Fix %a test the same way.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libc/stdio/t_printf.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/libc/stdio/t_printf.c
diff -u src/tests/lib/libc/stdio/t_printf.c:1.12 src/tests/lib/libc/stdio/t_printf.c:1.13
--- src/tests/lib/libc/stdio/t_printf.c:1.12	Wed May  8 20:04:33 2024
+++ src/tests/lib/libc/stdio/t_printf.c	Wed May  8 20:19:37 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_printf.c,v 1.12 2024/05/08 20:04:33 riastradh Exp $ */
+/* $NetBSD: t_printf.c,v 1.13 2024/05/08 20:19:37 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -196,7 +196,7 @@ ATF_TC_BODY(snprintf_double_a, tc)
 	ATF_CHECK_MSG((strcmp(buf, "0x1.533p+3") == 0 ||
 		strcmp(buf, "0x2.a66p+2") == 0 ||
 		strcmp(buf, "0x5.4ccp+1") == 0 ||
-		strcmp(buf, "0xa.998p+0") == 0),
+		strcmp(buf, "0xa.99ap+0") == 0),
 	"buf=%s", buf);
 
 	snprintf(buf, sizeof buf, "%a", (double)0.125);



CVS commit: src/tests/lib/libc/stdio

2024-05-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May  8 20:19:37 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Fix %a test the same way.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libc/stdio/t_printf.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/libc/stdio

2024-05-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May  8 20:04:33 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Fix %La test.

0xa.99ap+0 is closer to (long double)10.6 in x86 ld80 and in
binary128 (and possibly more formats, haven't verified).


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libc/stdio/t_printf.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/libc/stdio/t_printf.c
diff -u src/tests/lib/libc/stdio/t_printf.c:1.11 src/tests/lib/libc/stdio/t_printf.c:1.12
--- src/tests/lib/libc/stdio/t_printf.c:1.11	Wed May  8 18:19:57 2024
+++ src/tests/lib/libc/stdio/t_printf.c	Wed May  8 20:04:33 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_printf.c,v 1.11 2024/05/08 18:19:57 riastradh Exp $ */
+/* $NetBSD: t_printf.c,v 1.12 2024/05/08 20:04:33 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -224,7 +224,7 @@ ATF_TC_BODY(snprintf_long_double_a, tc)
 	ATF_CHECK_MSG((strcmp(buf, "0x1.533p+3") == 0 ||
 		strcmp(buf, "0x2.a66p+2") == 0 ||
 		strcmp(buf, "0x5.4ccp+1") == 0 ||
-		strcmp(buf, "0xa.998p+0") == 0),
+		strcmp(buf, "0xa.99ap+0") == 0),
 	"buf=%s", buf);
 
 	snprintf(buf, sizeof buf, "%La", 0.125L);



CVS commit: src/tests/lib/libc/stdio

2024-05-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May  8 20:04:33 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Fix %La test.

0xa.99ap+0 is closer to (long double)10.6 in x86 ld80 and in
binary128 (and possibly more formats, haven't verified).


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libc/stdio/t_printf.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/libc/stdio

2024-05-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May  8 18:19:57 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Add a couple simple %La tests.

PR lib/56937: printf(3) long double %a formatting is broken


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/stdio/t_printf.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/libc/stdio

2024-05-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May  8 18:19:57 UTC 2024

Modified Files:
src/tests/lib/libc/stdio: t_printf.c

Log Message:
tests/lib/libc/stdio/t_printf: Add a couple simple %La tests.

PR lib/56937: printf(3) long double %a formatting is broken


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/stdio/t_printf.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/libc/stdio/t_printf.c
diff -u src/tests/lib/libc/stdio/t_printf.c:1.10 src/tests/lib/libc/stdio/t_printf.c:1.11
--- src/tests/lib/libc/stdio/t_printf.c:1.10	Tue Apr  4 19:39:38 2023
+++ src/tests/lib/libc/stdio/t_printf.c	Wed May  8 18:19:57 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_printf.c,v 1.10 2023/04/04 19:39:38 he Exp $ */
+/* $NetBSD: t_printf.c,v 1.11 2024/05/08 18:19:57 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,14 +28,16 @@
 
 #include 
 #include 
+
 #include 
+#include 
+#include 
 #include 
-#include 
 #include 
+#include 
+#include 
 #include 
 #include 
-#include 
-#include 
 
 ATF_TC(snprintf_c99);
 ATF_TC_HEAD(snprintf_c99, tc)
@@ -191,7 +193,46 @@ ATF_TC_BODY(snprintf_double_a, tc)
 	char buf[1000];
 
 	snprintf(buf, sizeof buf, "%.3a", (double)10.6);
-	ATF_REQUIRE_STREQ("0x1.533p+3", buf);
+	ATF_CHECK_MSG((strcmp(buf, "0x1.533p+3") == 0 ||
+		strcmp(buf, "0x2.a66p+2") == 0 ||
+		strcmp(buf, "0x5.4ccp+1") == 0 ||
+		strcmp(buf, "0xa.998p+0") == 0),
+	"buf=%s", buf);
+
+	snprintf(buf, sizeof buf, "%a", (double)0.125);
+	ATF_CHECK_MSG((strcmp(buf, "0x1p-3") == 0 ||
+		strcmp(buf, "0x2p-4") == 0 ||
+		strcmp(buf, "0x4p-5") == 0 ||
+		strcmp(buf, "0x8p-6") == 0),
+	"buf=%s", buf);
+}
+
+ATF_TC(snprintf_long_double_a);
+ATF_TC_HEAD(snprintf_long_double_a, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test printf La format");
+}
+
+ATF_TC_BODY(snprintf_long_double_a, tc)
+{
+	char buf[1000];
+
+	atf_tc_expect_fail("PR lib/56937:"
+	" printf(3) long double %%a formatting is broken");
+
+	snprintf(buf, sizeof buf, "%.3La", 10.6L);
+	ATF_CHECK_MSG((strcmp(buf, "0x1.533p+3") == 0 ||
+		strcmp(buf, "0x2.a66p+2") == 0 ||
+		strcmp(buf, "0x5.4ccp+1") == 0 ||
+		strcmp(buf, "0xa.998p+0") == 0),
+	"buf=%s", buf);
+
+	snprintf(buf, sizeof buf, "%La", 0.125L);
+	ATF_CHECK_MSG((strcmp(buf, "0x1p-3") == 0 ||
+		strcmp(buf, "0x2p-4") == 0 ||
+		strcmp(buf, "0x4p-5") == 0 ||
+		strcmp(buf, "0x8p-6") == 0),
+	"buf=%s", buf);
 }
 
 /* is "long double" and "double" different? */
@@ -235,6 +276,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, snprintf_float);
 	ATF_TP_ADD_TC(tp, sprintf_zeropad);
 	ATF_TP_ADD_TC(tp, snprintf_double_a);
+	ATF_TP_ADD_TC(tp, snprintf_long_double_a);
 #ifndef WIDE_DOUBLE
 	ATF_TP_ADD_TC(tp, pr57250_fix);
 #endif



CVS commit: src/tests/lib/libm

2024-05-08 Thread Taylor R Campbell
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

2024-05-08 Thread Taylor R Campbell
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/libc/gen

2024-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May  7 21:00:00 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_fpclassify.c

Log Message:
tests/lib/libc/gen/t_fpclassify: Enable long double tests.

The necessary long double symbols should all be available now.  If
there are any architectures where they're not, we can fix those
architectures.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/t_fpclassify.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/libc/gen/t_fpclassify.c
diff -u src/tests/lib/libc/gen/t_fpclassify.c:1.3 src/tests/lib/libc/gen/t_fpclassify.c:1.4
--- src/tests/lib/libc/gen/t_fpclassify.c:1.3	Sat Oct  1 21:47:08 2011
+++ src/tests/lib/libc/gen/t_fpclassify.c	Tue May  7 21:00:00 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fpclassify.c,v 1.3 2011/10/01 21:47:08 christos Exp $ */
+/* $NetBSD: t_fpclassify.c,v 1.4 2024/05/07 21:00:00 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -136,13 +136,6 @@ ATF_TC_BODY(fpclassify_double, tc)
 	ATF_REQUIRE_EQ(f, 0);
 }
 
-/*
- * XXX NetBSD doesn't have long-double flavors of frexp, ldexp, and modf,
- * XXX so this test is disabled.
- */
-
-#ifdef TEST_LONG_DOUBLE
-
 ATF_TC(fpclassify_long_double);
 ATF_TC_HEAD(fpclassify_long_double, tc)
 {
@@ -186,7 +179,7 @@ ATF_TC_BODY(fpclassify_long_double, tc)
 	ATF_REQUIRE_EQ(e, 0);
 	ATF_REQUIRE_EQ(f, 0);
 }
-#endif /* TEST_LONG_DOUBLE */
+
 #endif /* _FLOAT_IEEE754 */
 
 ATF_TP_ADD_TCS(tp)
@@ -197,9 +190,7 @@ ATF_TP_ADD_TCS(tp)
 #else
 	ATF_TP_ADD_TC(tp, fpclassify_float);
 	ATF_TP_ADD_TC(tp, fpclassify_double);
-#ifdef TEST_LONG_DOUBLE
 	ATF_TP_ADD_TC(tp, fpclassify_long_double);
-#endif /* TEST_LONG_DOUBLE */
 #endif /* _FLOAT_IEEE754 */
 
 	return atf_no_error();



CVS commit: src/tests/lib/libc/gen

2024-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May  7 21:00:00 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_fpclassify.c

Log Message:
tests/lib/libc/gen/t_fpclassify: Enable long double tests.

The necessary long double symbols should all be available now.  If
there are any architectures where they're not, we can fix those
architectures.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/t_fpclassify.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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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/libc/stdlib

2024-05-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May  6 18:39:36 UTC 2024

Modified Files:
src/tests/lib/libc/stdlib: t_strtod.c

Log Message:
tests/lib/libc/stdlib/t_strtod: Spruce up and nix needless #ifdefs.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/tests/lib/libc/stdlib/t_strtod.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/libc/stdlib

2024-05-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May  6 18:39:36 UTC 2024

Modified Files:
src/tests/lib/libc/stdlib: t_strtod.c

Log Message:
tests/lib/libc/stdlib/t_strtod: Spruce up and nix needless #ifdefs.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/tests/lib/libc/stdlib/t_strtod.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/libc/stdlib/t_strtod.c
diff -u src/tests/lib/libc/stdlib/t_strtod.c:1.35 src/tests/lib/libc/stdlib/t_strtod.c:1.36
--- src/tests/lib/libc/stdlib/t_strtod.c:1.35	Sun Jan 14 12:44:09 2024
+++ src/tests/lib/libc/stdlib/t_strtod.c	Mon May  6 18:39:36 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_strtod.c,v 1.35 2024/01/14 12:44:09 andvar Exp $ */
+/*	$NetBSD: t_strtod.c,v 1.36 2024/05/06 18:39:36 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 /* Public domain, Otto Moerbeek , 2006. */
 
 #include 
-__RCSID("$NetBSD: t_strtod.c,v 1.35 2024/01/14 12:44:09 andvar Exp $");
+__RCSID("$NetBSD: t_strtod.c,v 1.36 2024/05/06 18:39:36 riastradh Exp $");
 
 #include 
 #include 
@@ -44,12 +44,10 @@ __RCSID("$NetBSD: t_strtod.c,v 1.35 2024
 
 #include 
 
-#if !defined(__vax__)
 static const char * const inf_strings[] =
 { "Inf", "INF", "-Inf", "-INF", "Infinity", "+Infinity",
   "INFINITY", "-INFINITY", "InFiNiTy", "+InFiNiTy" };
-const char *nan_string = "NaN(x)y";
-#endif
+const char * const nan_string = "NaN(x)y";
 
 ATF_TC(strtod_basic);
 ATF_TC_HEAD(strtod_basic, tc)
@@ -68,8 +66,10 @@ ATF_TC_BODY(strtod_basic, tc)
 		errno = 0;
 		double d = strtod(buf, NULL);
 
-		ATF_REQUIRE(d > 0.0);
-		ATF_REQUIRE(errno == 0);
+		ATF_CHECK_MSG(d > 0, "i=%zu buf=\"%s\" d=%g errno=%d",
+		i, buf, d, errno);
+		ATF_CHECK_EQ_MSG(errno, 0, "i=%zu buf=\"%s\" d=%g errno=%d",
+		i, buf, d, errno);
 	}
 }
 
@@ -79,12 +79,6 @@ ATF_TC_HEAD(strtod_hex, tc)
 	atf_tc_set_md_var(tc, "descr", "A strtod(3) with hexadecimals");
 }
 
-#ifdef __vax__
-#define SMALL_NUM   1.0e-38
-#else
-#define SMALL_NUM   1.0e-40
-#endif
-
 ATF_TC_BODY(strtod_hex, tc)
 {
 	const char *str;
@@ -94,16 +88,18 @@ ATF_TC_BODY(strtod_hex, tc)
 	str = "-0x0";
 	d = strtod(str, );	/* -0.0 */
 
-	ATF_REQUIRE(end == str + 4);
-	ATF_REQUIRE(signbit(d) != 0);
-	ATF_REQUIRE(fabs(d) < SMALL_NUM);
+	ATF_CHECK_EQ_MSG(end, str + 4, "str=%p end=%p", str, end);
+	ATF_CHECK_MSG(signbit(d) != 0, "d=%g=%a signbit=%d", d, d, signbit(d));
+	ATF_CHECK_EQ_MSG(fabs(d), 0, "d=%g=%a, fabs(d)=%g=%a",
+	d, d, fabs(d), fabs(d));
 
 	str = "-0x";
 	d = strtod(str, );	/* -0.0 */
 
-	ATF_REQUIRE(end == str + 2);
-	ATF_REQUIRE(signbit(d) != 0);
-	ATF_REQUIRE(fabs(d) < SMALL_NUM);
+	ATF_CHECK_EQ_MSG(end, str + 2, "str=%p end=%p", str, end);
+	ATF_CHECK_MSG(signbit(d) != 0, "d=%g=%a signbit=%d", d, d, signbit(d));
+	ATF_CHECK_EQ_MSG(fabs(d), 0, "d=%g=%a fabs(d)=%g=%a",
+	d, d, fabs(d), fabs(d));
 }
 
 ATF_TC(strtod_inf);
@@ -114,14 +110,15 @@ ATF_TC_HEAD(strtod_inf, tc)
 
 ATF_TC_BODY(strtod_inf, tc)
 {
-#ifndef __vax__
+
+	if (!isinf(INFINITY))
+		atf_tc_skip("no infinities on this architecture");
+
 	for (size_t i = 0; i < __arraycount(inf_strings); i++) {
 		volatile double d = strtod(inf_strings[i], NULL);
-		ATF_REQUIRE(isinf(d) != 0);
+		ATF_CHECK_MSG(isinf(d), "inf_strings[%zu]=\"%s\" d=%g=%a",
+		i, inf_strings[i], d, d);
 	}
-#else
-	atf_tc_skip("vax not supported");
-#endif
 }
 
 ATF_TC(strtof_inf);
@@ -132,14 +129,17 @@ ATF_TC_HEAD(strtof_inf, tc)
 
 ATF_TC_BODY(strtof_inf, tc)
 {
-#ifndef __vax__
+
+	if (!isinf(INFINITY))
+		atf_tc_skip("no infinities on this architecture");
+
 	for (size_t i = 0; i < __arraycount(inf_strings); i++) {
 		volatile float f = strtof(inf_strings[i], NULL);
-		ATF_REQUIRE(isinf(f) != 0);
+		ATF_CHECK_MSG(isinf(f), "inf_strings[%zu]=\"%s\" f=%g=%a",
+		i, inf_strings[i], f, f);
+		ATF_CHECK_MSG(isinff(f), "inf_strings[%zu]=\"%s\" f=%g=%a",
+		i, inf_strings[i], f, f);
 	}
-#else
-	atf_tc_skip("vax not supported");
-#endif
 }
 
 ATF_TC(strtold_inf);
@@ -150,19 +150,15 @@ ATF_TC_HEAD(strtold_inf, tc)
 
 ATF_TC_BODY(strtold_inf, tc)
 {
-#ifndef __vax__
-#   ifdef __HAVE_LONG_DOUBLE
+
+	if (!isinf(INFINITY))
+		atf_tc_skip("no infinities on this architecture");
 
 	for (size_t i = 0; i < __arraycount(inf_strings); i++) {
 		volatile long double ld = strtold(inf_strings[i], NULL);
-		ATF_REQUIRE(isinf(ld) != 0);
+		ATF_CHECK_MSG(isinf(ld), "inf_strings[%zu]=\"%s\" ld=%Lg=%La",
+		i, inf_strings[i], ld, ld);
 	}
-#   else
-	atf_tc_skip("Requires long double support");
-#   endif
-#else
-	atf_tc_skip("vax not supported");
-#endif
 }
 
 ATF_TC(strtod_nan);
@@ -173,15 +169,16 @@ ATF_TC_HEAD(strtod_nan, tc)
 
 ATF_TC_BODY(strtod_nan, tc)
 {
-#ifndef __vax__
 	char *end;
 
-	volatile double d = strtod(nan_string, );
-	ATF_REQUIRE(isnan(d) != 0);
-	ATF_REQUIRE(strcmp(end, "y") == 0);
-#else
-	atf_tc_skip("vax 

CVS commit: src/tests/lib/libm

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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/libc/gen

2024-05-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May  6 17:53:43 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_floatunditf.c

Log Message:
tests/lib/libc/gen/t_floatunditf: Nix __HAVE_LONG_DOUBLE conditional.

Conversion from uint64_t to long double should work on all ports,
including those where long double is the same as double, i.e., where
__HAVE_LONG_DOUBLE is undefined.

Instead, conditionalize the test cases on how many bits of precision
long double has in the significand, according to LDBL_MANT_DIG.  The
conditionals here should handle binary128, powerpc double-dekker
(~106-bit precision), x86 extended precision (80-bit), m68k extended
precision (80-bit), and VAX D (56-bit).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/gen/t_floatunditf.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/libc/gen/t_floatunditf.c
diff -u src/tests/lib/libc/gen/t_floatunditf.c:1.6 src/tests/lib/libc/gen/t_floatunditf.c:1.7
--- src/tests/lib/libc/gen/t_floatunditf.c:1.6	Tue Nov  4 00:20:19 2014
+++ src/tests/lib/libc/gen/t_floatunditf.c	Mon May  6 17:53:43 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_floatunditf.c,v 1.6 2014/11/04 00:20:19 justin Exp $ */
+/*	$NetBSD: t_floatunditf.c,v 1.7 2024/05/06 17:53:43 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -26,15 +26,23 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include 
+__RCSID("$NetBSD: t_floatunditf.c,v 1.7 2024/05/06 17:53:43 riastradh Exp $");
+
 #include 
+#include 
 #include 
 #include 
 
-#ifdef __HAVE_LONG_DOUBLE
+#if LDBL_MANT_DIG < 53
+#error Unsupported long double format
+#endif
+
 static const struct {
 	uint64_t u64;
 	long double ld;
 } testcases[] = {
+#if LDBL_MANT_DIG >= 64
 	{ 0xULL, 0xf.fffp+60L },
 	{ 0xfffeULL, 0xf.ffep+60L },
 	{ 0xfffdULL, 0xf.ffdp+60L },
@@ -46,9 +54,12 @@ static const struct {
 	{ 0x7ffULL, 0xf.fep+55L },
 	{ 0x3ffULL, 0xf.fcp+54L },
 	{ 0x1ffULL, 0xf.f8p+53L },
+#endif
+#if LDBL_MANT_DIG >= 56
 	{ 0xffULL, 0xf.fp+52L },
 	{ 0x7fULL, 0xf.ep+51L },
 	{ 0x3fULL, 0xf.cp+50L },
+#endif
 	{ 0x1fULL, 0xf.8p+49L },
 	{ 0xfULL, 0xf.p+48L },
 	{ 0x7ULL, 0xf.fffep+47L },
@@ -103,7 +114,6 @@ static const struct {
 	{ 0x3ULL, 0xcp-2L },
 	{ 0x1ULL, 0x8p-3L },
 };
-#endif
 
 ATF_TC(floatunditf);
 ATF_TC_HEAD(floatunditf, tc)
@@ -114,9 +124,6 @@ ATF_TC_HEAD(floatunditf, tc)
 
 ATF_TC_BODY(floatunditf, tc)
 {
-#ifndef __HAVE_LONG_DOUBLE
-	atf_tc_skip("Requires long double support");
-#else
 	size_t i;
 
 	for (i = 0; i < __arraycount(testcases); ++i)
@@ -125,7 +132,6 @@ ATF_TC_BODY(floatunditf, tc)
 		"#%zu: expected %.20Lf, got %.20Lf\n", i,
 		testcases[i].ld,
 		(long double)testcases[i].u64);
-#endif
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/tests/lib/libc/gen

2024-05-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May  6 17:53:43 UTC 2024

Modified Files:
src/tests/lib/libc/gen: t_floatunditf.c

Log Message:
tests/lib/libc/gen/t_floatunditf: Nix __HAVE_LONG_DOUBLE conditional.

Conversion from uint64_t to long double should work on all ports,
including those where long double is the same as double, i.e., where
__HAVE_LONG_DOUBLE is undefined.

Instead, conditionalize the test cases on how many bits of precision
long double has in the significand, according to LDBL_MANT_DIG.  The
conditionals here should handle binary128, powerpc double-dekker
(~106-bit precision), x86 extended precision (80-bit), m68k extended
precision (80-bit), and VAX D (56-bit).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/gen/t_floatunditf.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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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

2024-05-06 Thread Taylor R Campbell
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/libc/setjmp

2024-05-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May  6 12:11:03 UTC 2024

Modified Files:
src/tests/lib/libc/setjmp: t_sigstack.c

Log Message:
tests/lib/libc/setjmp/t_sigstack: Add missing comment for 1.10.

PR lib/57946


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/setjmp/t_sigstack.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/libc/setjmp

2024-05-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May  6 12:11:03 UTC 2024

Modified Files:
src/tests/lib/libc/setjmp: t_sigstack.c

Log Message:
tests/lib/libc/setjmp/t_sigstack: Add missing comment for 1.10.

PR lib/57946


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/setjmp/t_sigstack.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/libc/setjmp/t_sigstack.c
diff -u src/tests/lib/libc/setjmp/t_sigstack.c:1.10 src/tests/lib/libc/setjmp/t_sigstack.c:1.11
--- src/tests/lib/libc/setjmp/t_sigstack.c:1.10	Mon May  6 06:58:00 2024
+++ src/tests/lib/libc/setjmp/t_sigstack.c	Mon May  6 12:11:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_sigstack.c,v 1.10 2024/05/06 06:58:00 skrll Exp $	*/
+/*	$NetBSD: t_sigstack.c,v 1.11 2024/05/06 12:11:03 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_sigstack.c,v 1.10 2024/05/06 06:58:00 skrll Exp $");
+__RCSID("$NetBSD: t_sigstack.c,v 1.11 2024/05/06 12:11:03 riastradh Exp $");
 
 #include 
 #include 
@@ -83,6 +83,7 @@ on_sigusr1(int signo, siginfo_t *si, voi
 	 *
 	 *	aarch64
 	 *	alpha
+	 *	arm
 	 *	i386
 	 *	m68k
 	 *	or1k



CVS commit: src/tests/lib/libc/setjmp

2024-05-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon May  6 06:58:00 UTC 2024

Modified Files:
src/tests/lib/libc/setjmp: t_sigstack.c

Log Message:
arm has been fixed


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/setjmp/t_sigstack.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/libc/setjmp/t_sigstack.c
diff -u src/tests/lib/libc/setjmp/t_sigstack.c:1.9 src/tests/lib/libc/setjmp/t_sigstack.c:1.10
--- src/tests/lib/libc/setjmp/t_sigstack.c:1.9	Thu Apr  4 00:46:42 2024
+++ src/tests/lib/libc/setjmp/t_sigstack.c	Mon May  6 06:58:00 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_sigstack.c,v 1.9 2024/04/04 00:46:42 riastradh Exp $	*/
+/*	$NetBSD: t_sigstack.c,v 1.10 2024/05/06 06:58:00 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_sigstack.c,v 1.9 2024/04/04 00:46:42 riastradh Exp $");
+__RCSID("$NetBSD: t_sigstack.c,v 1.10 2024/05/06 06:58:00 skrll Exp $");
 
 #include 
 #include 
@@ -92,7 +92,7 @@ on_sigusr1(int signo, siginfo_t *si, voi
 	 *	vax
 	 *	x86_64
 	 */
-#if defined __arm__ || defined __hppa__ || \
+#if defined __hppa__ || \
 defined __ia64__ || defined __mips__ || defined __sh3__ || \
 defined __sparc__ || defined __sparc64__
 	if (nentries > 0)



CVS commit: src/tests/lib/libc/setjmp

2024-05-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon May  6 06:58:00 UTC 2024

Modified Files:
src/tests/lib/libc/setjmp: t_sigstack.c

Log Message:
arm has been fixed


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/setjmp/t_sigstack.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

2024-05-05 Thread Taylor R Campbell
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

2024-05-05 Thread Taylor R Campbell
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

2024-05-05 Thread Taylor R Campbell
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

2024-05-05 Thread Taylor R Campbell
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

2024-05-05 Thread Taylor R Campbell
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

2024-05-05 Thread Taylor R Campbell
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

2024-05-05 Thread Taylor R Campbell
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

2024-05-05 Thread Taylor R Campbell
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

2024-05-03 Thread Taylor R Campbell
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

2024-05-03 Thread Taylor R Campbell
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

2024-05-02 Thread Taylor R Campbell
> 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

2024-05-02 Thread Roland Illig
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

2024-05-02 Thread Taylor R Campbell
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

2024-05-02 Thread Taylor R Campbell
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.



  1   2   3   4   5   6   7   8   >