CVS commit: src/sys/external/bsd/drm2/linux

2024-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 22 15:59:25 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/linux: linux_xa.c

Log Message:
linux_xa: Delete and replace collision in xa_store as intended.

Don't free the colliding node that's still in the tree.

Noted by rjs@.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_xa.c

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

Modified files:

Index: src/sys/external/bsd/drm2/linux/linux_xa.c
diff -u src/sys/external/bsd/drm2/linux/linux_xa.c:1.3 src/sys/external/bsd/drm2/linux/linux_xa.c:1.4
--- src/sys/external/bsd/drm2/linux/linux_xa.c:1.3	Sun Dec 19 12:05:25 2021
+++ src/sys/external/bsd/drm2/linux/linux_xa.c	Wed May 22 15:59:25 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_xa.c,v 1.3 2021/12/19 12:05:25 riastradh Exp $	*/
+/*	$NetBSD: linux_xa.c,v 1.4 2024/05/22 15:59:25 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_xa.c,v 1.3 2021/12/19 12:05:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_xa.c,v 1.4 2024/05/22 15:59:25 riastradh Exp $");
 
 /*
  * This is a lame-o implementation of the Linux xarray data type, which
@@ -124,7 +124,7 @@ xa_load(struct xarray *xa, unsigned long
 void *
 xa_store(struct xarray *xa, unsigned long key, void *datum, gfp_t gfp)
 {
-	struct node *n, *collision;
+	struct node *n, *collision, *recollision;
 
 	KASSERT(datum != NULL);
 	KASSERT(((uintptr_t)datum & 0x3) == 0);
@@ -137,6 +137,11 @@ xa_store(struct xarray *xa, unsigned lon
 
 	mutex_enter(>xa_lock);
 	collision = rb_tree_insert_node(>xa_tree, n);
+	if (collision != n) {
+		rb_tree_remove_node(>xa_tree, n);
+		recollision = rb_tree_insert_node(>xa_tree, n);
+		KASSERT(recollision == n);
+	}
 	mutex_exit(>xa_lock);
 
 	if (collision != n) {



CVS commit: src/sys/external/bsd/drm2/linux

2024-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 22 15:59:25 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/linux: linux_xa.c

Log Message:
linux_xa: Delete and replace collision in xa_store as intended.

Don't free the colliding node that's still in the tree.

Noted by rjs@.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_xa.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm

2024-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 22 15:59:12 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm: drm_gem.c

Log Message:
drm_gem.c: Enable drm_gem_fence_array_add now that we emulate xa.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/external/bsd/drm2/dist/drm/drm_gem.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm

2024-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 22 15:59:12 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm: drm_gem.c

Log Message:
drm_gem.c: Enable drm_gem_fence_array_add now that we emulate xa.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/external/bsd/drm2/dist/drm/drm_gem.c

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

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/drm_gem.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_gem.c:1.24 src/sys/external/bsd/drm2/dist/drm/drm_gem.c:1.25
--- src/sys/external/bsd/drm2/dist/drm/drm_gem.c:1.24	Wed May 22 15:47:18 2024
+++ src/sys/external/bsd/drm2/dist/drm/drm_gem.c	Wed May 22 15:59:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_gem.c,v 1.24 2024/05/22 15:47:18 riastradh Exp $	*/
+/*	$NetBSD: drm_gem.c,v 1.25 2024/05/22 15:59:12 riastradh Exp $	*/
 
 /*
  * Copyright © 2008 Intel Corporation
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_gem.c,v 1.24 2024/05/22 15:47:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_gem.c,v 1.25 2024/05/22 15:59:12 riastradh Exp $");
 
 #include 
 #include 
@@ -1477,8 +1477,6 @@ drm_gem_unlock_reservations(struct drm_g
 }
 EXPORT_SYMBOL(drm_gem_unlock_reservations);
 
-#ifndef __NetBSD__		/* XXX xarray */
-
 /**
  * drm_gem_fence_array_add - Adds the fence to an array of fences to be
  * waited on, deduplicating fences from the same context.
@@ -1571,5 +1569,3 @@ int drm_gem_fence_array_add_implicit(str
 	return ret;
 }
 EXPORT_SYMBOL(drm_gem_fence_array_add_implicit);
-
-#endif



CVS commit: src/sys/external/bsd/drm2/dist/drm

2024-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 22 15:47:18 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm: drm_gem.c

Log Message:
drm_gem.c: Fix sense of assertion.

This is the opposite of WARN_ON.

Noted by rjs@.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/external/bsd/drm2/dist/drm/drm_gem.c

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

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/drm_gem.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_gem.c:1.23 src/sys/external/bsd/drm2/dist/drm/drm_gem.c:1.24
--- src/sys/external/bsd/drm2/dist/drm/drm_gem.c:1.23	Sun Dec 19 11:58:49 2021
+++ src/sys/external/bsd/drm2/dist/drm/drm_gem.c	Wed May 22 15:47:18 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_gem.c,v 1.23 2021/12/19 11:58:49 riastradh Exp $	*/
+/*	$NetBSD: drm_gem.c,v 1.24 2024/05/22 15:47:18 riastradh Exp $	*/
 
 /*
  * Copyright © 2008 Intel Corporation
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_gem.c,v 1.23 2021/12/19 11:58:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_gem.c,v 1.24 2024/05/22 15:47:18 riastradh Exp $");
 
 #include 
 #include 
@@ -605,7 +605,7 @@ drm_gem_get_pages(struct drm_gem_object 
 	unsigned i, npages;
 	int ret;
 
-	KASSERT((obj->size & (PAGE_SIZE - 1)) != 0);
+	KASSERT((obj->size & (PAGE_SIZE - 1)) == 0);
 
 	npages = obj->size >> PAGE_SHIFT;
 	pages = kvmalloc_array(npages, sizeof(*pages), GFP_KERNEL);



CVS commit: src/sys/external/bsd/drm2/dist/drm

2024-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 22 15:47:18 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm: drm_gem.c

Log Message:
drm_gem.c: Fix sense of assertion.

This is the opposite of WARN_ON.

Noted by rjs@.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/external/bsd/drm2/dist/drm/drm_gem.c

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



CVS commit: src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 19:36:30 UTC 2024

Modified Files:
src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io:
basic_file_stdio.cc

Log Message:
libstdc++: Don't try to fflush stdin in gcc.old libstdc++ either.

PR lib/58206
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114879


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io/basic_file_stdio.cc

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

Modified files:

Index: src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io/basic_file_stdio.cc
diff -u src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io/basic_file_stdio.cc:1.13 src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io/basic_file_stdio.cc:1.14
--- src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io/basic_file_stdio.cc:1.13	Mon Feb 20 02:11:45 2023
+++ src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io/basic_file_stdio.cc	Mon May 20 19:36:30 2024
@@ -190,7 +190,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { this->close(); }
 
   __basic_file*
-  __basic_file::sys_open(__c_file* __file, ios_base::openmode)
+  __basic_file::sys_open(__c_file* __file, ios_base::openmode __mode)
   {
 __basic_file* __ret = NULL;
 if (!this->is_open() && __file)
@@ -199,7 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	// POSIX guarantees that fflush sets errno on error, but C doesn't.
 	errno = 0;
 	do
-	  __err = fflush(__file);
+	  __err = (__mode == std::ios_base::in ? 0 : fflush(__file));
 	while (__err && errno == EINTR);
 	errno = __save_errno;
 	if (!__err)



CVS commit: src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 19:36:30 UTC 2024

Modified Files:
src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io:
basic_file_stdio.cc

Log Message:
libstdc++: Don't try to fflush stdin in gcc.old libstdc++ either.

PR lib/58206
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114879


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/external/gpl3/gcc.old/dist/libstdc++-v3/config/io/basic_file_stdio.cc

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



CVS commit: src/sys

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 19:15:49 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: pci_machdep.c
src/sys/arch/sparc64/include: pci_machdep.h
src/sys/arch/xen/include: pci_machdep.h
src/sys/arch/xen/xen: xpci_xenbus.c
src/sys/dev/acpi: acpi_mcfg.c
src/sys/dev/pci: pci.c pcivar.h

Log Message:
Revert "pci: Pass cookie through pci_find_device, pci_enumerate_bus."

Evidently something is wrong with this, to be diagnosed and redone
once the builds and tests are in better shape.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/sparc64/dev/pci_machdep.c
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sparc64/include/pci_machdep.h
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/xen/include/pci_machdep.h
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/xen/xen/xpci_xenbus.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/acpi/acpi_mcfg.c
cvs rdiff -u -r1.166 -r1.167 src/sys/dev/pci/pci.c
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/pci/pcivar.h

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



CVS commit: src/sys

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 19:15:49 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: pci_machdep.c
src/sys/arch/sparc64/include: pci_machdep.h
src/sys/arch/xen/include: pci_machdep.h
src/sys/arch/xen/xen: xpci_xenbus.c
src/sys/dev/acpi: acpi_mcfg.c
src/sys/dev/pci: pci.c pcivar.h

Log Message:
Revert "pci: Pass cookie through pci_find_device, pci_enumerate_bus."

Evidently something is wrong with this, to be diagnosed and redone
once the builds and tests are in better shape.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/sparc64/dev/pci_machdep.c
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sparc64/include/pci_machdep.h
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/xen/include/pci_machdep.h
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/xen/xen/xpci_xenbus.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/acpi/acpi_mcfg.c
cvs rdiff -u -r1.166 -r1.167 src/sys/dev/pci/pci.c
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/pci/pcivar.h

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

Modified files:

Index: src/sys/arch/sparc64/dev/pci_machdep.c
diff -u src/sys/arch/sparc64/dev/pci_machdep.c:1.81 src/sys/arch/sparc64/dev/pci_machdep.c:1.82
--- src/sys/arch/sparc64/dev/pci_machdep.c:1.81	Mon May 20 11:34:18 2024
+++ src/sys/arch/sparc64/dev/pci_machdep.c	Mon May 20 19:15:48 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.81 2024/05/20 11:34:18 riastradh Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.82 2024/05/20 19:15:48 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.81 2024/05/20 11:34:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.82 2024/05/20 19:15:48 riastradh Exp $");
 
 #include 
 #include 
@@ -244,9 +244,8 @@ pci_decompose_tag(pci_chipset_tag_t pc, 
 }
 
 int
-sparc64_pci_enumerate_bus1(struct pci_softc *sc, const int *locators,
-int (*match)(void *, const struct pci_attach_args *), void *cookie,
-struct pci_attach_args *pap)
+sparc64_pci_enumerate_bus(struct pci_softc *sc, const int *locators,
+int (*match)(const struct pci_attach_args *), struct pci_attach_args *pap)
 {
 	struct ofw_pci_register reg;
 	pci_chipset_tag_t pc = sc->sc_pc;
@@ -308,10 +307,8 @@ sparc64_pci_enumerate_bus1(struct pci_so
 		if (OF_getprop(node, "class-code", , sizeof(class)) != 
 		sizeof(class))
 			continue;
-		if (OF_getprop(node, "reg", , sizeof(reg)) < sizeof(reg)) {
-			panic("pci_enumerate_bus1: \"%s\" regs too small",
-			name);
-		}
+		if (OF_getprop(node, "reg", , sizeof(reg)) < sizeof(reg))
+			panic("pci_enumerate_bus: \"%s\" regs too small", name);
 
 		b = OFW_PCI_PHYS_HI_BUS(reg.phys_hi);
 		d = OFW_PCI_PHYS_HI_DEVICE(reg.phys_hi);
@@ -364,7 +361,7 @@ sparc64_pci_enumerate_bus1(struct pci_so
 			(cl << PCI_CACHELINE_SHIFT);
 		pci_conf_write(pc, tag, PCI_BHLC_REG, bhlc);
 
-		ret = pci_probe_device1(sc, tag, match, cookie, pap);
+		ret = pci_probe_device(sc, tag, match, pap);
 		if (match != NULL && ret != 0)
 			return (ret);
 	}

Index: src/sys/arch/sparc64/include/pci_machdep.h
diff -u src/sys/arch/sparc64/include/pci_machdep.h:1.29 src/sys/arch/sparc64/include/pci_machdep.h:1.30
--- src/sys/arch/sparc64/include/pci_machdep.h:1.29	Mon May 20 11:34:18 2024
+++ src/sys/arch/sparc64/include/pci_machdep.h	Mon May 20 19:15:48 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.29 2024/05/20 11:34:18 riastradh Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.30 2024/05/20 19:15:48 riastradh Exp $ */
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -95,10 +95,10 @@ int		pci_intr_map(const struct pci_attac
 		pci_intr_handle_t *);
 void		pci_intr_disestablish(pci_chipset_tag_t, void *);
 
-int		sparc64_pci_enumerate_bus1(struct pci_softc *, const int *,
-		int (*)(void *, const struct pci_attach_args *), void *,
+int		sparc64_pci_enumerate_bus(struct pci_softc *, const int *,
+		int (*)(const struct pci_attach_args *),
 		struct pci_attach_args *);
-#define PCI_MACHDEP_ENUMERATE_BUS1 sparc64_pci_enumerate_bus1
+#define PCI_MACHDEP_ENUMERATE_BUS sparc64_pci_enumerate_bus
 
 #define	pci_conf_read(pc, tag, reg) \
 		((pc)->spc_conf_read(pc, tag, reg))

Index: src/sys/arch/xen/include/pci_machdep.h
diff -u src/sys/arch/xen/include/pci_machdep.h:1.22 src/sys/arch/xen/include/pci_machdep.h:1.23
--- src/sys/arch/xen/include/pci_machdep.h:1.22	Mon May 20 11:34:18 2024
+++ src/sys/arch/xen/include/pci_machdep.h	Mon May 20 19:15:49 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.22 2024/05/20 11:34:18 riastradh Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.23 2024/05/20 19:15:49 riastradh Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -67,14 +67,20 @@ typedef intr_handle_t pci_intr_handle_t;
 #include "opt_xen.h"
 
 #if !defined(DOM0OPS) && defined(XENPV)
-int		xpci_enumerate_bus1(struct pci_softc *, const int *,

CVS commit: src/sys/modules

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 13:34:13 UTC 2024

Modified Files:
src/sys/modules: Makefile

Log Message:
sys/modules: Don't make compat_110.

Eventually we'll need this but it doesn't make sense until 11.0 is
released.


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/modules/Makefile

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

Modified files:

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.287 src/sys/modules/Makefile:1.288
--- src/sys/modules/Makefile:1.287	Sun May 19 22:25:49 2024
+++ src/sys/modules/Makefile	Mon May 20 13:34:12 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.287 2024/05/19 22:25:49 christos Exp $
+#	$NetBSD: Makefile,v 1.288 2024/05/20 13:34:12 riastradh Exp $
 
 .include 
 
@@ -12,7 +12,10 @@ SUBDIR+=	compat_43   compat_sysctl_09_43
 SUBDIR+=	compat_09   compat_10   compat_12   compat_13   compat_14
 SUBDIR+=	compat_16   compat_20   compat_30   compat_40   compat_50
 SUBDIR+=	compat_60   compat_70   compat_80   compat_90   compat_100
-SUBDIR+=	compat_110
+
+# Not until 11.0 is released and we need binary compatibility with it
+# in >11.0.
+#SUBDIR+= compat_110
 
 SUBDIR+=	compat_sysv_10 compat_sysv_14 compat_sysv_50
 



CVS commit: src/sys/modules

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 13:34:13 UTC 2024

Modified Files:
src/sys/modules: Makefile

Log Message:
sys/modules: Don't make compat_110.

Eventually we'll need this but it doesn't make sense until 11.0 is
released.


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/modules/Makefile

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



Re: CVS commit: src/usr.bin/make

2024-05-20 Thread Taylor R Campbell
> Module Name:src
> Committed By:   sjg
> Date:   Sun May 19 20:09:40 UTC 2024
> 
> Modified Files:
> src/usr.bin/make: dir.c dir.h parse.c
> 
> Log Message:
> make: use separate function to include makefiles.
> 
> Have Dir_FindFile and Dir_FindInclude call FindFile with a
> bool flag to indicate whether .CURDIR should be be searched at all.

This appears to have broken all of the builds:

https://releng.netbsd.org/builds/HEAD/202405200920Z/
https://releng.netbsd.org/b5reports/i386/commits-2024.05.html#2024.05.19.20.09.40
https://releng.netbsd.org/b5reports/i386/2024/2024.05.19.20.09.40/build.log.tail

--- cleandir-libterminfo ---
nbmake[5]: "/tmp/build/2024.05.19.20.09.40-i386/src/lib/libterminfo/Makefile" 
line 50: Could not find Makefile.hash

Can you please back this out promptly, add automatic tests for
whatever the underlying issue is, and redo it another way?


CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:36:21 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci(4): Narrow some more variable scopes in xhci_device_isoc_enter.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/dev/usb/xhci.c

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

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.183 src/sys/dev/usb/xhci.c:1.184
--- src/sys/dev/usb/xhci.c:1.183	Mon May 20 11:35:54 2024
+++ src/sys/dev/usb/xhci.c	Mon May 20 11:36:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.183 2024/05/20 11:35:54 riastradh Exp $	*/
+/*	$NetBSD: xhci.c,v 1.184 2024/05/20 11:36:20 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.183 2024/05/20 11:35:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.184 2024/05/20 11:36:20 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -4560,14 +4560,12 @@ xhci_device_isoc_enter(struct usbd_xfer 
 	uint64_t parameter;
 	uint32_t status;
 	uint32_t control;
-	uint32_t mfindex;
 	uint32_t offs;
 	int i, ival;
 	const bool polling = xhci_polling_p(sc);
 	const uint16_t MPS = UGETW(xfer->ux_pipe->up_endpoint->ue_edesc->wMaxPacketSize);
 	const uint16_t mps = UE_GET_SIZE(MPS);
 	const uint8_t maxb = xpipe->xp_maxb;
-	u_int tdpc, tbc, tlbpc;
 
 	XHCIHIST_FUNC();
 	XHCIHIST_CALLARGS("%#jx slot %ju dci %ju",
@@ -4593,7 +4591,8 @@ xhci_device_isoc_enter(struct usbd_xfer 
 		ival = 1; /* fake something up */
 
 	if (xpipe->xp_isoc_next == -1) {
-		mfindex = xhci_rt_read_4(sc, XHCI_MFINDEX);
+		uint32_t mfindex = xhci_rt_read_4(sc, XHCI_MFINDEX);
+
 		DPRINTF("mfindex %jx", (uintmax_t)mfindex, 0, 0, 0);
 		mfindex = XHCI_MFINDEX_GET(mfindex + 1);
 		mfindex /= USB_UFRAMES_PER_FRAME;
@@ -4604,11 +4603,10 @@ xhci_device_isoc_enter(struct usbd_xfer 
 	offs = 0;
 	for (i = 0; i < xfer->ux_nframes; i++) {
 		const uint32_t len = xfer->ux_frlengths[i];
-
-		tdpc = howmany(len, mps);
-		tbc = howmany(tdpc, maxb) - 1;
-		tlbpc = tdpc % maxb;
-		tlbpc = tlbpc ? tlbpc - 1 : maxb - 1;
+		const unsigned tdpc = howmany(len, mps);
+		const unsigned tbc = howmany(tdpc, maxb) - 1;
+		const unsigned tlbpc1 = tdpc % maxb;
+		const unsigned tlbpc = tlbpc1 ? tlbpc1 - 1 : maxb - 1;
 
 		KASSERTMSG(len <= 0x1, "len %d", len);
 		parameter = DMAADDR(dma, offs);



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:36:21 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci(4): Narrow some more variable scopes in xhci_device_isoc_enter.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/dev/usb/xhci.c

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



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:35:55 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci(4): Narrow scope of variable.

Nix spurious initialization in wider scope.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/dev/usb/xhci.c

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

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.182 src/sys/dev/usb/xhci.c:1.183
--- src/sys/dev/usb/xhci.c:1.182	Mon May 20 11:35:36 2024
+++ src/sys/dev/usb/xhci.c	Mon May 20 11:35:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.182 2024/05/20 11:35:36 riastradh Exp $	*/
+/*	$NetBSD: xhci.c,v 1.183 2024/05/20 11:35:54 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.182 2024/05/20 11:35:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.183 2024/05/20 11:35:54 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -4556,7 +4556,6 @@ xhci_device_isoc_enter(struct usbd_xfer 
 	struct xhci_ring * const tr = xs->xs_xr[dci];
 	struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer);
 	struct xhci_pipe * const xpipe = (struct xhci_pipe *)xfer->ux_pipe;
-	uint32_t len = xfer->ux_length;
 	usb_dma_t * const dma = >ux_dmabuf;
 	uint64_t parameter;
 	uint32_t status;
@@ -4604,7 +4603,7 @@ xhci_device_isoc_enter(struct usbd_xfer 
 
 	offs = 0;
 	for (i = 0; i < xfer->ux_nframes; i++) {
-		len = xfer->ux_frlengths[i];
+		const uint32_t len = xfer->ux_frlengths[i];
 
 		tdpc = howmany(len, mps);
 		tbc = howmany(tdpc, maxb) - 1;



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:35:55 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci(4): Narrow scope of variable.

Nix spurious initialization in wider scope.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/dev/usb/xhci.c

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



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:35:37 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci.c: Fix confusing line break.

No functionanl change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/sys/dev/usb/xhci.c

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



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:35:37 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci.c: Fix confusing line break.

No functionanl change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/sys/dev/usb/xhci.c

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

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.181 src/sys/dev/usb/xhci.c:1.182
--- src/sys/dev/usb/xhci.c:1.181	Fri Apr  5 18:57:10 2024
+++ src/sys/dev/usb/xhci.c	Mon May 20 11:35:36 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.181 2024/04/05 18:57:10 riastradh Exp $	*/
+/*	$NetBSD: xhci.c,v 1.182 2024/05/20 11:35:36 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.181 2024/04/05 18:57:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.182 2024/05/20 11:35:36 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2496,8 +2496,7 @@ xhci_event_transfer(struct xhci_softc * 
 			xfer->ux_frlengths[xx->xx_isoc_done] -=
 			XHCI_TRB_2_REM_GET(trb_2);
 			xfer->ux_actlen += xfer->ux_frlengths[xx->xx_isoc_done];
-		} else
-		if ((trb_3 & XHCI_TRB_3_ED_BIT) == 0) {
+		} else if ((trb_3 & XHCI_TRB_3_ED_BIT) == 0) {
 			if (xfer->ux_actlen == 0)
 xfer->ux_actlen = xfer->ux_length -
 XHCI_TRB_2_REM_GET(trb_2);



CVS commit: src/sys/external/bsd/drm2/linux

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:35:11 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/linux: linux_dma_buf.c

Log Message:
drm: Fix missing bounds checks in dma buf mmap.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/external/bsd/drm2/linux/linux_dma_buf.c

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

Modified files:

Index: src/sys/external/bsd/drm2/linux/linux_dma_buf.c
diff -u src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.16 src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.17
--- src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.16	Tue Feb 21 11:40:13 2023
+++ src/sys/external/bsd/drm2/linux/linux_dma_buf.c	Mon May 20 11:35:10 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_dma_buf.c,v 1.16 2023/02/21 11:40:13 riastradh Exp $	*/
+/*	$NetBSD: linux_dma_buf.c,v 1.17 2024/05/20 11:35:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.16 2023/02/21 11:40:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.17 2024/05/20 11:35:10 riastradh Exp $");
 
 #include 
 #include 
@@ -285,7 +285,7 @@ dmabuf_fop_mmap(struct file *file, off_t
 {
 	struct dma_buf *dmabuf = file->f_data;
 
-	if (size > dmabuf->size)
+	if (size > dmabuf->size || *offp < 0 || *offp > dmabuf->size - size)
 		return EINVAL;
 
 	return dmabuf->ops->mmap(dmabuf, offp, size, prot, flagsp, advicep,



CVS commit: src/sys/external/bsd/drm2/linux

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:35:11 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/linux: linux_dma_buf.c

Log Message:
drm: Fix missing bounds checks in dma buf mmap.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/external/bsd/drm2/linux/linux_dma_buf.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:34:45 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_dmabuf.c

Log Message:
i915: Fix dmabuf mmap object.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c

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

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c:1.6 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c:1.6	Sun Dec 19 11:33:30 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c	Mon May 20 11:34:45 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_dmabuf.c,v 1.6 2021/12/19 11:33:30 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_dmabuf.c,v 1.7 2024/05/20 11:34:45 riastradh Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_dmabuf.c,v 1.6 2021/12/19 11:33:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_dmabuf.c,v 1.7 2024/05/20 11:34:45 riastradh Exp $");
 
 #include 
 #include 
@@ -126,10 +126,9 @@ static int i915_gem_dmabuf_mmap(struct d
 		return -EINVAL;
 	if (!obj->base.filp)
 		return -ENODEV;
-	/* XXX review mmap refcount */
-	drm_gem_object_get(>base);
+	uao_reference(obj->base.filp);
 	*advicep = UVM_ADV_RANDOM;
-	*uobjp = >base.gemo_uvmobj;
+	*uobjp = obj->base.filp;
 	*maxprotp = prot;
 #else
 	if (obj->base.size < vma->vm_end - vma->vm_start)



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:34:45 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_dmabuf.c

Log Message:
i915: Fix dmabuf mmap object.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c

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



CVS commit: src/sys

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:34:19 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: pci_machdep.c
src/sys/arch/sparc64/include: pci_machdep.h
src/sys/arch/xen/include: pci_machdep.h
src/sys/arch/xen/xen: xpci_xenbus.c
src/sys/dev/acpi: acpi_mcfg.c
src/sys/dev/pci: pci.c pcivar.h

Log Message:
pci: Pass cookie through pci_find_device, pci_enumerate_bus.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument.  Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument.  But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/sparc64/dev/pci_machdep.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sparc64/include/pci_machdep.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/xen/include/pci_machdep.h
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/xen/xen/xpci_xenbus.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/acpi/acpi_mcfg.c
cvs rdiff -u -r1.165 -r1.166 src/sys/dev/pci/pci.c
cvs rdiff -u -r1.117 -r1.118 src/sys/dev/pci/pcivar.h

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

Modified files:

Index: src/sys/arch/sparc64/dev/pci_machdep.c
diff -u src/sys/arch/sparc64/dev/pci_machdep.c:1.80 src/sys/arch/sparc64/dev/pci_machdep.c:1.81
--- src/sys/arch/sparc64/dev/pci_machdep.c:1.80	Wed Dec 20 05:33:58 2023
+++ src/sys/arch/sparc64/dev/pci_machdep.c	Mon May 20 11:34:18 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.80 2023/12/20 05:33:58 thorpej Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.81 2024/05/20 11:34:18 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.80 2023/12/20 05:33:58 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.81 2024/05/20 11:34:18 riastradh Exp $");
 
 #include 
 #include 
@@ -244,8 +244,9 @@ pci_decompose_tag(pci_chipset_tag_t pc, 
 }
 
 int
-sparc64_pci_enumerate_bus(struct pci_softc *sc, const int *locators,
-int (*match)(const struct pci_attach_args *), struct pci_attach_args *pap)
+sparc64_pci_enumerate_bus1(struct pci_softc *sc, const int *locators,
+int (*match)(void *, const struct pci_attach_args *), void *cookie,
+struct pci_attach_args *pap)
 {
 	struct ofw_pci_register reg;
 	pci_chipset_tag_t pc = sc->sc_pc;
@@ -307,8 +308,10 @@ sparc64_pci_enumerate_bus(struct pci_sof
 		if (OF_getprop(node, "class-code", , sizeof(class)) != 
 		sizeof(class))
 			continue;
-		if (OF_getprop(node, "reg", , sizeof(reg)) < sizeof(reg))
-			panic("pci_enumerate_bus: \"%s\" regs too small", name);
+		if (OF_getprop(node, "reg", , sizeof(reg)) < sizeof(reg)) {
+			panic("pci_enumerate_bus1: \"%s\" regs too small",
+			name);
+		}
 
 		b = OFW_PCI_PHYS_HI_BUS(reg.phys_hi);
 		d = OFW_PCI_PHYS_HI_DEVICE(reg.phys_hi);
@@ -361,7 +364,7 @@ sparc64_pci_enumerate_bus(struct pci_sof
 			(cl << PCI_CACHELINE_SHIFT);
 		pci_conf_write(pc, tag, PCI_BHLC_REG, bhlc);
 
-		ret = pci_probe_device(sc, tag, match, pap);
+		ret = pci_probe_device1(sc, tag, match, cookie, pap);
 		if (match != NULL && ret != 0)
 			return (ret);
 	}

Index: src/sys/arch/sparc64/include/pci_machdep.h
diff -u src/sys/arch/sparc64/include/pci_machdep.h:1.28 src/sys/arch/sparc64/include/pci_machdep.h:1.29
--- src/sys/arch/sparc64/include/pci_machdep.h:1.28	Thu Jul  7 06:55:38 2016
+++ src/sys/arch/sparc64/include/pci_machdep.h	Mon May 20 11:34:18 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.28 2016/07/07 06:55:38 msaitoh Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.29 2024/05/20 11:34:18 riastradh Exp $ */
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -95,10 +95,10 @@ int		pci_intr_map(const struct pci_attac
 		pci_intr_handle_t *);
 void		pci_intr_disestablish(pci_chipset_tag_t, void *);
 
-int		sparc64_pci_enumerate_bus(struct pci_softc *, const int *,
-		int (*)(const struct pci_attach_args *),
+int		sparc64_pci_enumerate_bus1(struct pci_softc *, const int *,
+		int (*)(void *, const struct pci_attach_args *), void *,
 		struct pci_attach_args *);
-#define PCI_MACHDEP_ENUMERATE_BUS sparc64_pci_enumerate_bus
+#define PCI_MACHDEP_ENUMERATE_BUS1 sparc64_pci_enumerate_bus1
 
 #define	pci_conf_read(pc, tag, reg) \
 		((pc)->spc_conf_read(pc, tag, reg))

Index: src/sys/arch/xen/include/pci_machdep.h
diff -u src/sys/arch/xen/include/pci_machdep.h:1.21 src/sys/arch/xen/include/pci_machdep.h:1.22
--- src/sys/arch/xen/include/pci_machdep.h:1.21	Mon May 23 15:03:05 2022
+++ src/sys/arch/xen/include/pci_machdep.h	Mon May 20 11:34:18 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.21 2022/05/23 15:03:05 bouyer Exp $ */

CVS commit: src/sys

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:34:19 UTC 2024

Modified Files:
src/sys/arch/sparc64/dev: pci_machdep.c
src/sys/arch/sparc64/include: pci_machdep.h
src/sys/arch/xen/include: pci_machdep.h
src/sys/arch/xen/xen: xpci_xenbus.c
src/sys/dev/acpi: acpi_mcfg.c
src/sys/dev/pci: pci.c pcivar.h

Log Message:
pci: Pass cookie through pci_find_device, pci_enumerate_bus.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument.  Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument.  But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/sparc64/dev/pci_machdep.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sparc64/include/pci_machdep.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/xen/include/pci_machdep.h
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/xen/xen/xpci_xenbus.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/acpi/acpi_mcfg.c
cvs rdiff -u -r1.165 -r1.166 src/sys/dev/pci/pci.c
cvs rdiff -u -r1.117 -r1.118 src/sys/dev/pci/pcivar.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/gen

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:21:46 UTC 2024

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

Log Message:
t_siginfo: More volatile to prevent optimization.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 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.51 src/tests/lib/libc/gen/t_siginfo.c:1.52
--- src/tests/lib/libc/gen/t_siginfo.c:1.51	Tue May 14 16:10:54 2024
+++ src/tests/lib/libc/gen/t_siginfo.c	Mon May 20 11:21:46 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.51 2024/05/14 16:10:54 riastradh Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.52 2024/05/20 11:21:46 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -306,7 +306,7 @@ ATF_TC_HEAD(sigfpe_flt, tc)
 ATF_TC_BODY(sigfpe_flt, tc)
 {
 	struct sigaction sa;
-	double d = strtod("0", NULL);
+	volatile double d = strtod("0", NULL);
 
 	if (isQEMU())
 		atf_tc_skip("Test does not run correctly under QEMU");



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

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:21:46 UTC 2024

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

Log Message:
t_siginfo: More volatile to prevent optimization.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 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

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:20:53 UTC 2024

Modified Files:
src/external/gpl3/gcc/dist/libstdc++-v3/config/io: basic_file_stdio.cc
src/tests/lib/libstdc++: t_sync_with_stdio.sh

Log Message:
libstdc++: Don't try to fflush stdin.

It doesn't work.  It's undefined behaviour.  On NetBSD, it will fail
with EBADF, if fd 0 isn't open for write, or if fd 0 is open for
write, it will write heap garbage to fd 0.

   If stream points to an output stream or an update stream in which
   the most recent operation was not input, the fflush function causes
   any unwritten data for that stream to be delivered to the host
   environment to be written to the file; otherwise, the behavior is
   undefined.

   (ISO C11 and ISO C17, Sec. 7.21.5.2 `The fflush function')

PR lib/58206
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114879


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.13 -r1.2 \
src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libstdc++/t_sync_with_stdio.sh

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

Modified files:

Index: src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc
diff -u src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc:1.1.1.13 src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc:1.2
--- src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc:1.1.1.13	Sun Jul 30 05:21:27 2023
+++ src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc	Mon May 20 11:20:53 2024
@@ -204,7 +204,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { this->close(); }
 
   __basic_file*
-  __basic_file::sys_open(__c_file* __file, ios_base::openmode)
+  __basic_file::sys_open(__c_file* __file, ios_base::openmode __mode)
   {
 __basic_file* __ret = NULL;
 if (!this->is_open() && __file)
@@ -213,7 +213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	// POSIX guarantees that fflush sets errno on error, but C doesn't.
 	errno = 0;
 	do
-	  __err = fflush(__file);
+	  __err = (__mode == std::ios_base::in ? 0 : fflush(__file));
 	while (__err && errno == EINTR);
 	errno = __save_errno;
 	if (!__err)

Index: src/tests/lib/libstdc++/t_sync_with_stdio.sh
diff -u src/tests/lib/libstdc++/t_sync_with_stdio.sh:1.1 src/tests/lib/libstdc++/t_sync_with_stdio.sh:1.2
--- src/tests/lib/libstdc++/t_sync_with_stdio.sh:1.1	Sun Apr 28 01:21:27 2024
+++ src/tests/lib/libstdc++/t_sync_with_stdio.sh	Mon May 20 11:20:53 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: t_sync_with_stdio.sh,v 1.1 2024/04/28 01:21:27 riastradh Exp $
+#	$NetBSD: t_sync_with_stdio.sh,v 1.2 2024/05/20 11:20:53 riastradh Exp $
 #
 # Copyright (c) 2024 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -32,7 +32,6 @@ cin_nosync_head()
 cin_nosync_body()
 {
 	echo hello >in
-	atf_expect_fail "PR lib/58206: sync_with_stdio breaks reads from cin"
 	atf_check -o inline:'6\n' "$(atf_get_srcdir)"/h_cin_nosync 

CVS commit: src

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:20:53 UTC 2024

Modified Files:
src/external/gpl3/gcc/dist/libstdc++-v3/config/io: basic_file_stdio.cc
src/tests/lib/libstdc++: t_sync_with_stdio.sh

Log Message:
libstdc++: Don't try to fflush stdin.

It doesn't work.  It's undefined behaviour.  On NetBSD, it will fail
with EBADF, if fd 0 isn't open for write, or if fd 0 is open for
write, it will write heap garbage to fd 0.

   If stream points to an output stream or an update stream in which
   the most recent operation was not input, the fflush function causes
   any unwritten data for that stream to be delivered to the host
   environment to be written to the file; otherwise, the behavior is
   undefined.

   (ISO C11 and ISO C17, Sec. 7.21.5.2 `The fflush function')

PR lib/58206
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114879


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.13 -r1.2 \
src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libstdc++/t_sync_with_stdio.sh

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



CVS commit: src/sys/external/bsd/drm2

2024-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 19 17:36:08 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/include/linux: pci.h
src/sys/external/bsd/drm2/linux: linux_pci.c

Log Message:
linux: Add a few more cases to pci_get_class.

Should fix crash on boot with amdgpu now that the ACPI business is
enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/external/bsd/drm2/include/linux/pci.h
cvs rdiff -u -r1.27 -r1.28 src/sys/external/bsd/drm2/linux/linux_pci.c

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

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/pci.h
diff -u src/sys/external/bsd/drm2/include/linux/pci.h:1.57 src/sys/external/bsd/drm2/include/linux/pci.h:1.58
--- src/sys/external/bsd/drm2/include/linux/pci.h:1.57	Sat Sep 30 10:46:46 2023
+++ src/sys/external/bsd/drm2/include/linux/pci.h	Sun May 19 17:36:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci.h,v 1.57 2023/09/30 10:46:46 mrg Exp $	*/
+/*	$NetBSD: pci.h,v 1.58 2024/05/19 17:36:08 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -90,6 +90,10 @@ CTASSERT(PCI_CLASS_DISPLAY_VGA == 0x0300
 	((PCI_CLASS_DISPLAY << 8) | PCI_SUBCLASS_DISPLAY_MISC)
 CTASSERT(PCI_CLASS_DISPLAY_OTHER == 0x0380);
 
+#define	PCI_CLASS_DISPLAY_3D		\
+	((PCI_CLASS_DISPLAY << 8) | PCI_SUBCLASS_DISPLAY_3D)
+CTASSERT(PCI_CLASS_DISPLAY_3D == 0x0302);
+
 #define	PCI_CLASS_BRIDGE_ISA		\
 	((PCI_CLASS_BRIDGE << 8) | PCI_SUBCLASS_BRIDGE_ISA)
 CTASSERT(PCI_CLASS_BRIDGE_ISA == 0x0601);

Index: src/sys/external/bsd/drm2/linux/linux_pci.c
diff -u src/sys/external/bsd/drm2/linux/linux_pci.c:1.27 src/sys/external/bsd/drm2/linux/linux_pci.c:1.28
--- src/sys/external/bsd/drm2/linux/linux_pci.c:1.27	Sat Sep 30 10:46:46 2023
+++ src/sys/external/bsd/drm2/linux/linux_pci.c	Sun May 19 17:36:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_pci.c,v 1.27 2023/09/30 10:46:46 mrg Exp $	*/
+/*	$NetBSD: linux_pci.c,v 1.28 2024/05/19 17:36:08 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.27 2023/09/30 10:46:46 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.28 2024/05/19 17:36:08 riastradh Exp $");
 
 #if NACPICA > 0
 #include 
@@ -626,6 +626,42 @@ pci_kludgey_match_isa_bridge(const struc
 	return 1;
 }
 
+static int
+pci_kludgey_match_other_display(const struct pci_attach_args *pa)
+{
+
+	if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY)
+		return 0;
+	if (PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_DISPLAY_MISC)
+		return 0;
+
+	return 1;
+}
+
+static int
+pci_kludgey_match_vga_display(const struct pci_attach_args *pa)
+{
+
+	if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY)
+		return 0;
+	if (PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_DISPLAY_VGA)
+		return 0;
+
+	return 1;
+}
+
+static int
+pci_kludgey_match_3d_display(const struct pci_attach_args *pa)
+{
+
+	if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY)
+		return 0;
+	if (PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_DISPLAY_3D)
+		return 0;
+
+	return 1;
+}
+
 void
 pci_dev_put(struct pci_dev *pdev)
 {
@@ -638,20 +674,37 @@ pci_dev_put(struct pci_dev *pdev)
 	kmem_free(pdev, sizeof(*pdev));
 }
 
-struct pci_dev *		/* XXX i915 kludge */
-pci_get_class(uint32_t class_subclass_shifted __unused, struct pci_dev *from)
+struct pci_dev *		/* XXX i915/amdgpu kludge */
+pci_get_class(uint32_t class_subclass_shifted, struct pci_dev *from)
 {
 	struct pci_attach_args pa;
 
-	KASSERT(class_subclass_shifted == (PCI_CLASS_BRIDGE_ISA << 8));
-
 	if (from != NULL) {
 		pci_dev_put(from);
 		return NULL;
 	}
 
-	if (!pci_find_device(, _kludgey_match_isa_bridge))
-		return NULL;
+	switch (class_subclass_shifted) {
+	case PCI_CLASS_BRIDGE_ISA << 8:
+		if (!pci_find_device(, _kludgey_match_isa_bridge))
+			return NULL;
+		break;
+	case PCI_CLASS_DISPLAY_OTHER << 8:
+		if (!pci_find_device(, _kludgey_match_other_display))
+			return NULL;
+		break;
+	case PCI_CLASS_DISPLAY_VGA << 8:
+		if (!pci_find_device(, _kludgey_match_vga_display))
+			return NULL;
+		break;
+	case PCI_CLASS_DISPLAY_3D << 8:
+		if (!pci_find_device(, _kludgey_match_3d_display))
+			return NULL;
+		break;
+	default:
+		panic("unknown pci_get_class: %"PRIx32,
+		class_subclass_shifted);
+	}
 
 	struct pci_dev *const pdev = kmem_zalloc(sizeof(*pdev), KM_SLEEP);
 	linux_pci_dev_init(pdev, NULL, NULL, , NBPCI_KLUDGE_GET_MUMBLE);



CVS commit: src/sys/external/bsd/drm2

2024-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 19 17:36:08 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/include/linux: pci.h
src/sys/external/bsd/drm2/linux: linux_pci.c

Log Message:
linux: Add a few more cases to pci_get_class.

Should fix crash on boot with amdgpu now that the ACPI business is
enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/external/bsd/drm2/include/linux/pci.h
cvs rdiff -u -r1.27 -r1.28 src/sys/external/bsd/drm2/linux/linux_pci.c

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



CVS commit: src/sys/external/bsd/drm2/ttm

2024-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 19 13:50:05 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/ttm: ttm_bo_vm.c

Log Message:
ttm: Undo mistake in previous.

PR xsrc/58133


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c

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



CVS commit: src/sys/external/bsd/drm2/ttm

2024-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 19 13:50:05 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/ttm: ttm_bo_vm.c

Log Message:
ttm: Undo mistake in previous.

PR xsrc/58133


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c

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

Modified files:

Index: src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c
diff -u src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c:1.23 src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c:1.24
--- src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c:1.23	Sun May 19 13:28:28 2024
+++ src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c	Sun May 19 13:50:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ttm_bo_vm.c,v 1.23 2024/05/19 13:28:28 riastradh Exp $	*/
+/*	$NetBSD: ttm_bo_vm.c,v 1.24 2024/05/19 13:50:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ttm_bo_vm.c,v 1.23 2024/05/19 13:28:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttm_bo_vm.c,v 1.24 2024/05/19 13:50:04 riastradh Exp $");
 
 #include 
 
@@ -44,6 +44,8 @@ __KERNEL_RCSID(0, "$NetBSD: ttm_bo_vm.c,
 
 #include 
 
+static int	ttm_bo_uvm_fault_idle(struct ttm_buffer_object *,
+		struct uvm_faultinfo *);
 static int	ttm_bo_uvm_lookup(struct ttm_bo_device *, unsigned long,
 		unsigned long, struct ttm_buffer_object **);
 



CVS commit: src/sys/external/bsd/drm2/ttm

2024-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 19 13:28:28 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/ttm: ttm_bo_vm.c

Log Message:
ttm: Sync ttm_bo_uvm_fault_idle better with Linux.

PR xsrc/58133


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c

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

Modified files:

Index: src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c
diff -u src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c:1.22 src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c:1.23
--- src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c:1.22	Thu Jul 21 08:07:56 2022
+++ src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c	Sun May 19 13:28:28 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ttm_bo_vm.c,v 1.22 2022/07/21 08:07:56 riastradh Exp $	*/
+/*	$NetBSD: ttm_bo_vm.c,v 1.23 2024/05/19 13:28:28 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ttm_bo_vm.c,v 1.22 2022/07/21 08:07:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttm_bo_vm.c,v 1.23 2024/05/19 13:28:28 riastradh Exp $");
 
 #include 
 
@@ -44,8 +44,6 @@ __KERNEL_RCSID(0, "$NetBSD: ttm_bo_vm.c,
 
 #include 
 
-static int	ttm_bo_uvm_fault_idle(struct ttm_buffer_object *,
-		struct uvm_faultinfo *);
 static int	ttm_bo_uvm_lookup(struct ttm_bo_device *, unsigned long,
 		unsigned long, struct ttm_buffer_object **);
 
@@ -134,10 +132,7 @@ ttm_bo_uvm_fault(struct uvm_faultinfo *u
 	ret = ttm_bo_uvm_fault_idle(bo, ufi);
 	if (ret) {
 		KASSERT(ret == -ERESTART || ret == -EFAULT);
-		/* ttm_bo_uvm_fault_idle calls uvmfault_unlockall for us.  */
-		ttm_bo_unreserve(bo);
-		/* XXX errno Linux->NetBSD */
-		return -ret;
+		goto out1;
 	}
 
 	ret = ttm_mem_io_lock(man, true);
@@ -221,24 +216,49 @@ out0:	uvmfault_unlockall(ufi, ufi->entry
 static int
 ttm_bo_uvm_fault_idle(struct ttm_buffer_object *bo, struct uvm_faultinfo *ufi)
 {
-	int ret = 0;
+	int err, ret = 0;
 
 	if (__predict_true(!bo->moving))
-		goto out0;
+		goto out_unlock;
 
+	/*
+	 * Quick non-stalling check for idle.
+	 */
 	if (dma_fence_is_signaled(bo->moving))
-		goto out1;
+		goto out_clear;
 
-	if (dma_fence_wait(bo->moving, true) != 0) {
-		ret = -EFAULT;
-		goto out2;
+	/*
+	 * If possible, avoid waiting for GPU with mmap_sem
+	 * held.
+	 * XXX Need to integrate this properly into caller's
+	 * error branches so it doesn't uvmfault_unlockall twice.
+	 */
+	if (0) {
+		ret = -ERESTART;
+
+		ttm_bo_get(bo);
+		uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, NULL);
+		(void) dma_fence_wait(bo->moving, true);
+		dma_resv_unlock(bo->base.resv);
+		ttm_bo_put(bo);
+		goto out_unlock;
+	}
+
+	/*
+	 * Ordinary wait.
+	 */
+	err = dma_fence_wait(bo->moving, true);
+	if (__predict_false(ret != 0)) {
+		ret = (err != -ERESTARTSYS) ? -EFAULT : -ERESTART;
+		goto out_unlock;
 	}
 
-	ret = -ERESTART;
-out2:	uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, NULL);
-out1:	dma_fence_put(bo->moving);
+out_clear:
+	dma_fence_put(bo->moving);
 	bo->moving = NULL;
-out0:	return ret;
+
+out_unlock:
+	return ret;
 }
 
 int



CVS commit: src/sys/external/bsd/drm2/ttm

2024-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 19 13:28:28 UTC 2024

Modified Files:
src/sys/external/bsd/drm2/ttm: ttm_bo_vm.c

Log Message:
ttm: Sync ttm_bo_uvm_fault_idle better with Linux.

PR xsrc/58133


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/external/bsd/drm2/ttm/ttm_bo_vm.c

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



CVS commit: src/lib/libm/arch/riscv

2024-05-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 17 02:11:07 UTC 2024

Modified Files:
src/lib/libm/arch/riscv: fenv.c

Log Message:
riscv: Make feraiseexcept actually raise the given exceptions.

Doing

fexcept_t ex = 0;
fesetexceptflag(, excepts);

has the effect of _clearing_ all the exceptions in excepts.  Using
fesetexceptflag doesn't make this easier, because we would have to
record which exceptions were already raised.  So just set the fflags
bits in the fcsr register directly.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libm/arch/riscv/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/lib/libm/arch/riscv/fenv.c
diff -u src/lib/libm/arch/riscv/fenv.c:1.4 src/lib/libm/arch/riscv/fenv.c:1.5
--- src/lib/libm/arch/riscv/fenv.c:1.4	Sun May  7 12:41:47 2023
+++ src/lib/libm/arch/riscv/fenv.c	Fri May 17 02:11:07 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.4 2023/05/07 12:41:47 skrll Exp $ */
+/* $NetBSD: fenv.c,v 1.5 2024/05/17 02:11:07 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: fenv.c,v 1.4 2023/05/07 12:41:47 skrll Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.5 2024/05/17 02:11:07 riastradh Exp $");
 
 #include "namespace.h"
 
@@ -114,19 +114,15 @@ fegetexceptflag(fexcept_t *flagp, int ex
  * The standard explicitly allows us to execute an instruction that has the
  * exception as a side effect, but we choose to manipulate the status register
  * directly.
- *
- * The validation of input is being deferred to fesetexceptflag().
  */
 int
 feraiseexcept(int excepts)
 {
-	fexcept_t ex = 0;
 
 	_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
 
 	excepts &= FE_ALL_EXCEPT;
-	fesetexceptflag(, excepts);
-	/* XXX exception magic XXX */
+	fcsr_fflags_write(fcsr_fflags_read() | excepts);
 
 	/* Success */
 	return 0;



CVS commit: src/lib/libm/arch/riscv

2024-05-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 17 02:11:07 UTC 2024

Modified Files:
src/lib/libm/arch/riscv: fenv.c

Log Message:
riscv: Make feraiseexcept actually raise the given exceptions.

Doing

fexcept_t ex = 0;
fesetexceptflag(, excepts);

has the effect of _clearing_ all the exceptions in excepts.  Using
fesetexceptflag doesn't make this easier, because we would have to
record which exceptions were already raised.  So just set the fflags
bits in the fcsr register directly.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libm/arch/riscv/fenv.c

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



CVS commit: src/lib/libc/arch/riscv/gen

2024-05-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 16 01:02:35 UTC 2024

Modified Files:
src/lib/libc/arch/riscv/gen: fpgetsticky.c fpsetsticky.c

Log Message:
riscv: More shiftiness reduction around FCSR in libc.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/riscv/gen/fpgetsticky.c \
src/lib/libc/arch/riscv/gen/fpsetsticky.c

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



CVS commit: src/lib/libc/arch/riscv/gen

2024-05-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 16 01:02:35 UTC 2024

Modified Files:
src/lib/libc/arch/riscv/gen: fpgetsticky.c fpsetsticky.c

Log Message:
riscv: More shiftiness reduction around FCSR in libc.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/riscv/gen/fpgetsticky.c \
src/lib/libc/arch/riscv/gen/fpsetsticky.c

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

Modified files:

Index: src/lib/libc/arch/riscv/gen/fpgetsticky.c
diff -u src/lib/libc/arch/riscv/gen/fpgetsticky.c:1.3 src/lib/libc/arch/riscv/gen/fpgetsticky.c:1.4
--- src/lib/libc/arch/riscv/gen/fpgetsticky.c:1.3	Sun May  7 12:41:47 2023
+++ src/lib/libc/arch/riscv/gen/fpgetsticky.c	Thu May 16 01:02:35 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpgetsticky.c,v 1.3 2023/05/07 12:41:47 skrll Exp $	*/
+/*	$NetBSD: fpgetsticky.c,v 1.4 2024/05/16 01:02:35 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fpgetsticky.c,v 1.3 2023/05/07 12:41:47 skrll Exp $");
+__RCSID("$NetBSD: fpgetsticky.c,v 1.4 2024/05/16 01:02:35 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -47,5 +47,5 @@ __weak_alias(fpgetsticky,_fpgetsticky)
 fp_except
 fpgetsticky(void)
 {
-	return __SHIFTOUT(fcsr_read(), FCSR_FFLAGS);
+	return fcsr_fflags_read();
 }
Index: src/lib/libc/arch/riscv/gen/fpsetsticky.c
diff -u src/lib/libc/arch/riscv/gen/fpsetsticky.c:1.3 src/lib/libc/arch/riscv/gen/fpsetsticky.c:1.4
--- src/lib/libc/arch/riscv/gen/fpsetsticky.c:1.3	Sun May  7 12:41:47 2023
+++ src/lib/libc/arch/riscv/gen/fpsetsticky.c	Thu May 16 01:02:35 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpsetsticky.c,v 1.3 2023/05/07 12:41:47 skrll Exp $	*/
+/*	$NetBSD: fpsetsticky.c,v 1.4 2024/05/16 01:02:35 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fpsetsticky.c,v 1.3 2023/05/07 12:41:47 skrll Exp $");
+__RCSID("$NetBSD: fpsetsticky.c,v 1.4 2024/05/16 01:02:35 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -48,5 +48,5 @@ __weak_alias(fpsetsticky,_fpsetsticky)
 fp_except
 fpsetsticky(fp_except mask)
 {
-	return __SHIFTOUT(fcsr_fflags_write(__SHIFTIN(mask, FCSR_FFLAGS)), FCSR_FFLAGS);
+	return fcsr_fflags_write(mask);
 }



CVS commit: src/lib/libc/arch/riscv/gen

2024-05-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 16 00:56:11 UTC 2024

Modified Files:
src/lib/libc/arch/riscv/gen: fpgetround.c fpsetround.c

Log Message:
riscv: Nix shifting around FRRM and FSRM in libc too.

These read and write the floating-point rounding mode directly, not
the whole floating-point control and status register.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/riscv/gen/fpgetround.c \
src/lib/libc/arch/riscv/gen/fpsetround.c

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

Modified files:

Index: src/lib/libc/arch/riscv/gen/fpgetround.c
diff -u src/lib/libc/arch/riscv/gen/fpgetround.c:1.3 src/lib/libc/arch/riscv/gen/fpgetround.c:1.4
--- src/lib/libc/arch/riscv/gen/fpgetround.c:1.3	Sun May  7 12:41:47 2023
+++ src/lib/libc/arch/riscv/gen/fpgetround.c	Thu May 16 00:56:11 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpgetround.c,v 1.3 2023/05/07 12:41:47 skrll Exp $	*/
+/*	$NetBSD: fpgetround.c,v 1.4 2024/05/16 00:56:11 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fpgetround.c,v 1.3 2023/05/07 12:41:47 skrll Exp $");
+__RCSID("$NetBSD: fpgetround.c,v 1.4 2024/05/16 00:56:11 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -47,5 +47,5 @@ __weak_alias(fpgetround,_fpgetround)
 fp_rnd
 fpgetround(void)
 {
-	return __SHIFTOUT(fcsr_read(), FCSR_FRM);
+	return fcsr_frm_read();
 }
Index: src/lib/libc/arch/riscv/gen/fpsetround.c
diff -u src/lib/libc/arch/riscv/gen/fpsetround.c:1.3 src/lib/libc/arch/riscv/gen/fpsetround.c:1.4
--- src/lib/libc/arch/riscv/gen/fpsetround.c:1.3	Sun May  7 12:41:47 2023
+++ src/lib/libc/arch/riscv/gen/fpsetround.c	Thu May 16 00:56:11 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpsetround.c,v 1.3 2023/05/07 12:41:47 skrll Exp $	*/
+/*	$NetBSD: fpsetround.c,v 1.4 2024/05/16 00:56:11 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fpsetround.c,v 1.3 2023/05/07 12:41:47 skrll Exp $");
+__RCSID("$NetBSD: fpsetround.c,v 1.4 2024/05/16 00:56:11 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -47,5 +47,5 @@ __weak_alias(fpsetround,_fpsetround)
 fp_rnd
 fpsetround(fp_rnd rnd_dir)
 {
-	return __SHIFTOUT(fcsr_frm_write(__SHIFTIN(rnd_dir, FCSR_FRM)), FCSR_FRM);
+	return fcsr_frm_write(rnd_dir);
 }



CVS commit: src/lib/libc/arch/riscv/gen

2024-05-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 16 00:56:11 UTC 2024

Modified Files:
src/lib/libc/arch/riscv/gen: fpgetround.c fpsetround.c

Log Message:
riscv: Nix shifting around FRRM and FSRM in libc too.

These read and write the floating-point rounding mode directly, not
the whole floating-point control and status register.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/riscv/gen/fpgetround.c \
src/lib/libc/arch/riscv/gen/fpsetround.c

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



CVS commit: src/lib/libc/gen

2024-05-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 15 13:12:04 UTC 2024

Modified Files:
src/lib/libc/gen: usleep.3

Log Message:
usleep(3): Note the historical rake that was stepped upon.

PR 58184


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/gen/usleep.3

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

Modified files:

Index: src/lib/libc/gen/usleep.3
diff -u src/lib/libc/gen/usleep.3:1.21 src/lib/libc/gen/usleep.3:1.22
--- src/lib/libc/gen/usleep.3:1.21	Mon Apr 22 21:25:29 2024
+++ src/lib/libc/gen/usleep.3	Wed May 15 13:12:04 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: usleep.3,v 1.21 2024/04/22 21:25:29 jdolecek Exp $
+.\"	$NetBSD: usleep.3,v 1.22 2024/05/15 13:12:04 riastradh Exp $
 .\"
 .\" Copyright (c) 1986, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -99,3 +99,17 @@ The
 .Fn usleep
 function appeared in
 .Bx 4.3 .
+.Sh CAVEATS
+In
+.St -p1003.1-2004 ,
+.Nm
+was limited to values of
+.Fa microseconds
+less than one million.
+Some implementations, including
+.Nx
+before 10.1, fail immediately with
+.Er EINVAL
+\(em and don't sleep at all \(em if
+.Fa microseconds
+is one million or greater.



CVS commit: src/lib/libc/gen

2024-05-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 15 13:12:04 UTC 2024

Modified Files:
src/lib/libc/gen: usleep.3

Log Message:
usleep(3): Note the historical rake that was stepped upon.

PR 58184


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/gen/usleep.3

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



CVS commit: src

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 15 00:02:57 UTC 2024

Modified Files:
src/lib/libm/src: s_modfl.c
src/tests/lib/libm: t_fe_round.c t_modf.c

Log Message:
modfl(3): Fix conversion from FreeBSD.

LDBL_MANL_SIZE is spelled EXT_FRACLBITS -- and not EXT_FRACHBITS.

PR lib/58237: modfl returns wrong answers on ld128 architectures


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/src/s_modfl.c
cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libm/t_fe_round.c
cvs rdiff -u -r1.5 -r1.6 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/lib/libm/src/s_modfl.c
diff -u src/lib/libm/src/s_modfl.c:1.1 src/lib/libm/src/s_modfl.c:1.2
--- src/lib/libm/src/s_modfl.c:1.1	Mon Jun 16 12:54:43 2014
+++ src/lib/libm/src/s_modfl.c	Wed May 15 00:02:56 2024
@@ -36,7 +36,7 @@
  * $FreeBSD: head/lib/msun/src/s_modfl.c 165855 2007-01-07 07:54:21Z das $
  */
 #include 
-__RCSID("$NetBSD: s_modfl.c,v 1.1 2014/06/16 12:54:43 joerg Exp $");
+__RCSID("$NetBSD: s_modfl.c,v 1.2 2024/05/15 00:02:56 riastradh Exp $");
 
 #include "namespace.h"
 
@@ -51,7 +51,7 @@ __RCSID("$NetBSD: s_modfl.c,v 1.1 2014/0
 __weak_alias(modfl, _modfl)
 #endif
 
-#if LDBL_MANL_SIZE > 32
+#if EXT_FRACLBITS > 32
 #define	MASK	((uint64_t)-1)
 #else
 #define	MASK	((uint32_t)-1)
@@ -59,7 +59,7 @@ __weak_alias(modfl, _modfl)
 /* Return the last n bits of a word, representing the fractional part. */
 #define	GETFRAC(bits, n)	((bits) & ~(MASK << (n)))
 /* The number of fraction bits in manh, not counting the integer bit */
-#define	HIBITS	(LDBL_MANT_DIG - EXT_FRACHBITS)
+#define	HIBITS	(LDBL_MANT_DIG - EXT_FRACLBITS)
 
 static const long double zero[] = { 0.0L, -0.0L };
 

Index: src/tests/lib/libm/t_fe_round.c
diff -u src/tests/lib/libm/t_fe_round.c:1.19 src/tests/lib/libm/t_fe_round.c:1.20
--- src/tests/lib/libm/t_fe_round.c:1.19	Thu May  9 12:18:28 2024
+++ src/tests/lib/libm/t_fe_round.c	Wed May 15 00:02:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fe_round.c,v 1.19 2024/05/09 12:18:28 riastradh Exp $	*/
+/*	$NetBSD: t_fe_round.c,v 1.20 2024/05/15 00:02:57 riastradh Exp $	*/
 
 /*
  * Written by Maya Rashish 
@@ -8,7 +8,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_fe_round.c,v 1.19 2024/05/09 12:18:28 riastradh Exp $");
+__RCSID("$NetBSD: t_fe_round.c,v 1.20 2024/05/15 00:02:57 riastradh Exp $");
 
 #include 
 #include 
@@ -400,12 +400,6 @@ 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

Index: src/tests/lib/libm/t_modf.c
diff -u src/tests/lib/libm/t_modf.c:1.5 src/tests/lib/libm/t_modf.c:1.6
--- src/tests/lib/libm/t_modf.c:1.5	Wed May  8 22:57:37 2024
+++ src/tests/lib/libm/t_modf.c	Wed May 15 00:02:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_modf.c,v 1.5 2024/05/08 22:57:37 riastradh Exp $	*/
+/*	$NetBSD: t_modf.c,v 1.6 2024/05/15 00:02:57 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_modf.c,v 1.5 2024/05/08 22:57:37 riastradh Exp $");
+__RCSID("$NetBSD: t_modf.c,v 1.6 2024/05/15 00:02:57 riastradh Exp $");
 
 #include 
 #include 
@@ -289,11 +289,6 @@ 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

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 15 00:02:57 UTC 2024

Modified Files:
src/lib/libm/src: s_modfl.c
src/tests/lib/libm: t_fe_round.c t_modf.c

Log Message:
modfl(3): Fix conversion from FreeBSD.

LDBL_MANL_SIZE is spelled EXT_FRACLBITS -- and not EXT_FRACHBITS.

PR lib/58237: modfl returns wrong answers on ld128 architectures


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/src/s_modfl.c
cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libm/t_fe_round.c
cvs rdiff -u -r1.5 -r1.6 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/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/kernel

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

Modified Files:
src/tests/kernel: h_segv.c

Log Message:
tests/kernel/h_segv: Disable SIGFPE test on RISC-V.

No floating-point exception traps on RISC-V.

Also don't pass the result of divide-by-zero converted to integer to
usleep.  Although the floating-point result of divide-by-zero is
well-defined by IEEE 754 (+/-infinity), the outcome of C conversion
to integer is not.  And while on some architectures this might return
zero, on RISC-V it looks like it'll return all bits set.  And as of
PR 58184, usleep now honours sleeps longer than 1sec, which means
this will be waiting at least two billion microseconds, or about half
an hour...

So instead, just write the result to a volatile variable.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/kernel/h_segv.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/kernel/h_segv.c
diff -u src/tests/kernel/h_segv.c:1.14 src/tests/kernel/h_segv.c:1.15
--- src/tests/kernel/h_segv.c:1.14	Thu Apr 25 19:37:09 2019
+++ src/tests/kernel/h_segv.c	Tue May 14 15:54:16 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_segv.c,v 1.14 2019/04/25 19:37:09 kamil Exp $	*/
+/*	$NetBSD: h_segv.c,v 1.15 2024/05/14 15:54:16 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: h_segv.c,v 1.14 2019/04/25 19:37:09 kamil Exp $");
+__RCSID("$NetBSD: h_segv.c,v 1.15 2024/05/14 15:54:16 riastradh Exp $");
 
 #define	__TEST_FENV
 
@@ -121,10 +121,15 @@ check_fpe(void)
 		printf("FPU does not implement traps on FP exceptions\n");
 		exit(EXIT_FAILURE);
 	}
+#elif defined __riscv__
+	printf("RISC-V does not support floating-point exception traps\n");
+	exit(EXIT_FAILURE);
 #endif
 	exit(EXIT_SUCCESS);
 }
 
+volatile int ignore_result;
+
 static void
 trigger_fpe(void)
 {
@@ -135,7 +140,13 @@ trigger_fpe(void)
 	feenableexcept(FE_ALL_EXCEPT);
 #endif
 
-	usleep((int)(a/b));
+	/*
+	 * Try to trigger SIGFPE either by dividing by zero (which is
+	 * defined to raise FE_DIVBYZERO, but may just return infinity
+	 * without trapping the exception) or by converting infinity to
+	 * integer.
+	 */
+	ignore_result = (int)(a/b);
 }
 
 static void



CVS commit: src/tests/kernel

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

Modified Files:
src/tests/kernel: h_segv.c

Log Message:
tests/kernel/h_segv: Disable SIGFPE test on RISC-V.

No floating-point exception traps on RISC-V.

Also don't pass the result of divide-by-zero converted to integer to
usleep.  Although the floating-point result of divide-by-zero is
well-defined by IEEE 754 (+/-infinity), the outcome of C conversion
to integer is not.  And while on some architectures this might return
zero, on RISC-V it looks like it'll return all bits set.  And as of
PR 58184, usleep now honours sleeps longer than 1sec, which means
this will be waiting at least two billion microseconds, or about half
an hour...

So instead, just write the result to a volatile variable.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/kernel/h_segv.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.



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/sys/arch/riscv/include

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

Modified Files:
src/sys/arch/riscv/include: sysreg.h

Log Message:
riscv: No volatile needed on asm to _read_ rounding mode, exceptions.

These instructions can be omitted if the return values are unused.
In contrast, _writes_ to the rounding mode or exceptions must not be
omitted (even if we ignore the return value, which is the old value
of the field).

I think "memory" is the wrong clobber on these asm blocks too; they
can't be reordered around _floating-point_ instructions, while
reordering around loads and stores is fine.  But I don't know how to
spell the right thing in gcclish.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/riscv/include/sysreg.h

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

Modified files:

Index: src/sys/arch/riscv/include/sysreg.h
diff -u src/sys/arch/riscv/include/sysreg.h:1.32 src/sys/arch/riscv/include/sysreg.h:1.33
--- src/sys/arch/riscv/include/sysreg.h:1.32	Tue May 14 15:16:51 2024
+++ src/sys/arch/riscv/include/sysreg.h	Tue May 14 15:17:57 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: sysreg.h,v 1.32 2024/05/14 15:16:51 riastradh Exp $ */
+/* $NetBSD: sysreg.h,v 1.33 2024/05/14 15:17:57 riastradh Exp $ */
 
 /*
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@ static inline uint32_t
 fcsr_read(void)
 {
 	uint32_t __fcsr;
-	asm volatile("frcsr %0" : "=r"(__fcsr) :: "memory");
+	asm("frcsr %0" : "=r"(__fcsr) :: "memory");
 	return __fcsr;
 }
 
@@ -73,7 +73,7 @@ static inline uint32_t
 fcsr_fflags_read(void)
 {
 	uint32_t __old;
-	asm volatile("frflags %0" : "=r"(__old) :: "memory");
+	asm("frflags %0" : "=r"(__old) :: "memory");
 	return __old;
 }
 
@@ -89,7 +89,7 @@ static inline uint32_t
 fcsr_frm_read(void)
 {
 	uint32_t __old;
-	asm volatile("frrm\t%0" : "=r"(__old) :: "memory");
+	asm("frrm\t%0" : "=r"(__old) :: "memory");
 	return __old;
 }
 



CVS commit: src/sys/arch/riscv/include

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

Modified Files:
src/sys/arch/riscv/include: sysreg.h

Log Message:
riscv: No volatile needed on asm to _read_ rounding mode, exceptions.

These instructions can be omitted if the return values are unused.
In contrast, _writes_ to the rounding mode or exceptions must not be
omitted (even if we ignore the return value, which is the old value
of the field).

I think "memory" is the wrong clobber on these asm blocks too; they
can't be reordered around _floating-point_ instructions, while
reordering around loads and stores is fine.  But I don't know how to
spell the right thing in gcclish.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/riscv/include/sysreg.h

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



CVS commit: src/sys/arch/riscv/include

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

Modified Files:
src/sys/arch/riscv/include: sysreg.h

Log Message:
riscv: Fix reading and writing frm and fflags.

The FRRM/FSRM and FRFLAGS/FSFLAGS instructions do all the masking and
shifting needed -- __SHIFTIN/__SHIFTOUT is wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/riscv/include/sysreg.h

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

Modified files:

Index: src/sys/arch/riscv/include/sysreg.h
diff -u src/sys/arch/riscv/include/sysreg.h:1.31 src/sys/arch/riscv/include/sysreg.h:1.32
--- src/sys/arch/riscv/include/sysreg.h:1.31	Mon Feb  5 21:46:05 2024
+++ src/sys/arch/riscv/include/sysreg.h	Tue May 14 15:16:51 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: sysreg.h,v 1.31 2024/02/05 21:46:05 andvar Exp $ */
+/* $NetBSD: sysreg.h,v 1.32 2024/05/14 15:16:51 riastradh Exp $ */
 
 /*
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -61,7 +61,6 @@ fcsr_read(void)
 	return __fcsr;
 }
 
-
 static inline uint32_t
 fcsr_write(uint32_t __new)
 {
@@ -75,16 +74,15 @@ fcsr_fflags_read(void)
 {
 	uint32_t __old;
 	asm volatile("frflags %0" : "=r"(__old) :: "memory");
-	return __SHIFTOUT(__old, FCSR_FFLAGS);
+	return __old;
 }
 
 static inline uint32_t
 fcsr_fflags_write(uint32_t __new)
 {
 	uint32_t __old;
-	__new = __SHIFTIN(__new, FCSR_FFLAGS);
 	asm volatile("fsflags %0, %1" : "=r"(__old) : "r"(__new) : "memory");
-	return __SHIFTOUT(__old, FCSR_FFLAGS);
+	return __old;
 }
 
 static inline uint32_t
@@ -92,19 +90,17 @@ fcsr_frm_read(void)
 {
 	uint32_t __old;
 	asm volatile("frrm\t%0" : "=r"(__old) :: "memory");
-	return __SHIFTOUT(__old, FCSR_FRM);
+	return __old;
 }
 
 static inline uint32_t
 fcsr_frm_write(uint32_t __new)
 {
 	uint32_t __old;
-	__new = __SHIFTIN(__new, FCSR_FRM);
 	asm volatile("fsrm\t%0, %1" : "=r"(__old) : "r"(__new) : "memory");
-	return __SHIFTOUT(__old, FCSR_FRM);
+	return __old;
 }
 
-
 #define	RISCVREG_READ_INLINE(regname)	\
 static inline uintptr_t			\
 csr_##regname##_read(void)		\



CVS commit: src/sys/arch/riscv/include

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

Modified Files:
src/sys/arch/riscv/include: sysreg.h

Log Message:
riscv: Fix reading and writing frm and fflags.

The FRRM/FSRM and FRFLAGS/FSFLAGS instructions do all the masking and
shifting needed -- __SHIFTIN/__SHIFTOUT is wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/riscv/include/sysreg.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

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/lib/libm

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

Modified Files:
src/lib/libm: Makefile
Added Files:
src/lib/libm: m.powerpc64.expsym

Log Message:
libm: Fix powerpc64 build.

- Include fenv.c and fma(3) symbols (which just use the FMADD
  instruction).
- Note the .FN symbols in libm for the asm functions.  The FN symbols
  point at the function _descriptors_; the .FN symbols point at the
  first instruction of the function.

XXX Unclear why we have the .FN symbols for asm functions but not for
C functions.  I'm not sure we should be exporting them.


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/lib/libm/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libm/m.powerpc64.expsym

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

Modified files:

Index: src/lib/libm/Makefile
diff -u src/lib/libm/Makefile:1.234 src/lib/libm/Makefile:1.235
--- src/lib/libm/Makefile:1.234	Thu May  9 14:42:09 2024
+++ src/lib/libm/Makefile	Tue May 14 14:34:35 2024
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.234 2024/05/09 14:42:09 riastradh Exp $
+#  $NetBSD: Makefile,v 1.235 2024/05/14 14:34:35 riastradh Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -194,7 +194,7 @@ ARCH_SRCS += s_fmax.S s_fmaxf.S
 ARCH_SRCS += s_fmin.S s_fminf.S
 .endif
 
-.elif (${LIBC_MACHINE_ARCH} == "powerpc")
+.elif (${LIBC_MACHINE_CPU} == "powerpc")
 .PATH:	${.CURDIR}/arch/powerpc
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c

Added files:

Index: src/lib/libm/m.powerpc64.expsym
diff -u /dev/null src/lib/libm/m.powerpc64.expsym:1.1
--- /dev/null	Tue May 14 14:34:35 2024
+++ src/lib/libm/m.powerpc64.expsym	Tue May 14 14:34:35 2024
@@ -0,0 +1,479 @@
+._fini
+._init
+.fma
+.fmaf
+__c99_cabs
+__c99_cabsf
+__c99_cabsl
+__divdc3
+__divsc3
+__divtc3
+__exp__D
+__fe_dfl_env
+__ieee754_acos
+__ieee754_acosf
+__ieee754_acosh
+__ieee754_acoshf
+__ieee754_asin
+__ieee754_asinf
+__ieee754_atan2
+__ieee754_atan2f
+__ieee754_atanh
+__ieee754_atanhf
+__ieee754_cosh
+__ieee754_coshf
+__ieee754_exp
+__ieee754_expf
+__ieee754_fmod
+__ieee754_fmodf
+__ieee754_fmodl
+__ieee754_hypot
+__ieee754_hypotf
+__ieee754_j0
+__ieee754_j0f
+__ieee754_j1
+__ieee754_j1f
+__ieee754_jn
+__ieee754_jnf
+__ieee754_lgamma_r
+__ieee754_lgammaf_r
+__ieee754_log
+__ieee754_log10
+__ieee754_log10f
+__ieee754_log2
+__ieee754_log2f
+__ieee754_logf
+__ieee754_pow
+__ieee754_powf
+__ieee754_rem_pio2
+__ieee754_rem_pio2f
+__ieee754_remainder
+__ieee754_remainderf
+__ieee754_scalb
+__ieee754_scalbf
+__ieee754_sinh
+__ieee754_sinhf
+__ieee754_sqrt
+__ieee754_sqrtf
+__ieee754_y0
+__ieee754_y0f
+__ieee754_y1
+__ieee754_y1f
+__ieee754_yn
+__ieee754_ynf
+__kernel_cos
+__kernel_cosf
+__kernel_rem_pio2
+__kernel_rem_pio2f
+__kernel_sin
+__kernel_sinf
+__kernel_standard
+__kernel_tan
+__kernel_tanf
+__log__D
+__muldc3
+__mulsc3
+__multc3
+_acoshl
+_acosl
+_asin
+_asinf
+_asinhl
+_asinl
+_atan2
+_atan2f
+_atan2l
+_atanhl
+_atanl
+_casin
+_casinf
+_casinl
+_catan
+_catanf
+_catanl
+_cbrtl
+_cchsh
+_cchshf
+_cchshl
+_ceill
+_copysignl
+_cos
+_cosf
+_cosh
+_coshf
+_coshl
+_cosl
+_cospi
+_cospif
+_cospil
+_ctans
+_ctansf
+_ctansl
+_end
+_erfcl
+_erfl
+_exp
+_exp2l
+_expf
+_expl
+_expm1l
+_fdlib_version
+_feclearexcept
+_fedisableexcept
+_feenableexcept
+_fegetenv
+_fegetexcept
+_fegetexceptflag
+_fegetround
+_feholdexcept
+_feraiseexcept
+_fesetenv
+_fesetexceptflag
+_fesetround
+_fetestexcept
+_feupdateenv
+_fini
+_finite
+_finitef
+_floorl
+_fmodl
+_hypot
+_hypotf
+_hypotl
+_init
+_lgammal
+_lgammal_r
+_log
+_log10l
+_log1pl
+_log2l
+_logf
+_logl
+_modfl
+_powl
+_redupi
+_redupif
+_redupil
+_remquo
+_remquof
+_remquol
+_roundl
+_scalbln
+_scalblnf
+_scalblnl
+_scalbn
+_scalbnf
+_scalbnl
+_sin
+_sincos
+_sincosf
+_sincosl
+_sinf
+_sinh
+_sinhf
+_sinhl
+_sinl
+_sinpi
+_sinpif
+_sinpil
+_sqrtl
+_tan
+_tanf
+_tanhl
+_tanl
+_tanpi
+_tanpif
+_tanpil
+_tgammal
+_truncl
+acos
+acosf
+acosh
+acoshf
+acoshl
+acosl
+asin
+asinf
+asinh
+asinhf
+asinhl
+asinl
+atan
+atan2
+atan2f
+atan2l
+atanf
+atanh
+atanhf
+atanhl
+atanl
+cabs
+cabsf
+cacos
+cacosf
+cacosh
+cacoshf
+cacoshl
+cacosl
+carg
+cargf
+cargl
+casin
+casinf
+casinh
+casinhf
+casinhl
+casinl
+catan
+catanf
+catanh
+catanhf
+catanhl
+catanl
+cbrt
+cbrtf
+cbrtl
+ccos
+ccosf
+ccosh
+ccoshf
+ccoshl
+ccosl
+ceil
+ceilf
+ceill
+cexp
+cexpf
+cexpl
+cimag
+cimagf
+cimagl
+clog
+clogf
+clogl
+conj
+conjf
+conjl
+copysign
+copysignf
+copysignl
+cos
+cosf
+cosh
+coshf
+coshl
+cosl
+cospi
+cospif
+cospil
+cpow
+cpowf
+cpowl
+cproj
+cprojf
+cprojl
+creal
+crealf
+creall
+csin
+csinf
+csinh
+csinhf
+csinhl
+csinl
+csqrt
+csqrtf
+csqrtl
+ctan
+ctanf
+ctanh
+ctanhf
+ctanhl
+ctanl
+drem
+dremf
+erf
+erfc
+erfcf
+erfcl
+erff
+erfl
+exp
+exp2
+exp2f
+exp2l
+expf
+expl
+expm1
+expm1f
+expm1l
+fabsf
+fdim
+fdimf
+fdiml
+feclearexcept
+fedisableexcept
+feenableexcept
+fegetenv
+fegetexcept
+fegetexceptflag
+fegetround
+feholdexcept
+feraiseexcept

CVS commit: src/lib/libm

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

Modified Files:
src/lib/libm: Makefile
Added Files:
src/lib/libm: m.powerpc64.expsym

Log Message:
libm: Fix powerpc64 build.

- Include fenv.c and fma(3) symbols (which just use the FMADD
  instruction).
- Note the .FN symbols in libm for the asm functions.  The FN symbols
  point at the function _descriptors_; the .FN symbols point at the
  first instruction of the function.

XXX Unclear why we have the .FN symbols for asm functions but not for
C functions.  I'm not sure we should be exporting them.


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/lib/libm/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libm/m.powerpc64.expsym

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



CVS commit: src/sys/dev/ic

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

Modified Files:
src/sys/dev/ic: tpm.c

Log Message:
tpm(4): device_printf needs \n.

Observed in PR 58255.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/tpm.c

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

Modified files:

Index: src/sys/dev/ic/tpm.c
diff -u src/sys/dev/ic/tpm.c:1.28 src/sys/dev/ic/tpm.c:1.29
--- src/sys/dev/ic/tpm.c:1.28	Tue Jul  4 01:02:26 2023
+++ src/sys/dev/ic/tpm.c	Tue May 14 13:41:15 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tpm.c,v 1.28 2023/07/04 01:02:26 riastradh Exp $	*/
+/*	$NetBSD: tpm.c,v 1.29 2024/05/14 13:41:15 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.28 2023/07/04 01:02:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.29 2024/05/14 13:41:15 riastradh Exp $");
 
 #include 
 #include 
@@ -150,7 +150,7 @@ tpm12_suspend(struct tpm_softc *sc)
 	 */
 	error = (*sc->sc_intf->start)(sc, UIO_WRITE);
 	if (error) {
-		device_printf(sc->sc_dev, "start write failed: %d", error);
+		device_printf(sc->sc_dev, "start write failed: %d\n", error);
 		goto out;
 	}
 
@@ -158,8 +158,8 @@ tpm12_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->write)(sc, , sizeof(command));
 	if (error) {
-		device_printf(sc->sc_dev, "write TPM_ORD_SaveState failed: %d",
-		error);
+		device_printf(sc->sc_dev, "write TPM_ORD_SaveState failed:"
+		" %d\n", error);
 		goto out;
 	}
 
@@ -167,7 +167,7 @@ tpm12_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->end)(sc, UIO_WRITE, 0);
 	if (error) {
-		device_printf(sc->sc_dev, "end write failed: %d", error);
+		device_printf(sc->sc_dev, "end write failed: %d\n", error);
 		goto out;
 	}
 
@@ -177,7 +177,7 @@ tpm12_suspend(struct tpm_softc *sc)
 	 */
 	error = (*sc->sc_intf->start)(sc, UIO_READ);
 	if (error) {
-		device_printf(sc->sc_dev, "start read failed: %d", error);
+		device_printf(sc->sc_dev, "start read failed: %d\n", error);
 		goto out;
 	}
 
@@ -186,11 +186,11 @@ tpm12_suspend(struct tpm_softc *sc)
 	error = (*sc->sc_intf->read)(sc, , sizeof(response), ,
 	0);
 	if (error) {
-		device_printf(sc->sc_dev, "read failed: %d", error);
+		device_printf(sc->sc_dev, "read failed: %d\n", error);
 		goto out;
 	}
 	if (nread != sizeof(response)) {
-		device_printf(sc->sc_dev, "short header read: %zu", nread);
+		device_printf(sc->sc_dev, "short header read: %zu\n", nread);
 		goto out;
 	}
 
@@ -198,7 +198,7 @@ tpm12_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->end)(sc, UIO_READ, 0);
 	if (error) {
-		device_printf(sc->sc_dev, "end read failed: %d", error);
+		device_printf(sc->sc_dev, "end read failed: %d\n", error);
 		goto out;
 	}
 
@@ -209,7 +209,8 @@ tpm12_suspend(struct tpm_softc *sc)
 	be32toh(response.length) != sizeof(response) ||
 	be32toh(response.code) != 0) {
 		device_printf(sc->sc_dev,
-		"TPM_ORD_SaveState failed: tag=0x%x length=0x%x code=0x%x",
+		"TPM_ORD_SaveState failed:"
+		" tag=0x%x length=0x%x code=0x%x\n",
 		be16toh(response.tag),
 		be32toh(response.length),
 		be32toh(response.code));
@@ -248,7 +249,7 @@ tpm20_suspend(struct tpm_softc *sc)
 	 */
 	error = (*sc->sc_intf->start)(sc, UIO_WRITE);
 	if (error) {
-		device_printf(sc->sc_dev, "start write failed: %d", error);
+		device_printf(sc->sc_dev, "start write failed: %d\n", error);
 		goto out;
 	}
 
@@ -256,8 +257,8 @@ tpm20_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->write)(sc, , sizeof(command));
 	if (error) {
-		device_printf(sc->sc_dev, "write TPM_ORD_SaveState failed: %d",
-		error);
+		device_printf(sc->sc_dev, "write TPM_ORD_SaveState failed:"
+		" %d\n", error);
 		goto out;
 	}
 
@@ -265,7 +266,7 @@ tpm20_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->end)(sc, UIO_WRITE, 0);
 	if (error) {
-		device_printf(sc->sc_dev, "end write failed: %d", error);
+		device_printf(sc->sc_dev, "end write failed: %d\n", error);
 		goto out;
 	}
 
@@ -275,7 +276,7 @@ tpm20_suspend(struct tpm_softc *sc)
 	 */
 	error = (*sc->sc_intf->start)(sc, UIO_READ);
 	if (error) {
-		device_printf(sc->sc_dev, "start read failed: %d", error);
+		device_printf(sc->sc_dev, "start read failed: %d\n", error);
 		goto out;
 	}
 
@@ -284,11 +285,11 @@ tpm20_suspend(struct tpm_softc *sc)
 	error = (*sc->sc_intf->read)(sc, , sizeof(response), ,
 	0);
 	if (error) {
-		device_printf(sc->sc_dev, "read failed: %d", error);
+		device_printf(sc->sc_dev, "read failed: %d\n", error);
 		goto out;
 	}
 	if (nread != sizeof(response)) {
-		device_printf(sc->sc_dev, "short header read: %zu", nread);
+		device_printf(sc->sc_dev, "short header read: %zu\n", nread);
 		goto out;
 	}
 
@@ -296,7 +297,7 @@ tpm20_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->end)(sc, UIO_READ, 0);
 	if (error) {
-		

CVS commit: src/sys/dev/ic

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

Modified Files:
src/sys/dev/ic: tpm.c

Log Message:
tpm(4): device_printf needs \n.

Observed in PR 58255.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/tpm.c

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



Re: CVS commit: src/usr.sbin/flashctl

2024-05-13 Thread Taylor R Campbell
> Module Name:src
> Committed By:   rillig
> Date:   Sun May 12 19:03:55 UTC 2024
> 
> Modified Files:
> src/usr.sbin/flashctl: flashctl.c
> 
> Log Message:
> flashctl: fix lint's strict bool mode with Clang preprocessor
> 
> Treating the return value from the  character classification
> functions as an 'int' is neither elegant nor idiomatic, but it works for
> now.
> 
> -   if (!isxdigit((unsigned char)str[2]))
> +   if (isxdigit((unsigned char)str[2]) == 0)

Why is this change necessary?  Weren't you teaching lint to handle
this case without complaining?  We shouldn't change anything like

if (!isxdigit(...))
if (ferror(...))

to

if (isxdigit(...) == 0)
if (ferror(...) != 0)

The original is clearer and idiomatic code, even if it's a little
silly that the return value is declared as int and not bool
(presumably for historical reasons, if the interfaces were defined
before bool existed).


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/sys/arch/riscv/include

2024-05-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 12 20:04:12 UTC 2024

Modified Files:
src/sys/arch/riscv/include: fenv.h

Log Message:
riscv fenv.h: Make sure FE_* exception constants have type int.

This may not be formally required by the standard, but the values
must be representable by int since that's the type that functions
like fetestexcept and feclearexcept traffic in.  And this is less
work than changing all the printf %d users in tree.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/riscv/include/fenv.h

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



CVS commit: src/sys/arch/riscv/include

2024-05-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 12 20:04:12 UTC 2024

Modified Files:
src/sys/arch/riscv/include: fenv.h

Log Message:
riscv fenv.h: Make sure FE_* exception constants have type int.

This may not be formally required by the standard, but the values
must be representable by int since that's the type that functions
like fetestexcept and feclearexcept traffic in.  And this is less
work than changing all the printf %d users in tree.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/riscv/include/fenv.h

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

Modified files:

Index: src/sys/arch/riscv/include/fenv.h
diff -u src/sys/arch/riscv/include/fenv.h:1.4 src/sys/arch/riscv/include/fenv.h:1.5
--- src/sys/arch/riscv/include/fenv.h:1.4	Fri May 10 08:20:37 2024
+++ src/sys/arch/riscv/include/fenv.h	Sun May 12 20:04:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: fenv.h,v 1.4 2024/05/10 08:20:37 skrll Exp $	*/
+/*	$NetBSD: fenv.h,v 1.5 2024/05/12 20:04:12 riastradh Exp $	*/
 
 /*
  * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995
@@ -11,11 +11,11 @@
 typedef int fenv_t;		/* FPSCR */
 typedef int fexcept_t;
 
-#define	FE_INEXACT	__BIT(0)	/* Result inexact */
-#define	FE_UNDERFLOW	__BIT(1)	/* Result underflowed */
-#define	FE_OVERFLOW	__BIT(2)	/* Result overflowed */
-#define	FE_DIVBYZERO	__BIT(3)	/* divide-by-zero */
-#define	FE_INVALID	__BIT(4)	/* Result invalid */
+#define	FE_INEXACT	((int)__BIT(0))	/* Result inexact */
+#define	FE_UNDERFLOW	((int)__BIT(1))	/* Result underflowed */
+#define	FE_OVERFLOW	((int)__BIT(2))	/* Result overflowed */
+#define	FE_DIVBYZERO	((int)__BIT(3))	/* divide-by-zero */
+#define	FE_INVALID	((int)__BIT(4))	/* Result invalid */
 
 #define	FE_ALL_EXCEPT	\
 (FE_INEXACT | FE_UNDERFLOW | FE_OVERFLOW | FE_DIVBYZERO | FE_INVALID)



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

2024-05-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 11 20:09:47 UTC 2024

Modified Files:
src/lib/libm/src: e_hypotl.c
src/tests/lib/libm: t_hypot.c

Log Message:
hypotl(3): Fix includes and macros.

1. Need  for __HAVE_LONG_DOUBLE.
2. Need  for struct ieee_ext_u 
3. EXT_FRACLBITS, not LDBL_MANL_SIZE.

PR lib/58245: hypotl is broken on ld128 ports


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/src/e_hypotl.c
cvs rdiff -u -r1.4 -r1.5 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/lib/libm/src/e_hypotl.c
diff -u src/lib/libm/src/e_hypotl.c:1.1 src/lib/libm/src/e_hypotl.c:1.2
--- src/lib/libm/src/e_hypotl.c:1.1	Sun Jan 21 18:53:18 2024
+++ src/lib/libm/src/e_hypotl.c	Sat May 11 20:09:47 2024
@@ -16,6 +16,9 @@
 
 
 #include 
+#include 
+
+#include 
 
 __weak_alias(hypotl, _hypotl)
 
@@ -45,7 +48,7 @@ __weak_alias(hypotl, _hypotl)
 #define	MANT_DIG	LDBL_MANT_DIG
 #define	MAX_EXP		LDBL_MAX_EXP
 
-#if LDBL_MANL_SIZE > 32
+#if EXT_FRACLBITS > 32
 typedef	uint64_t man_t;
 #else
 typedef	uint32_t man_t;

Index: src/tests/lib/libm/t_hypot.c
diff -u src/tests/lib/libm/t_hypot.c:1.4 src/tests/lib/libm/t_hypot.c:1.5
--- src/tests/lib/libm/t_hypot.c:1.4	Sat May 11 20:09:13 2024
+++ src/tests/lib/libm/t_hypot.c	Sat May 11 20:09:47 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_hypot.c,v 1.4 2024/05/11 20:09:13 riastradh Exp $ */
+/* $NetBSD: t_hypot.c,v 1.5 2024/05/11 20:09:47 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -265,10 +265,6 @@ ATF_TC_BODY(hypotl_trivial, tc)
 		CHECKL_EQ(i, hypotl, -0.L, -x, x);
 	}
 
-#if __HAVE_LONG_DOUBLE + 0 == 128
-	atf_tc_expect_fail("PR lib/58245: hypotl is broken on ld128 ports");
-#endif
-
 	for (i = 0; i < __arraycount(trivial_casesl); i++) {
 		volatile long double x = trivial_casesl[i];
 
@@ -457,10 +453,6 @@ ATF_TC_BODY(hypotl_exact, tc)
 		}
 	}
 
-#if __HAVE_LONG_DOUBLE + 0 == 128
-	atf_tc_expect_fail("PR lib/58245: hypotl is broken on ld128 ports");
-#endif
-
 #if LDBL_MANT_DIG >= 64
 	for (i = 0; i < __arraycount(exact_casesl); i++) {
 		int s;



CVS commit: src

2024-05-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 11 20:09:47 UTC 2024

Modified Files:
src/lib/libm/src: e_hypotl.c
src/tests/lib/libm: t_hypot.c

Log Message:
hypotl(3): Fix includes and macros.

1. Need  for __HAVE_LONG_DOUBLE.
2. Need  for struct ieee_ext_u 
3. EXT_FRACLBITS, not LDBL_MANL_SIZE.

PR lib/58245: hypotl is broken on ld128 ports


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/src/e_hypotl.c
cvs rdiff -u -r1.4 -r1.5 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: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/sys/sys

2024-05-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 11 13:26:54 UTC 2024

Modified Files:
src/sys/sys: cdefs.h

Log Message:
sys/cdefs.h: Make various macros work more robustly.

Use predefined __-namespace macros inside __BIT, __type_min,
__type_max, and __type_fit:

- Use __CHAR_BIT__ instead of NBBY so this works without sys/types.h
  and without _NETBSD_SOURCE.

- Use __INTMAX_TYPE__, __UINTMAX_TYPE__ instead of intmax_t, uintmax_t
  so this works without stdint.h.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/sys/cdefs.h

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

Modified files:

Index: src/sys/sys/cdefs.h
diff -u src/sys/sys/cdefs.h:1.161 src/sys/sys/cdefs.h:1.162
--- src/sys/sys/cdefs.h:1.161	Wed May  1 07:43:41 2024
+++ src/sys/sys/cdefs.h	Sat May 11 13:26:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cdefs.h,v 1.161 2024/05/01 07:43:41 rillig Exp $	*/
+/*	$NetBSD: cdefs.h,v 1.162 2024/05/11 13:26:54 riastradh Exp $	*/
 
 /* * Copyright (c) 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -645,9 +645,12 @@
 
 #ifndef __ASSEMBLER__
 /* __BIT(n): nth bit, where __BIT(0) == 0x1. */
-#define	__BIT(__n)	\
-(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \
-((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1
+#define	__BIT(__n)			  \
+	(((__UINTMAX_TYPE__)(__n) >= __CHAR_BIT__ * sizeof(__UINTMAX_TYPE__)) \
+	? 0  \
+	: ((__UINTMAX_TYPE__)1 <<	  \
+		(__UINTMAX_TYPE__)((__n) &  \
+		(__CHAR_BIT__ * sizeof(__UINTMAX_TYPE__) - 1
 
 /* __MASK(n): first n bits all set, where __MASK(4) == 0b. */
 #define	__MASK(__n)	(__BIT(__n) - 1)
@@ -720,8 +723,8 @@
  */
 #define	__MACROUSE(e)	(/*LINTED*/(void)sizeof((long)(e)))
 
-#define __type_mask(t) (/*LINTED*/sizeof(t) < sizeof(intmax_t) ? \
-(~((1ULL << (sizeof(t) * NBBY)) - 1)) : 0ULL)
+#define __type_mask(t) (/*LINTED*/sizeof(t) < sizeof(__INTMAX_TYPE__) ? \
+(~((1ULL << (sizeof(t) * __CHAR_BIT__)) - 1)) : 0ULL)
 
 #ifndef __ASSEMBLER__
 static __inline long long __zeroll(void) { return 0; }
@@ -733,8 +736,8 @@ static __inline unsigned long long __zer
 
 #define __negative_p(x) (!((x) > 0) && ((x) != 0))
 
-#define __type_min_s(t) ((t)((1ULL << (sizeof(t) * NBBY - 1
-#define __type_max_s(t) ((t)~((1ULL << (sizeof(t) * NBBY - 1
+#define __type_min_s(t) ((t)((1ULL << (sizeof(t) * __CHAR_BIT__ - 1
+#define __type_max_s(t) ((t)~((1ULL << (sizeof(t) * __CHAR_BIT__ - 1
 #define __type_min_u(t) ((t)0ULL)
 #define __type_max_u(t) ((t)~0ULL)
 #define __type_is_signed(t) (/*LINTED*/__type_min_s(t) + (t)1 < (t)1)
@@ -742,13 +745,18 @@ static __inline unsigned long long __zer
 #define __type_max(t) (__type_is_signed(t) ? __type_max_s(t) : __type_max_u(t))
 
 
-#define __type_fit_u(t, a) (/*LINTED*/!__negative_p(a) && \
-(uintmax_t)((a) + __zeroull()) <= (uintmax_t)__type_max_u(t))
-
-#define __type_fit_s(t, a) (/*LINTED*/__negative_p(a) ? \
-((intmax_t)((a) + __zeroll()) >= (intmax_t)__type_min_s(t)) : \
-((intmax_t)((a) + __zeroll()) >= (intmax_t)0 && \
- (intmax_t)((a) + __zeroll()) <= (intmax_t)__type_max_s(t)))
+#define __type_fit_u(t, a)		  \
+	(/*LINTED*/!__negative_p(a) &&	  \
+	((__UINTMAX_TYPE__)((a) + __zeroull()) <=			  \
+		(__UINTMAX_TYPE__)__type_max_u(t)))
+
+#define __type_fit_s(t, a)		  \
+	(/*LINTED*/__negative_p(a)	  \
+	? ((__INTMAX_TYPE__)((a) + __zeroll()) >=			  \
+		(__INTMAX_TYPE__)__type_min_s(t))			  \
+	: ((__INTMAX_TYPE__)((a) + __zeroll()) >= (__INTMAX_TYPE__)0 &&   \
+		((__INTMAX_TYPE__)((a) + __zeroll()) <=			  \
+		(__INTMAX_TYPE__)__type_max_s(t
 
 /*
  * return true if value 'a' fits in type 't'



CVS commit: src/sys/sys

2024-05-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 11 13:26:54 UTC 2024

Modified Files:
src/sys/sys: cdefs.h

Log Message:
sys/cdefs.h: Make various macros work more robustly.

Use predefined __-namespace macros inside __BIT, __type_min,
__type_max, and __type_fit:

- Use __CHAR_BIT__ instead of NBBY so this works without sys/types.h
  and without _NETBSD_SOURCE.

- Use __INTMAX_TYPE__, __UINTMAX_TYPE__ instead of intmax_t, uintmax_t
  so this works without stdint.h.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/sys/cdefs.h

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



CVS commit: src

2024-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 11 02:07:54 UTC 2024

Modified Files:
src/lib/libm/src: s_nexttoward.c
src/tests/lib/libm: t_next.c

Log Message:
nexttoward(3): Fix high-word test on small positive subnormals.

By this point in the logic, x can't be zero, so it's either positive
or negative.

The high word hx, however, can be zero, when x is a small positive
subnormal.  This means x is a small positive subnormal, so if x > y
we are computing nextDown, and if x < y we are computing nextUp.

hx is a (signed 32-bit) integer, not a double floating-point number,
so it's a little silly to compare hx > 0.0.  But that on its own
isn't enough to trigger the bug because all signed 32-bit integers
can be represented by double on all NetBSD architectures.

PR lib/58236


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/src/s_nexttoward.c
cvs rdiff -u -r1.5 -r1.6 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/lib/libm/src/s_nexttoward.c
diff -u src/lib/libm/src/s_nexttoward.c:1.2 src/lib/libm/src/s_nexttoward.c:1.3
--- src/lib/libm/src/s_nexttoward.c:1.2	Wed Aug 21 13:03:56 2013
+++ src/lib/libm/src/s_nexttoward.c	Sat May 11 02:07:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: s_nexttoward.c,v 1.2 2013/08/21 13:03:56 martin Exp $	*/
+/*	$NetBSD: s_nexttoward.c,v 1.3 2024/05/11 02:07:53 riastradh Exp $	*/
 
 /* @(#)s_nextafter.c 5.1 93/09/24 */
 /*
@@ -13,7 +13,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: s_nexttoward.c,v 1.2 2013/08/21 13:03:56 martin Exp $");
+__RCSID("$NetBSD: s_nexttoward.c,v 1.3 2024/05/11 02:07:53 riastradh Exp $");
 
 /*
  * We assume that a long double has a 15-bit exponent.  On systems
@@ -71,7 +71,7 @@ nexttoward(double x, long double y)
 			return x;		/* raise underflow flag */
 	}
 
-	if ((hx > 0.0) ^ (x < y)) {		/* x -= ulp */
+	if ((hx >= 0) ^ (x < y)) {		/* x -= ulp */
 		if (lx == 0) hx -= 1;
 		lx -= 1;
 	} else {/* x += ulp */

Index: src/tests/lib/libm/t_next.c
diff -u src/tests/lib/libm/t_next.c:1.5 src/tests/lib/libm/t_next.c:1.6
--- src/tests/lib/libm/t_next.c:1.5	Sat May 11 01:44:12 2024
+++ src/tests/lib/libm/t_next.c	Sat May 11 02:07:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_next.c,v 1.5 2024/05/11 01:44:12 riastradh Exp $	*/
+/*	$NetBSD: t_next.c,v 1.6 2024/05/11 02:07:54 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_next.c,v 1.5 2024/05/11 01:44:12 riastradh Exp $");
+__RCSID("$NetBSD: t_next.c,v 1.6 2024/05/11 02:07:54 riastradh Exp $");
 
 #include 
 #include 
@@ -391,9 +391,6 @@ 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

2024-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 11 02:07:54 UTC 2024

Modified Files:
src/lib/libm/src: s_nexttoward.c
src/tests/lib/libm: t_next.c

Log Message:
nexttoward(3): Fix high-word test on small positive subnormals.

By this point in the logic, x can't be zero, so it's either positive
or negative.

The high word hx, however, can be zero, when x is a small positive
subnormal.  This means x is a small positive subnormal, so if x > y
we are computing nextDown, and if x < y we are computing nextUp.

hx is a (signed 32-bit) integer, not a double floating-point number,
so it's a little silly to compare hx > 0.0.  But that on its own
isn't enough to trigger the bug because all signed 32-bit integers
can be represented by double on all NetBSD architectures.

PR lib/58236


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/src/s_nexttoward.c
cvs rdiff -u -r1.5 -r1.6 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-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/sys/arch/arm/fdt

2024-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 10 14:42:21 UTC 2024

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
arm/fdt/cpu_fdt.c: Use `cpu' iattr to attach cpufreq.

Now that cpu has an explicit interface attribute, cpufeaturebus,
_all_ children of cpu must use an explicit interface attribute to
disambiguate.  For children that weren't previously attached using an
explicit interface attribute, the name of the parent, `cpu', serves
as the iattr.

XXX I think we should either
(a) not use cpufreqbus, since in the aarch64 case it doesn't seem to
be passing any information through attach args, or
(b) create another iattr like cpufdtbus for use by cpufreq_dt.c,
which does rely on attach args, if it has to attach differently
from the rest of fdtbus.
But for now this should get aarch64 on fdt booting again.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/fdt/cpu_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2024-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 10 14:42:21 UTC 2024

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
arm/fdt/cpu_fdt.c: Use `cpu' iattr to attach cpufreq.

Now that cpu has an explicit interface attribute, cpufeaturebus,
_all_ children of cpu must use an explicit interface attribute to
disambiguate.  For children that weren't previously attached using an
explicit interface attribute, the name of the parent, `cpu', serves
as the iattr.

XXX I think we should either
(a) not use cpufreqbus, since in the aarch64 case it doesn't seem to
be passing any information through attach args, or
(b) create another iattr like cpufdtbus for use by cpufreq_dt.c,
which does rely on attach args, if it has to attach differently
from the rest of fdtbus.
But for now this should get aarch64 on fdt booting again.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/fdt/cpu_fdt.c

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

Modified files:

Index: src/sys/arch/arm/fdt/cpu_fdt.c
diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.43 src/sys/arch/arm/fdt/cpu_fdt.c:1.44
--- src/sys/arch/arm/fdt/cpu_fdt.c:1.43	Thu May  9 12:41:08 2024
+++ src/sys/arch/arm/fdt/cpu_fdt.c	Fri May 10 14:42:21 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_fdt.c,v 1.43 2024/05/09 12:41:08 pho Exp $ */
+/* $NetBSD: cpu_fdt.c,v 1.44 2024/05/10 14:42:21 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "psci_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.43 2024/05/09 12:41:08 pho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.44 2024/05/10 14:42:21 riastradh Exp $");
 
 #include 
 #include 
@@ -98,7 +98,7 @@ cpu_fdt_attach(device_t parent, device_t
 	cpu_attach(self, cpuid);
 
 	/* Attach CPU frequency scaling provider */
-	config_found(self, faa, NULL, CFARGS_NONE);
+	config_found(self, faa, NULL, CFARGS(.iattr = "cpu"));
 }
 
 #if defined(MULTIPROCESSOR) && (NPSCI_FDT > 0 || defined(__aarch64__))



CVS commit: src/distrib/sets/lists/xdebug

2024-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 10 12:24:08 UTC 2024

Modified Files:
src/distrib/sets/lists/xdebug: shl.mi

Log Message:
xdebug/shl.mi: Delete libXxf86misc.so.2.0.debug.

Loading existing applications that linked against this into a
debugger should continue to work, so it shouldn't be obsoleted, but
the file is no longer installed.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/distrib/sets/lists/xdebug/shl.mi

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



CVS commit: src/distrib/sets/lists/xdebug

2024-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 10 12:24:08 UTC 2024

Modified Files:
src/distrib/sets/lists/xdebug: shl.mi

Log Message:
xdebug/shl.mi: Delete libXxf86misc.so.2.0.debug.

Loading existing applications that linked against this into a
debugger should continue to work, so it shouldn't be obsoleted, but
the file is no longer installed.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/distrib/sets/lists/xdebug/shl.mi

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

Modified files:

Index: src/distrib/sets/lists/xdebug/shl.mi
diff -u src/distrib/sets/lists/xdebug/shl.mi:1.69 src/distrib/sets/lists/xdebug/shl.mi:1.70
--- src/distrib/sets/lists/xdebug/shl.mi:1.69	Mon Sep  4 19:07:59 2023
+++ src/distrib/sets/lists/xdebug/shl.mi	Fri May 10 12:24:08 2024
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.69 2023/09/04 19:07:59 riastradh Exp $
+# $NetBSD: shl.mi,v 1.70 2024/05/10 12:24:08 riastradh Exp $
 ./usr/libdata/debug/usr/X11R7/lib	base-sys-usr		xorg,debug,compatx11dir
 ./usr/libdata/debug/usr/X11R7/lib/X11/locale/lib/common/libximcp.so.2.0.debug	obsolete		obsolete
 ./usr/libdata/debug/usr/X11R7/lib/X11/locale/lib/common/libxlcDef.so.2.0.debug	obsolete		obsolete
@@ -50,7 +50,6 @@
 ./usr/libdata/debug/usr/X11R7/lib/libXvMC.so.2.0.debug	xdebug-libXvMC-debug		xorg,debug,compatx11file
 ./usr/libdata/debug/usr/X11R7/lib/libXvMCW.so.1.0.debug	xdebug-libXvMCW-debug		xorg,debug,compatx11file
 ./usr/libdata/debug/usr/X11R7/lib/libXxf86dga.so.2.0.debug	xdebug-libXxf86dga-debug		xorg,debug,compatx11file
-./usr/libdata/debug/usr/X11R7/lib/libXxf86misc.so.2.0.debug	xdebug-libXxf86misc-debug		xorg,debug,compatx11file
 ./usr/libdata/debug/usr/X11R7/lib/libXxf86vm.so.2.0.debug	xdebug-libXxf86vm-debug		xorg,debug,compatx11file
 ./usr/libdata/debug/usr/X11R7/lib/libdrm.so.3.7.debug	xdebug-libdrm-debug		xorg,debug,compatx11file
 ./usr/libdata/debug/usr/X11R7/lib/libdrm_radeon.so.0.0.debug	xdebug-libdrm_radeon-debug		xorg,debug,compatx11file



  1   2   3   4   5   6   7   8   9   10   >