CVS commit: src/sys/dev

2023-05-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 24 00:02:51 UTC 2023

Modified Files:
src/sys/dev: efi.c

Log Message:
efi(4): Fix logic to handle buffer sizing.

Can't KASSERT(datasize <= databufsize) because the caller is allowed
to pass in a too-small size and get ERR_BUFFER_TOO_SMALL back, with
the actual size returned so it can resize its buffer.  So just clamp
the size to the smaller of what the caller provided and what the
firwmare provided, instead of asserting anything.

PR kern/57076

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/efi.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

2023-05-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 24 00:02:51 UTC 2023

Modified Files:
src/sys/dev: efi.c

Log Message:
efi(4): Fix logic to handle buffer sizing.

Can't KASSERT(datasize <= databufsize) because the caller is allowed
to pass in a too-small size and get ERR_BUFFER_TOO_SMALL back, with
the actual size returned so it can resize its buffer.  So just clamp
the size to the smaller of what the caller provided and what the
firwmare provided, instead of asserting anything.

PR kern/57076

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/efi.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/efi.c
diff -u src/sys/dev/efi.c:1.8 src/sys/dev/efi.c:1.9
--- src/sys/dev/efi.c:1.8	Mon May 22 16:28:16 2023
+++ src/sys/dev/efi.c	Wed May 24 00:02:51 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: efi.c,v 1.8 2023/05/22 16:28:16 riastradh Exp $ */
+/* $NetBSD: efi.c,v 1.9 2023/05/24 00:02:51 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2021 Jared McNeill 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.8 2023/05/22 16:28:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.9 2023/05/24 00:02:51 riastradh Exp $");
 
 #include 
 #include 
@@ -377,10 +377,10 @@ efi_ioctl_var_get(struct efi_var_ioc *va
 		error = efi_status_to_error(status);
 		goto done;
 	}
-	KASSERT(datasize <= databufsize);
 	var->datasize = datasize;
-	if (status == EFI_SUCCESS && databuf != NULL) {
-		error = copyout(databuf, var->data, var->datasize);
+	if (status == EFI_SUCCESS && databufsize != 0) {
+		error = copyout(databuf, var->data,
+		MIN(datasize, databufsize));
 	} else {
 		var->data = NULL;
 	}
@@ -423,10 +423,10 @@ efi_ioctl_var_next(struct efi_var_ioc *v
 		error = efi_status_to_error(status);
 		goto done;
 	}
-	KASSERT(namesize <= namebufsize);
 	var->namesize = namesize;
 	if (status == EFI_SUCCESS) {
-		error = copyout(namebuf, var->name, var->namesize);
+		error = copyout(namebuf, var->name,
+		MIN(namesize, namebufsize));
 	} else {
 		var->name = NULL;
 	}



CVS commit: src

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 20:26:52 UTC 2023

Modified Files:
src: UPDATING

Log Message:
ctfmerge tool fixes might need a clean tools build


To generate a diff of this commit:
cvs rdiff -u -r1.337 -r1.338 src/UPDATING

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



CVS commit: src

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 20:26:52 UTC 2023

Modified Files:
src: UPDATING

Log Message:
ctfmerge tool fixes might need a clean tools build


To generate a diff of this commit:
cvs rdiff -u -r1.337 -r1.338 src/UPDATING

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

Modified files:

Index: src/UPDATING
diff -u src/UPDATING:1.337 src/UPDATING:1.338
--- src/UPDATING:1.337	Thu Mar 23 07:15:08 2023
+++ src/UPDATING	Tue May 23 20:26:52 2023
@@ -1,4 +1,4 @@
-$NetBSD: UPDATING,v 1.337 2023/03/23 07:15:08 mrg Exp $
+$NetBSD: UPDATING,v 1.338 2023/05/23 20:26:52 lukem Exp $
 
 This file (UPDATING) is intended to be a brief reference to recent
 changes that might cause problems in the build process, and a guide for
@@ -19,6 +19,11 @@ See also: BUILDING, build.sh, Makefile.
 Recent changes:
 ^^^
 
+
+20230523:
+	ctfmerge was fixed as macOS host tool. This may require a clean tools
+	rebuild to detect the update to tools/compat/configure.
+
 20230322:
 	Fixes for moved /lib/libisns* mean that builds will complain about
 	./usr/lib/libisns* being missing until src/lib/libisns is forced
@@ -32,7 +37,6 @@ Recent changes:
 	userland.
 
 20221116:
-
 	The addition to NetBSD's version of UFS2 of support for extended
 	attributes broke backward compatibility with previous releases
 	of NetBSD, so UFS2 has been restored to being compatible with



CVS commit: src/doc

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 20:24:24 UTC 2023

Modified Files:
src/doc: CHANGES

Log Message:
ctfmerge: pthread error handling. macos host fixes


To generate a diff of this commit:
cvs rdiff -u -r1.2966 -r1.2967 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2966 src/doc/CHANGES:1.2967
--- src/doc/CHANGES:1.2966	Sat May 13 12:51:28 2023
+++ src/doc/CHANGES	Tue May 23 20:24:24 2023
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2966 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2967 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -103,3 +103,5 @@ Changes from NetBSD 10.0 to NetBSD 11.0:
 		[skrll 20230507]
 	riscv: Add Google Goldfish RTC driver. [skrll 20230508]
 	OpenSSL: Imported 3.0.8. [christos 20230510]
+	ctfmerge: Add error handling to pthread APIs.
+		Fix semaphores for macOS host tool.  [lukem 20230523]



CVS commit: src/doc

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 20:24:24 UTC 2023

Modified Files:
src/doc: CHANGES

Log Message:
ctfmerge: pthread error handling. macos host fixes


To generate a diff of this commit:
cvs rdiff -u -r1.2966 -r1.2967 src/doc/CHANGES

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



CVS commit: src/tools/compat

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 20:22:11 UTC 2023

Modified Files:
src/tools/compat: configure nbtool_config.h.in

Log Message:
tools/compat: regen for dispatch_semaphore_create


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/tools/compat/configure
cvs rdiff -u -r1.53 -r1.54 src/tools/compat/nbtool_config.h.in

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

Modified files:

Index: src/tools/compat/configure
diff -u src/tools/compat/configure:1.99 src/tools/compat/configure:1.100
--- src/tools/compat/configure:1.99	Thu Feb 25 13:41:58 2021
+++ src/tools/compat/configure	Tue May 23 20:22:11 2023
@@ -5294,6 +5294,7 @@ _ACEOF
 fi
 
 for ac_func in atoll asprintf asnprintf basename devname dirfd dirname \
+	dispatch_semaphore_create \
 	dprintf esetfunc fgetln flock fpurge __fpurge futimes getline \
 	getopt getopt_long group_from_gid gid_from_group \
 	heapsort isblank issetugid lchflags lchmod lchown lutimes mkstemp \

Index: src/tools/compat/nbtool_config.h.in
diff -u src/tools/compat/nbtool_config.h.in:1.53 src/tools/compat/nbtool_config.h.in:1.54
--- src/tools/compat/nbtool_config.h.in:1.53	Thu Feb 25 13:41:58 2021
+++ src/tools/compat/nbtool_config.h.in	Tue May 23 20:22:11 2023
@@ -1,6 +1,6 @@
 /* nbtool_config.h.in.  Generated from configure.ac by autoheader.  */
 
-/*  $NetBSD: nbtool_config.h.in,v 1.53 2021/02/25 13:41:58 christos Exp $*/
+/*  $NetBSD: nbtool_config.h.in,v 1.54 2023/05/23 20:22:11 lukem Exp $*/
  
 #ifndef __NETBSD_NBTOOL_CONFIG_H__
 #define __NETBSD_NBTOOL_CONFIG_H__
@@ -8,7 +8,7 @@
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD
 
-/* Define to 1 if your `fparseln' function is broken. */
+/* Define to 1 if your 'fparseln' function is broken. */
 #undef BROKEN_FPARSELN
 
 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
@@ -437,6 +437,9 @@
 /* Define to 1 if `__dd_fd' is a member of `DIR'. */
 #undef HAVE_DIR___DD_FD
 
+/* Define to 1 if you have the `dispatch_semaphore_create' function. */
+#undef HAVE_DISPATCH_SEMAPHORE_CREATE
+
 /* Define to 1 if you have the `dprintf' function. */
 #undef HAVE_DPRINTF
 



CVS commit: src/tools/compat

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 20:22:11 UTC 2023

Modified Files:
src/tools/compat: configure nbtool_config.h.in

Log Message:
tools/compat: regen for dispatch_semaphore_create


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/tools/compat/configure
cvs rdiff -u -r1.53 -r1.54 src/tools/compat/nbtool_config.h.in

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



CVS commit: src

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 20:20:54 UTC 2023

Modified Files:
src/share/mk: bsd.own.mk
src/tools/compat: Makefile

Log Message:
tools/compat: MAKEVERBOSE support in regen


To generate a diff of this commit:
cvs rdiff -u -r1.1325 -r1.1326 src/share/mk/bsd.own.mk
cvs rdiff -u -r1.90 -r1.91 src/tools/compat/Makefile

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

Modified files:

Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.1325 src/share/mk/bsd.own.mk:1.1326
--- src/share/mk/bsd.own.mk:1.1325	Mon May 22 12:55:45 2023
+++ src/share/mk/bsd.own.mk	Tue May 23 20:20:54 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.1325 2023/05/22 12:55:45 lukem Exp $
+#	$NetBSD: bsd.own.mk,v 1.1326 2023/05/23 20:20:54 lukem Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -1740,6 +1740,7 @@ _MKMSG_INSTALL?=	${_MKMSG} "install "
 _MKMSG_LINK?=		${_MKMSG} "   link "
 _MKMSG_LEX?=		${_MKMSG} "lex "
 _MKMSG_REMOVE?=		${_MKMSG} " remove "
+_MKMSG_REGEN?=		${_MKMSG} "  regen "
 _MKMSG_YACC?=		${_MKMSG} "   yacc "
 
 _MKSHMSG_CREATE?=	${_MKSHMSG} " create "

Index: src/tools/compat/Makefile
diff -u src/tools/compat/Makefile:1.90 src/tools/compat/Makefile:1.91
--- src/tools/compat/Makefile:1.90	Sat Sep 18 01:47:10 2021
+++ src/tools/compat/Makefile	Tue May 23 20:20:54 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.90 2021/09/18 01:47:10 christos Exp $
+#	$NetBSD: Makefile,v 1.91 2023/05/23 20:20:54 lukem Exp $
 
 HOSTLIB=	nbcompat
 
@@ -166,5 +166,7 @@ INSTALL=	${INSTALL_OBJ}/xinstall
 # Run "${TOOLDIR}/bin/nbmake-${MACHINE} regen" by hand after editing
 # configure.ac.  See more detailed instructions in configure.ac.
 regen:
+	${_MKMSG_REGEN} configure
 	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoconf
+	${_MKMSG_REGEN} nbtool_config.h.in
 	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoheader



CVS commit: src

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 20:20:54 UTC 2023

Modified Files:
src/share/mk: bsd.own.mk
src/tools/compat: Makefile

Log Message:
tools/compat: MAKEVERBOSE support in regen


To generate a diff of this commit:
cvs rdiff -u -r1.1325 -r1.1326 src/share/mk/bsd.own.mk
cvs rdiff -u -r1.90 -r1.91 src/tools/compat/Makefile

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



CVS commit: src/external/gpl3/autoconf/dist/lib/autoconf

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 20:15:58 UTC 2023

Modified Files:
src/external/gpl3/autoconf/dist/lib/autoconf: functions.m4

Log Message:
autoconf: AC_FUNC_ALLOCA(): add local fix for BSD support

Add local fix to AC_FUNC_ALLOCA() to include  on BSD:
 # elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) 
|| defined(__OpenBSD__)
 #   include 

This change avoids regen losing this change in tools/compat/configure
that was added in rev 1.75 on 2013-03-05 of tools/compat/configure,
and subsequent commits that keep re-adding these lines back
manually (e.g., rev 1.97 on 2019-06-22 of tools/compat/configure)

XXX: Arguably this could be fixed in a separate way to allow us to
use an unmodified modern autoconf in the future ?


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/gpl3/autoconf/dist/lib/autoconf/functions.m4

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/autoconf/dist/lib/autoconf/functions.m4
diff -u src/external/gpl3/autoconf/dist/lib/autoconf/functions.m4:1.1.1.1 src/external/gpl3/autoconf/dist/lib/autoconf/functions.m4:1.2
--- src/external/gpl3/autoconf/dist/lib/autoconf/functions.m4:1.1.1.1	Sat Jan 16 18:36:00 2016
+++ src/external/gpl3/autoconf/dist/lib/autoconf/functions.m4	Tue May 23 20:15:58 2023
@@ -384,6 +384,8 @@ AC_CACHE_CHECK([for alloca], ac_cv_func_
 # ifdef _MSC_VER
 #  include 
 #  define alloca _alloca
+# elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
+#   include 
 # else
 #  ifdef HAVE_ALLOCA_H
 #   include 



CVS commit: src/external/gpl3/autoconf/dist/lib/autoconf

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 20:15:58 UTC 2023

Modified Files:
src/external/gpl3/autoconf/dist/lib/autoconf: functions.m4

Log Message:
autoconf: AC_FUNC_ALLOCA(): add local fix for BSD support

Add local fix to AC_FUNC_ALLOCA() to include  on BSD:
 # elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) 
|| defined(__OpenBSD__)
 #   include 

This change avoids regen losing this change in tools/compat/configure
that was added in rev 1.75 on 2013-03-05 of tools/compat/configure,
and subsequent commits that keep re-adding these lines back
manually (e.g., rev 1.97 on 2019-06-22 of tools/compat/configure)

XXX: Arguably this could be fixed in a separate way to allow us to
use an unmodified modern autoconf in the future ?


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/gpl3/autoconf/dist/lib/autoconf/functions.m4

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



CVS commit: src/external/bsd/unbound/include

2023-05-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue May 23 20:07:21 UTC 2023

Modified Files:
src/external/bsd/unbound/include: config.h

Log Message:
Set PID path back to "/var/run/unbound.pid" so rc scripts work again.

Ok: Christos Zoulas

PR bin/57242 unbound rc.d script does not work with chrooted unbound


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/unbound/include/config.h

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

Modified files:

Index: src/external/bsd/unbound/include/config.h
diff -u src/external/bsd/unbound/include/config.h:1.10 src/external/bsd/unbound/include/config.h:1.11
--- src/external/bsd/unbound/include/config.h:1.10	Sat Sep 24 18:11:43 2022
+++ src/external/bsd/unbound/include/config.h	Tue May 23 20:07:21 2023
@@ -773,7 +773,7 @@
 #define PACKAGE_VERSION "1.16.3"
 
 /* default pidfile location */
-#define PIDFILE CHROOT_DIR "/var/run/unbound.pid"
+#define PIDFILE "/var/run/unbound.pid"
 
 /* Define to necessary symbol if this constant uses a non-standard name on
your system. */



CVS commit: src/external/bsd/unbound/include

2023-05-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue May 23 20:07:21 UTC 2023

Modified Files:
src/external/bsd/unbound/include: config.h

Log Message:
Set PID path back to "/var/run/unbound.pid" so rc scripts work again.

Ok: Christos Zoulas

PR bin/57242 unbound rc.d script does not work with chrooted unbound


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/unbound/include/config.h

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



CVS commit: src

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 19:53:25 UTC 2023

Modified Files:
src/external/cddl/osnet/dist/tools/ctf/cvt: barrier.c barrier.h
src/tools/compat: configure.ac

Log Message:
ctfmerge: fix macOS semaphore implementation

Use dispatch_semaphore_create() if present instead of sem_init().

macOS doesn't actually implement sem_init() (et al)
(even though it provides the prototypes as deprecated).
This was detected by the previous commit to ctfmerge
that added error handling.

Implement ctfmerge's barrier operations in terms of
dispatch(3) APIs such as dispatch_semaphore_create() (et al).

Update tools/compat/configure.ac to find dispatch_semaphore_create().

Fixes ctfmerge on macOS hosts.

Inspired by https://stackoverflow.com/a/27847103.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.h
cvs rdiff -u -r1.99 -r1.100 src/tools/compat/configure.ac

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

Modified files:

Index: src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c
diff -u src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c:1.6 src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c:1.7
--- src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c:1.6	Tue May 23 18:54:58 2023
+++ src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c	Tue May 23 19:53:24 2023
@@ -60,6 +60,9 @@ barrier_init(barrier_t *bar, int nthread
 #ifdef illumos
 	if ((errno = sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL)) != 0)
 		terminate("%s: sema_init(bar_sem)", __func__);
+#elif defined(HAVE_DISPATCH_SEMAPHORE_CREATE)
+	if ((bar->bar_sem = dispatch_semaphore_create(0)) == NULL)
+		terminate("%s: dispatch_semaphore_create()\n", __func__);
 #else
 	if (sem_init(&bar->bar_sem, 0, 0) == -1)
 		terminate("%s: sem_init(bar_sem)", __func__);
@@ -72,6 +75,9 @@ barrier_init(barrier_t *bar, int nthread
 int
 barrier_wait(barrier_t *bar)
 {
+#if defined(HAVE_DISPATCH_SEMAPHORE_CREATE)
+	long error;
+#endif
 	if ((errno = pthread_mutex_lock(&bar->bar_lock)) != 0)
 		terminate("%s: pthread_mutex_lock(bar_lock)", __func__);
 
@@ -82,6 +88,10 @@ barrier_wait(barrier_t *bar)
 #ifdef illumos
 		if ((errno = sema_wait(&bar->bar_sem)) != 0)
 			terminate("%s: sema_wait(bar_sem)", __func__);
+#elif defined(HAVE_DISPATCH_SEMAPHORE_CREATE)
+		if ((error = dispatch_semaphore_wait(bar->bar_sem, DISPATCH_TIME_FOREVER)) != 0)
+			terminate("%s: dispatch_semaphore_wait(bar_sem) = %ld\n",
+			__func__, error);
 #else
 		if (sem_wait(&bar->bar_sem) == -1)
 			terminate("%s: sem_wait(bar_sem)", __func__);
@@ -94,14 +104,19 @@ barrier_wait(barrier_t *bar)
 
 		/* reset for next use */
 		bar->bar_numin = 0;
-		for (i = 1; i < bar->bar_nthr; i++)
+		for (i = 1; i < bar->bar_nthr; i++) {
 #ifdef illumos
 			if ((errno = sema_post(&bar->bar_sem)) != 0)
 terminate("%s: sema_post(bar_sem)", __func__);
+#elif defined(HAVE_DISPATCH_SEMAPHORE_CREATE)
+			if ((error = dispatch_semaphore_signal(bar->bar_sem)) != 0)
+terminate("%s: dispatch_semaphore_signal(bar_sem) = %ld\n",
+__func__, error);
 #else
 			if (sem_post(&bar->bar_sem) == -1)
 terminate("%s: sem_post(bar_sem)", __func__);
 #endif
+		}
 		if ((errno = pthread_mutex_unlock(&bar->bar_lock)) != 0)
 			terminate("%s: pthread_mutex_unlock(bar_lock)",
 			__func__);

Index: src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.h
diff -u src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.h:1.3 src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.h:1.4
--- src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.h:1.3	Mon May 28 21:05:06 2018
+++ src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.h	Tue May 23 19:53:24 2023
@@ -33,8 +33,15 @@
  * APIs for the barrier synchronization primitive.
  */
 
+#ifdef HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
 #ifdef illumos
 #include 
+#elif defined(HAVE_DISPATCH_SEMAPHORE_CREATE)
+#include 
+typedef dispatch_semaphore_t sema_t;
 #else
 #include 
 typedef sem_t	sema_t;

Index: src/tools/compat/configure.ac
diff -u src/tools/compat/configure.ac:1.99 src/tools/compat/configure.ac:1.100
--- src/tools/compat/configure.ac:1.99	Thu Feb 25 13:41:58 2021
+++ src/tools/compat/configure.ac	Tue May 23 19:53:24 2023
@@ -1,10 +1,10 @@
-#	$NetBSD: configure.ac,v 1.99 2021/02/25 13:41:58 christos Exp $
+#	$NetBSD: configure.ac,v 1.100 2023/05/23 19:53:24 lukem Exp $
 #
 # Autoconf definition file for libnbcompat.
 #
 # When you edit configure.ac:
 # 0. Create the tools versions of autoconf and autoheader:
-#cd ${SRCDIR} && build.sh -V MKMAINTAINERTOOLS=yes tools
+#cd ${SRCDIR} && ./build.sh -V MKMAINTAINERTOOLS=yes tools
 #(This might not work if you try it after editing configure.ac.)
 # 1. edit configure.ac
 # 2. Regenerate "configure" and "nbtool_config.h.in" from "configure.ac":
@@ -12,

CVS commit: src

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 19:53:25 UTC 2023

Modified Files:
src/external/cddl/osnet/dist/tools/ctf/cvt: barrier.c barrier.h
src/tools/compat: configure.ac

Log Message:
ctfmerge: fix macOS semaphore implementation

Use dispatch_semaphore_create() if present instead of sem_init().

macOS doesn't actually implement sem_init() (et al)
(even though it provides the prototypes as deprecated).
This was detected by the previous commit to ctfmerge
that added error handling.

Implement ctfmerge's barrier operations in terms of
dispatch(3) APIs such as dispatch_semaphore_create() (et al).

Update tools/compat/configure.ac to find dispatch_semaphore_create().

Fixes ctfmerge on macOS hosts.

Inspired by https://stackoverflow.com/a/27847103.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.h
cvs rdiff -u -r1.99 -r1.100 src/tools/compat/configure.ac

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



CVS commit: src/external/cddl/osnet/dist/tools/ctf/cvt

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 18:54:58 UTC 2023

Modified Files:
src/external/cddl/osnet/dist/tools/ctf/cvt: barrier.c ctfmerge.c
tdata.c

Log Message:
ctfmerge: error check sem_*() and pthread_*() APIs

terminate() if sem_*() returns -1 or pthread_*() returns != 0.
(Set errno from pthread_*() so terminate() prints the strerror message).

Note: Failing on errors instead of ignoring them helps identify
reasons for intermittent failures, such as those on macOS host builds:
  ERROR: nbctfmerge: barrier_init: sem_init(bar_sem): Function not implemented


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c
cvs rdiff -u -r1.17 -r1.18 \
src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/dist/tools/ctf/cvt/tdata.c

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

Modified files:

Index: src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c
diff -u src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c:1.5 src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c:1.6
--- src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c:1.5	Thu Jun 20 14:33:04 2019
+++ src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c	Tue May 23 18:54:58 2023
@@ -42,6 +42,7 @@
  * get a return code of 0.
  */
 
+#include 
 #include 
 #ifdef illumos
 #include 
@@ -49,15 +50,19 @@
 #include 
 
 #include "barrier.h"
+#include "ctftools.h"
 
 void
 barrier_init(barrier_t *bar, int nthreads)
 {
-	pthread_mutex_init(&bar->bar_lock, NULL);
+	if ((errno = pthread_mutex_init(&bar->bar_lock, NULL)) != 0)
+		terminate("%s: pthread_mutex_init(bar_lock)", __func__);
 #ifdef illumos
-	sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL);
+	if ((errno = sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL)) != 0)
+		terminate("%s: sema_init(bar_sem)", __func__);
 #else
-	sem_init(&bar->bar_sem, 0, 0);
+	if (sem_init(&bar->bar_sem, 0, 0) == -1)
+		terminate("%s: sem_init(bar_sem)", __func__);
 #endif
 
 	bar->bar_numin = 0;
@@ -67,14 +72,19 @@ barrier_init(barrier_t *bar, int nthread
 int
 barrier_wait(barrier_t *bar)
 {
-	pthread_mutex_lock(&bar->bar_lock);
+	if ((errno = pthread_mutex_lock(&bar->bar_lock)) != 0)
+		terminate("%s: pthread_mutex_lock(bar_lock)", __func__);
 
 	if (++bar->bar_numin < bar->bar_nthr) {
-		pthread_mutex_unlock(&bar->bar_lock);
+		if ((errno = pthread_mutex_unlock(&bar->bar_lock)) != 0)
+			terminate("%s: pthread_mutex_unlock(bar_lock)",
+			__func__);
 #ifdef illumos
-		sema_wait(&bar->bar_sem);
+		if ((errno = sema_wait(&bar->bar_sem)) != 0)
+			terminate("%s: sema_wait(bar_sem)", __func__);
 #else
-		sem_wait(&bar->bar_sem);
+		if (sem_wait(&bar->bar_sem) == -1)
+			terminate("%s: sem_wait(bar_sem)", __func__);
 #endif
 
 		return (0);
@@ -86,11 +96,15 @@ barrier_wait(barrier_t *bar)
 		bar->bar_numin = 0;
 		for (i = 1; i < bar->bar_nthr; i++)
 #ifdef illumos
-			sema_post(&bar->bar_sem);
+			if ((errno = sema_post(&bar->bar_sem)) != 0)
+terminate("%s: sema_post(bar_sem)", __func__);
 #else
-			sem_post(&bar->bar_sem);
+			if (sem_post(&bar->bar_sem) == -1)
+terminate("%s: sem_post(bar_sem)", __func__);
 #endif
-		pthread_mutex_unlock(&bar->bar_lock);
+		if ((errno = pthread_mutex_unlock(&bar->bar_lock)) != 0)
+			terminate("%s: pthread_mutex_unlock(bar_lock)",
+			__func__);
 
 		return (1);
 	}

Index: src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c
diff -u src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c:1.17 src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c:1.18
--- src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c:1.17	Sun Oct 13 21:32:07 2019
+++ src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c	Tue May 23 18:54:58 2023
@@ -373,22 +373,31 @@ init_phase_two(workqueue_t *wq)
 static void
 wip_save_work(workqueue_t *wq, wip_t *slot, int slotnum)
 {
-	pthread_mutex_lock(&wq->wq_donequeue_lock);
-
-	while (wq->wq_lastdonebatch + 1 < slot->wip_batchid)
-		pthread_cond_wait(&slot->wip_cv, &wq->wq_donequeue_lock);
+	if ((errno = pthread_mutex_lock(&wq->wq_donequeue_lock)) != 0)
+		terminate("%s: pthread_mutex_lock(wq_donequeue_lock)",
+		__func__);
+
+	while (wq->wq_lastdonebatch + 1 < slot->wip_batchid) {
+		if ((errno = pthread_cond_wait(&slot->wip_cv, &wq->wq_donequeue_lock)) != 0)
+			terminate("%s: pthread_cond_wait(wip_cv,wq_donequeue_lock)",
+			__func__);
+	}
 	assert(wq->wq_lastdonebatch + 1 == slot->wip_batchid);
 
 	fifo_add(wq->wq_donequeue, slot->wip_td);
 	wq->wq_lastdonebatch++;
-	pthread_cond_signal(&wq->wq_wip[(slotnum + 1) %
-	wq->wq_nwipslots].wip_cv);
+	const int nextslot = (slotnum + 1) % wq->wq_nwipslots;
+	if ((errno = pthread_cond_signal(&wq->wq_wip[nextslot].wip_cv)) != 0)
+		terminate("%s: pthread_cond_signal(wq_wip[%d].wip_cv)",
+		__func__, nextslot);
 
 	/* reset the slot for next use */
 	slot->wip_td = NULL;
 	slot->wip_batchi

CVS commit: src/external/cddl/osnet/dist/tools/ctf/cvt

2023-05-23 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Tue May 23 18:54:58 UTC 2023

Modified Files:
src/external/cddl/osnet/dist/tools/ctf/cvt: barrier.c ctfmerge.c
tdata.c

Log Message:
ctfmerge: error check sem_*() and pthread_*() APIs

terminate() if sem_*() returns -1 or pthread_*() returns != 0.
(Set errno from pthread_*() so terminate() prints the strerror message).

Note: Failing on errors instead of ignoring them helps identify
reasons for intermittent failures, such as those on macOS host builds:
  ERROR: nbctfmerge: barrier_init: sem_init(bar_sem): Function not implemented


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c
cvs rdiff -u -r1.17 -r1.18 \
src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/dist/tools/ctf/cvt/tdata.c

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



CVS commit: src/usr.bin/indent

2023-05-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May 23 18:16:28 UTC 2023

Modified Files:
src/usr.bin/indent: indent.c io.c lexi.c

Log Message:
indent: separate code for handling enums from the lexer

The lexer's responsibility is to generate tokens, it's not supposed to
update the parser state.  Centralize the state transitions that control
indentation of enum constants to keep the lexer code clean.

Skip comments, newlines and preprocessing lines when updating the parser
state for enum constants and for '*' in declarations.


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/indent/io.c
cvs rdiff -u -r1.205 -r1.206 src/usr.bin/indent/lexi.c

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

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.309 src/usr.bin/indent/indent.c:1.310
--- src/usr.bin/indent/indent.c:1.309	Tue May 23 16:53:57 2023
+++ src/usr.bin/indent/indent.c	Tue May 23 18:16:28 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.309 2023/05/23 16:53:57 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.310 2023/05/23 18:16:28 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.309 2023/05/23 16:53:57 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.310 2023/05/23 18:16:28 rillig Exp $");
 
 #include 
 #include 
@@ -372,6 +372,36 @@ update_ps_decl_ptr(lexer_symbol lsym)
 	}
 }
 
+static void
+update_ps_in_enum(lexer_symbol lsym)
+{
+	switch (ps.in_enum) {
+	case in_enum_no:
+		if (lsym == lsym_tag && token.st[0] == 'e')
+			ps.in_enum = in_enum_enum;
+		break;
+	case in_enum_enum:
+		if (lsym == lsym_type_outside_parentheses
+		|| lsym == lsym_type_in_parentheses)
+			ps.in_enum = in_enum_type;
+		else if (lsym == lsym_lbrace)
+			ps.in_enum = in_enum_brace;
+		else
+			ps.in_enum = in_enum_no;
+		break;
+	case in_enum_type:
+		if (lsym == lsym_lbrace)
+			ps.in_enum = in_enum_brace;
+		else
+			ps.in_enum = in_enum_no;
+		break;
+	case in_enum_brace:
+		if (lsym == lsym_rbrace)
+			ps.in_enum = in_enum_no;
+		break;
+	}
+}
+
 static int
 process_eof(void)
 {
@@ -1166,7 +1196,9 @@ indent(void)
 
 		if (lsym == lsym_newline || lsym == lsym_preprocessing)
 			ps.force_nl = false;
-		else if (lsym != lsym_comment) {
+		else if (lsym == lsym_comment) {
+			/* no special processing */
+		} else {
 			maybe_break_line(lsym);
 			/*
 			 * Add an extra level of indentation; turned off again
@@ -1175,10 +1207,10 @@ indent(void)
 			ps.in_stmt_or_decl = true;
 			if (com.len > 0)
 move_com_to_code(lsym);
+			update_ps_decl_ptr(lsym);
+			update_ps_in_enum(lsym);
 		}
 
-		update_ps_decl_ptr(lsym);
-
 		process_lsym(lsym);
 
 		debug_parser_state();

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.186 src/usr.bin/indent/io.c:1.187
--- src/usr.bin/indent/io.c:1.186	Tue May 23 12:12:29 2023
+++ src/usr.bin/indent/io.c	Tue May 23 18:16:28 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.186 2023/05/23 12:12:29 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.187 2023/05/23 18:16:28 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: io.c,v 1.186 2023/05/23 12:12:29 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.187 2023/05/23 18:16:28 rillig Exp $");
 
 #include 
 
@@ -350,7 +350,9 @@ compute_code_indent(void)
 	int base_ind = ps.ind_level * opt.indent_size;
 
 	if (ps.line_start_nparen == 0) {
-		if (ps.in_stmt_cont && ps.in_enum != in_enum_brace)
+		if (ps.in_enum == in_enum_brace)
+			return base_ind;
+		if (ps.in_stmt_cont)
 			return base_ind + opt.continuation_indent;
 		return base_ind;
 	}

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.205 src/usr.bin/indent/lexi.c:1.206
--- src/usr.bin/indent/lexi.c:1.205	Tue May 23 12:12:29 2023
+++ src/usr.bin/indent/lexi.c	Tue May 23 18:16:28 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.205 2023/05/23 12:12:29 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.206 2023/05/23 18:16:28 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: lexi.c,v 1.205 2023/05/23 12:12:29 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.206 2023/05/23 18:16:28 rillig Exp $");
 
 #include 
 #include 
@@ -396,8 +396,6 @@ lexi_alnum(void)
 	if (is_typename()) {
 		lsym = lsym_type_in_parentheses;
 		ps.next_unary = true;
-		if (ps.in_enum == in_enum_enum)
-			ps.in_enum = in_enum_type;
 found_typename:
 		if (ps.nparen > 0) {
 			/* inside parentheses: cast, param list, offsetof or
@@ -407,11 +405,8 @@ found_typename:
 		}
 		if (ps.prev_token != lsym_period
 		&& ps.prev_token != lsym_unary_op) {
-			if (kw != NULL && kw->lsym == lsym_tag) {
-if (token.st[0] == 'e' /* enum */)
-	ps.in_enum = in_enum_enum;
+			if (kw != NULL && kw->lsym == lsym_tag)
 

CVS commit: src/usr.bin/indent

2023-05-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May 23 18:16:28 UTC 2023

Modified Files:
src/usr.bin/indent: indent.c io.c lexi.c

Log Message:
indent: separate code for handling enums from the lexer

The lexer's responsibility is to generate tokens, it's not supposed to
update the parser state.  Centralize the state transitions that control
indentation of enum constants to keep the lexer code clean.

Skip comments, newlines and preprocessing lines when updating the parser
state for enum constants and for '*' in declarations.


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/indent/io.c
cvs rdiff -u -r1.205 -r1.206 src/usr.bin/indent/lexi.c

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



CVS commit: src

2023-05-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May 23 16:53:57 UTC 2023

Modified Files:
src/tests/usr.bin/indent: fmt_decl.c
src/usr.bin/indent: debug.c indent.c

Log Message:
indent: fix indentation of struct declarations


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.308 -r1.309 src/usr.bin/indent/indent.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/usr.bin/indent/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.45 src/tests/usr.bin/indent/fmt_decl.c:1.46
--- src/tests/usr.bin/indent/fmt_decl.c:1.45	Tue May 23 06:43:19 2023
+++ src/tests/usr.bin/indent/fmt_decl.c	Tue May 23 16:53:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmt_decl.c,v 1.45 2023/05/23 06:43:19 rillig Exp $	*/
+/*	$NetBSD: fmt_decl.c,v 1.46 2023/05/23 16:53:57 rillig Exp $	*/
 
 /*
  * Tests for declarations of global variables, external functions, and local
@@ -602,7 +602,8 @@ ToToken(bool cond)
 
 
 /*
- * Indent gets easily confused by unknown type names in struct declarations.
+ * Before indent.c 1.309 from 2023-05-23, indent easily got confused by unknown
+ * type names in struct declarations, as a ';' did not finish a declaration.
  */
 //indent input
 typedef struct OpenDirs {
@@ -611,20 +612,14 @@ typedef struct OpenDirs {
 }		OpenDirs;
 //indent end
 
-/* FIXME: The word 'HashTable' must not be aligned like a member name. */
-//indent run
-typedef struct OpenDirs {
-	CachedDirList	list;
-			HashTable /* of CachedDirListNode */ table;
-}		OpenDirs;
-//indent end
-
 //indent run-equals-input -THashTable
 
+//indent run-equals-input
+
 
 /*
- * Indent gets easily confused by unknown type names, even in declarations
- * that are syntactically unambiguous.
+ * Before lexi.c 1.153 from 2021-11-25, indent easily got confused by unknown
+ * type names, even in declarations that are syntactically unambiguous.
  */
 //indent input
 static CachedDir *dot = NULL;
@@ -632,14 +627,12 @@ static CachedDir *dot = NULL;
 
 //indent run-equals-input -TCachedDir
 
-/* Since lexi.c 1.153 from 2021-11-25. */
 //indent run-equals-input
 
 
 /*
- * Before lexi.c 1.156 from 2021-11-25, indent easily got confused by unknown
- * type names in declarations and generated 'HashEntry * he' with an extra
- * space.
+ * Before lexi.c 1.153 from 2021-11-25, indent easily got confused by unknown
+ * type names in declarations.
  */
 //indent input
 static CachedDir *
@@ -648,7 +641,6 @@ CachedDir_New(const char *name)
 }
 //indent end
 
-/* Since lexi.c 1.153 from 2021-11-25. */
 //indent run-equals-input
 
 
@@ -697,15 +689,15 @@ CachedDir_Assign(CachedDir **var, Cached
 }
 //indent end
 
-//indent run-equals-input
-
 //indent run-equals-input -TCachedDir
 
+//indent run-equals-input
+
 
 /*
  * Before lexi.c 1.153 from 2021-11-25, all initializer expressions after the
- * first one were indented as if they would be statement continuations. This
- * was because the token 'Shell' was identified as a word, not as a type name.
+ * first one were indented as if they were statement continuations. This was
+ * caused by the token 'Shell' being identified as a word, not as a type name.
  */
 //indent input
 static Shell	shells[] = {
@@ -716,7 +708,6 @@ static Shell	shells[] = {
 };
 //indent end
 
-/* Since lexi.c 1.153 from 2021-11-25. */
 //indent run-equals-input
 
 
@@ -963,22 +954,6 @@ ch_isalpha(char ch)
 
 
 //indent input
-struct {
-	void *list;
-	Table /* comment */ table;
-} var;
-//indent end
-
-//indent run -di0
-struct {
-	void *list;
-// $ FIXME: Wrong indentation, as 'Table' starts a new declaration.
-	 Table /* comment */ table;
-} var;
-//indent end
-
-
-//indent input
 void __printflike(1, 2)
 debug_printf(const char *fmt, ...)
 {

Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.22 src/usr.bin/indent/debug.c:1.23
--- src/usr.bin/indent/debug.c:1.22	Tue May 23 12:12:29 2023
+++ src/usr.bin/indent/debug.c	Tue May 23 16:53:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.22 2023/05/23 12:12:29 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.23 2023/05/23 16:53:57 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.22 2023/05/23 12:12:29 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.23 2023/05/23 16:53:57 rillig Exp $");
 
 #include 
 
@@ -134,7 +134,7 @@ static const char *const decl_ptr_name[]
 	"other",
 };
 
-static unsigned wrote_newlines;
+static unsigned wrote_newlines = 1;
 
 void
 debug_printf(const char *fmt, ...)

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.308 src/usr.bin/indent/indent.c:1.309
--- src/usr.bin/indent/indent.c:1.308	Tue May 23 12:12:29 2023
+++ src/usr.bin/indent/indent.c	Tue May 23 16:53:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1

CVS commit: src

2023-05-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May 23 16:53:57 UTC 2023

Modified Files:
src/tests/usr.bin/indent: fmt_decl.c
src/usr.bin/indent: debug.c indent.c

Log Message:
indent: fix indentation of struct declarations


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.308 -r1.309 src/usr.bin/indent/indent.c

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



CVS commit: src/usr.bin/indent

2023-05-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May 23 12:12:29 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c parse.c

Log Message:
indent: split debug output into paragraphs

The paragraphs separate the different processing steps: getting a token
from the lexer, processing the token, updating the parser state, sending
a finished line to the output.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.307 -r1.308 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.158 -r1.159 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.185 -r1.186 src/usr.bin/indent/io.c
cvs rdiff -u -r1.204 -r1.205 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/indent/parse.c

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



CVS commit: src/usr.bin/indent

2023-05-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May 23 12:12:29 UTC 2023

Modified Files:
src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c parse.c

Log Message:
indent: split debug output into paragraphs

The paragraphs separate the different processing steps: getting a token
from the lexer, processing the token, updating the parser state, sending
a finished line to the output.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.307 -r1.308 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.158 -r1.159 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.185 -r1.186 src/usr.bin/indent/io.c
cvs rdiff -u -r1.204 -r1.205 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/indent/parse.c

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

Modified files:

Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.21 src/usr.bin/indent/debug.c:1.22
--- src/usr.bin/indent/debug.c:1.21	Tue May 23 06:35:01 2023
+++ src/usr.bin/indent/debug.c	Tue May 23 12:12:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.21 2023/05/23 06:35:01 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.22 2023/05/23 12:12:29 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: debug.c,v 1.21 2023/05/23 06:35:01 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.22 2023/05/23 12:12:29 rillig Exp $");
 
 #include 
 
@@ -134,6 +134,8 @@ static const char *const decl_ptr_name[]
 	"other",
 };
 
+static unsigned wrote_newlines;
+
 void
 debug_printf(const char *fmt, ...)
 {
@@ -143,6 +145,7 @@ debug_printf(const char *fmt, ...)
 	va_start(ap, fmt);
 	vfprintf(f, fmt, ap);
 	va_end(ap);
+	wrote_newlines = 0;
 }
 
 void
@@ -155,6 +158,14 @@ debug_println(const char *fmt, ...)
 	vfprintf(f, fmt, ap);
 	va_end(ap);
 	fprintf(f, "\n");
+	wrote_newlines = fmt[0] == '\0' ? wrote_newlines + 1 : 1;
+}
+
+void
+debug_blank_line(void)
+{
+	while (wrote_newlines < 2)
+		debug_println("");
 }
 
 void
@@ -182,26 +193,19 @@ static void
 debug_print_buf(const char *name, const struct buffer *buf)
 {
 	if (buf->len > 0) {
-		debug_printf("%s ", name);
-		debug_vis_range("\"", buf->st, buf->len, "\"\n");
+		debug_printf(" %s ", name);
+		debug_vis_range("\"", buf->st, buf->len, "\"");
 	}
 }
 
 void
 debug_buffers(void)
 {
-	if (lab.len > 0) {
-		debug_printf(" label ");
-		debug_vis_range("\"", lab.st, lab.len, "\"");
-	}
-	if (code.len > 0) {
-		debug_printf(" code ");
-		debug_vis_range("\"", code.st, code.len, "\"");
-	}
-	if (com.len > 0) {
-		debug_printf(" comment ");
-		debug_vis_range("\"", com.st, com.len, "\"");
-	}
+	debug_print_buf("token", &token);
+	debug_print_buf("label", &lab);
+	debug_print_buf("code", &code);
+	debug_print_buf("comment", &com);
+	debug_println("");
 }
 
 #define debug_ps_bool(name) \
@@ -280,18 +284,11 @@ debug_ps_di_stack(const struct parser_st
 }
 
 void
-debug_parser_state(lexer_symbol lsym)
+debug_parser_state(void)
 {
 	static struct parser_state prev_ps;
 
-	debug_println("");
-	debug_printf("line %d: %s", line_no, lsym_name[lsym]);
-	debug_vis_range(" \"", token.st, token.len, "\"\n");
-
-	debug_print_buf("label", &lab);
-	debug_print_buf("code", &code);
-	debug_print_buf("comment", &com);
-
+	debug_blank_line();
 	debug_println("   ps.prev_token = %s",
 	lsym_name[ps.prev_token]);
 	debug_ps_bool(curr_col_1);
@@ -337,6 +334,7 @@ debug_parser_state(lexer_symbol lsym)
 
 	debug_ps_enum(spaced_expr_psym, psym_name);
 	debug_ps_int(quest_level);
+	debug_blank_line();
 
 	prev_ps = ps;
 }

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.307 src/usr.bin/indent/indent.c:1.308
--- src/usr.bin/indent/indent.c:1.307	Tue May 23 11:37:23 2023
+++ src/usr.bin/indent/indent.c	Tue May 23 12:12:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.307 2023/05/23 11:37:23 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.308 2023/05/23 12:12:29 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.307 2023/05/23 11:37:23 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.308 2023/05/23 12:12:29 rillig Exp $");
 
 #include 
 #include 
@@ -1146,9 +1146,16 @@ process_lsym(lexer_symbol lsym)
 static int
 indent(void)
 {
+	debug_parser_state();
+
 	for (;;) {		/* loop until we reach eof */
 		lexer_symbol lsym = lexi();
 
+		debug_blank_line();
+		debug_printf("line %d: %s", line_no, lsym_name[lsym]);
+		debug_buffers();
+		debug_blank_line();
+
 		if (lsym == lsym_eof)
 			return process_eof();
 
@@ -1173,6 +1180,8 @@ indent(void)
 
 		process_lsym(lsym);
 
+		debug_parser_state();
+
 		if (lsym != lsym_comment && lsym != lsym_newline &&
 		lsym != lsym_preprocessing)
 			ps.prev_token = lsym;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.158 src/usr.bin/indent/indent.h:1.159
--- src/usr.

CVS commit: src/crypto

2023-05-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue May 23 12:05:10 UTC 2023

Modified Files:
src/crypto: Makefile.openssl

Log Message:
centralize the warnings, try to fix clang


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/crypto/Makefile.openssl

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



CVS commit: src/crypto

2023-05-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue May 23 12:05:10 UTC 2023

Modified Files:
src/crypto: Makefile.openssl

Log Message:
centralize the warnings, try to fix clang


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/crypto/Makefile.openssl

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

Modified files:

Index: src/crypto/Makefile.openssl
diff -u src/crypto/Makefile.openssl:1.15 src/crypto/Makefile.openssl:1.16
--- src/crypto/Makefile.openssl:1.15	Thu May 18 08:01:58 2023
+++ src/crypto/Makefile.openssl	Tue May 23 08:05:10 2023
@@ -1,15 +1,32 @@
-#	$NetBSD: Makefile.openssl,v 1.15 2023/05/18 12:01:58 martin Exp $
+#	$NetBSD: Makefile.openssl,v 1.16 2023/05/23 12:05:10 christos Exp $
 
 .ifndef _MAKEFILE_OPENSSL_INCLUDED
 _MAKEFILE_OPENSSL_INCLUDED=1
 
 .include 
 WARNS=3
+
 # would require changing a lot of code
-COPTS+= -Wno-error=cast-qual -Wno-error=discarded-qualifiers
+COPTS+= -Wno-error=cast-qual
 COPTS+= -Wno-error=missing-field-initializers -Wno-error=char-subscripts
 COPTS+= -Wno-error=shadow
 
+CWARNFLAGS.gcc+= -Wno-error=discarded-qualifiers
+CWARNFLAGS.clang+= -Wno-error=ignored-qualifiers
+
+# XXX: re-examine the below
+CWARNFLAGS.clang+= -Wno-empty-body -Wno-unused-value -Wno-parentheses
+CWARNFLAGS.clang+= -Wno-implicit-int-float-conversion
+# XXX: This warning seems to trigger incorrectly
+CWARNFLAGS.clang+=	-Wno-atomic-alignment
+
+LINTFLAGS+=	-X 161	# constant in conditional context
+LINTFLAGS+=	-X 129	# expression has null effect
+LINTFLAGS+=	-X 117	# bitwise '>>' on signed value possibly nonportable
+LINTFLAGS+=	-X 231	# argument '%s' unused in function '%s'
+LINTFLAGS+=	-X 220	# fallthrough on case statement
+LINTFLAGS+=	-X 118	# semantics of '%s' change in ANSI C; use explicit cast
+
 
 .if ${HAVE_OPENSSL} <= 11
 OSSL_ENGINESDIR=/usr/lib/openssl



CVS commit: src/crypto/external/bsd/openssl/lib

2023-05-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue May 23 12:04:42 UTC 2023

Modified Files:
src/crypto/external/bsd/openssl/lib/libapps: Makefile
src/crypto/external/bsd/openssl/lib/libcommon: Makefile
src/crypto/external/bsd/openssl/lib/libcrypto: Makefile
src/crypto/external/bsd/openssl/lib/libdefault: Makefile
src/crypto/external/bsd/openssl/lib/liblegacy: Makefile

Log Message:
centralie warnings


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/crypto/external/bsd/openssl/lib/libapps/Makefile
cvs rdiff -u -r1.3 -r1.4 \
src/crypto/external/bsd/openssl/lib/libcommon/Makefile
cvs rdiff -u -r1.28 -r1.29 \
src/crypto/external/bsd/openssl/lib/libcrypto/Makefile
cvs rdiff -u -r1.4 -r1.5 \
src/crypto/external/bsd/openssl/lib/libdefault/Makefile
cvs rdiff -u -r1.5 -r1.6 \
src/crypto/external/bsd/openssl/lib/liblegacy/Makefile

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

Modified files:

Index: src/crypto/external/bsd/openssl/lib/libapps/Makefile
diff -u src/crypto/external/bsd/openssl/lib/libapps/Makefile:1.2 src/crypto/external/bsd/openssl/lib/libapps/Makefile:1.3
--- src/crypto/external/bsd/openssl/lib/libapps/Makefile:1.2	Wed May 17 15:09:41 2023
+++ src/crypto/external/bsd/openssl/lib/libapps/Makefile	Tue May 23 08:04:42 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2023/05/17 19:09:41 christos Exp $
+#	$NetBSD: Makefile,v 1.3 2023/05/23 12:04:42 christos Exp $
 
 # RCSid:
 #	Id: Makefile,v 1.33 1998/11/11 11:53:53 sjg Exp
@@ -25,17 +25,6 @@ USE_FIPS=	no
 .include 
 .include 
 
-CWARNFLAGS.clang+=	-Wno-empty-body -Wno-unused-value -Wno-parentheses -Wno-implicit-int-float-conversion
-# XXX: This warning seems to trigger incorrectly
-CWARNFLAGS.clang+=	-Wno-atomic-alignment
-
-LINTFLAGS+=	-X 161	# constant in conditional context
-LINTFLAGS+=	-X 129	# expression has null effect
-LINTFLAGS+=	-X 117	# bitwise '>>' on signed value possibly nonportable
-LINTFLAGS+=	-X 231	# argument '%s' unused in function '%s'
-LINTFLAGS+=	-X 220	# fallthrough on case statement
-LINTFLAGS+=	-X 118	# semantics of '%s' change in ANSI C; use explicit cast
-
 CPPFLAGS+= -Dlib${LIB} -I. -I${OPENSSLSRC}/crypto -I${OPENSSLSRC} -I${.CURDIR}
 CPPFLAGS+= -I${OPENSSLSRC}/include -I${OPENSSLSRC}/crypto/include
 CPPFLAGS+= -I${OPENSSLSRC}/crypto/asn1 -I${OPENSSLSRC}/crypto/evp

Index: src/crypto/external/bsd/openssl/lib/libcommon/Makefile
diff -u src/crypto/external/bsd/openssl/lib/libcommon/Makefile:1.3 src/crypto/external/bsd/openssl/lib/libcommon/Makefile:1.4
--- src/crypto/external/bsd/openssl/lib/libcommon/Makefile:1.3	Wed May 17 15:09:41 2023
+++ src/crypto/external/bsd/openssl/lib/libcommon/Makefile	Tue May 23 08:04:42 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2023/05/17 19:09:41 christos Exp $
+#	$NetBSD: Makefile,v 1.4 2023/05/23 12:04:42 christos Exp $
 
 # RCSid:
 #	Id: Makefile,v 1.33 1998/11/11 11:53:53 sjg Exp
@@ -25,17 +25,6 @@ USE_FIPS=	no
 .include 
 .include 
 
-CWARNFLAGS.clang+=	-Wno-empty-body -Wno-unused-value -Wno-parentheses -Wno-implicit-int-float-conversion
-# XXX: This warning seems to trigger incorrectly
-CWARNFLAGS.clang+=	-Wno-atomic-alignment
-
-LINTFLAGS+=	-X 161	# constant in conditional context
-LINTFLAGS+=	-X 129	# expression has null effect
-LINTFLAGS+=	-X 117	# bitwise '>>' on signed value possibly nonportable
-LINTFLAGS+=	-X 231	# argument '%s' unused in function '%s'
-LINTFLAGS+=	-X 220	# fallthrough on case statement
-LINTFLAGS+=	-X 118	# semantics of '%s' change in ANSI C; use explicit cast
-
 CPPFLAGS+= -Dlib${LIB} -I. -I${OPENSSLSRC}/crypto -I${OPENSSLSRC} -I${.CURDIR}
 CPPFLAGS+= -I${OPENSSLSRC}/include -I${OPENSSLSRC}/crypto/include
 CPPFLAGS+= -I${OPENSSLSRC}/crypto/asn1 -I${OPENSSLSRC}/crypto/evp

Index: src/crypto/external/bsd/openssl/lib/libcrypto/Makefile
diff -u src/crypto/external/bsd/openssl/lib/libcrypto/Makefile:1.28 src/crypto/external/bsd/openssl/lib/libcrypto/Makefile:1.29
--- src/crypto/external/bsd/openssl/lib/libcrypto/Makefile:1.28	Wed May 17 15:09:41 2023
+++ src/crypto/external/bsd/openssl/lib/libcrypto/Makefile	Tue May 23 08:04:42 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.28 2023/05/17 19:09:41 christos Exp $
+#	$NetBSD: Makefile,v 1.29 2023/05/23 12:04:42 christos Exp $
 
 # RCSid:
 #	Id: Makefile,v 1.33 1998/11/11 11:53:53 sjg Exp
@@ -25,27 +25,12 @@ USE_FIPS=	no
 .include 
 .include 
 
-COPTS+= -Wno-error=cast-qual -Wno-error=discarded-qualifiers
-COPTS+= -Wno-error=missing-field-initializers -Wno-error=char-subscripts
-CWARNFLAGS.clang+=	-Wno-empty-body -Wno-unused-value -Wno-parentheses -Wno-implicit-int-float-conversion
-# XXX: This warning seems to trigger incorrectly
-CWARNFLAGS.clang+=	-Wno-atomic-alignment
-
-LINTFLAGS+=	-X 161	# constant in conditional context
-LINTFLAGS+=	-X 129	# expression has null effect
-LINTFLAGS+=	-X 117	# bitwise '>>' on signed value possibly nonportable
-LINTFLAGS+=	-X 231	# ar

CVS commit: src/crypto/external/bsd/openssl/lib

2023-05-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue May 23 12:04:42 UTC 2023

Modified Files:
src/crypto/external/bsd/openssl/lib/libapps: Makefile
src/crypto/external/bsd/openssl/lib/libcommon: Makefile
src/crypto/external/bsd/openssl/lib/libcrypto: Makefile
src/crypto/external/bsd/openssl/lib/libdefault: Makefile
src/crypto/external/bsd/openssl/lib/liblegacy: Makefile

Log Message:
centralie warnings


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/crypto/external/bsd/openssl/lib/libapps/Makefile
cvs rdiff -u -r1.3 -r1.4 \
src/crypto/external/bsd/openssl/lib/libcommon/Makefile
cvs rdiff -u -r1.28 -r1.29 \
src/crypto/external/bsd/openssl/lib/libcrypto/Makefile
cvs rdiff -u -r1.4 -r1.5 \
src/crypto/external/bsd/openssl/lib/libdefault/Makefile
cvs rdiff -u -r1.5 -r1.6 \
src/crypto/external/bsd/openssl/lib/liblegacy/Makefile

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



CVS commit: src/usr.bin/indent

2023-05-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May 23 11:37:23 UTC 2023

Modified Files:
src/usr.bin/indent: indent.c

Log Message:
indent: extract processing of a single token to separate function

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.306 -r1.307 src/usr.bin/indent/indent.c

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

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.306 src/usr.bin/indent/indent.c:1.307
--- src/usr.bin/indent/indent.c:1.306	Tue May 23 06:43:19 2023
+++ src/usr.bin/indent/indent.c	Tue May 23 11:37:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.306 2023/05/23 06:43:19 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.307 2023/05/23 11:37:23 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: indent.c,v 1.306 2023/05/23 06:43:19 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.307 2023/05/23 11:37:23 rillig Exp $");
 
 #include 
 #include 
@@ -1018,6 +1018,131 @@ process_preprocessing(void)
 	 * to be printed */
 }
 
+static void
+process_lsym(lexer_symbol lsym)
+{
+	switch (lsym) {
+
+	case lsym_newline:
+		process_newline();
+		break;
+
+	case lsym_lparen_or_lbracket:
+		process_lparen_or_lbracket();
+		break;
+
+	case lsym_rparen_or_rbracket:
+		process_rparen_or_rbracket();
+		break;
+
+	case lsym_unary_op:
+		process_unary_op();
+		break;
+
+	case lsym_binary_op:
+		process_binary_op();
+		break;
+
+	case lsym_postfix_op:
+		process_postfix_op();
+		break;
+
+	case lsym_question:
+		process_question();
+		break;
+
+	case lsym_case_label:
+		ps.seen_case = true;
+		goto copy_token;
+
+	case lsym_colon:
+		process_colon();
+		break;
+
+	case lsym_semicolon:
+		process_semicolon();
+		break;
+
+	case lsym_lbrace:
+		process_lbrace();
+		break;
+
+	case lsym_rbrace:
+		process_rbrace();
+		break;
+
+	case lsym_switch:
+		ps.spaced_expr_psym = psym_switch_expr;
+		goto copy_token;
+
+	case lsym_for:
+		ps.spaced_expr_psym = psym_for_exprs;
+		goto copy_token;
+
+	case lsym_if:
+		ps.spaced_expr_psym = psym_if_expr;
+		goto copy_token;
+
+	case lsym_while:
+		ps.spaced_expr_psym = psym_while_expr;
+		goto copy_token;
+
+	case lsym_do:
+		process_do();
+		goto copy_token;
+
+	case lsym_else:
+		process_else();
+		goto copy_token;
+
+	case lsym_typedef:
+	case lsym_storage_class:
+		goto copy_token;
+
+	case lsym_tag:
+		if (ps.nparen > 0)
+			goto copy_token;
+		/* FALLTHROUGH */
+	case lsym_type_outside_parentheses:
+		process_type();
+		goto copy_token;
+
+	case lsym_type_in_parentheses:
+	case lsym_offsetof:
+	case lsym_sizeof:
+	case lsym_word:
+	case lsym_funcname:
+	case lsym_return:
+		process_ident(lsym);
+	copy_token:
+		if (ps.want_blank)
+			buf_add_char(&code, ' ');
+		buf_add_buf(&code, &token);
+		if (lsym != lsym_funcname)
+			ps.want_blank = true;
+		break;
+
+	case lsym_period:
+		process_period();
+		break;
+
+	case lsym_comma:
+		process_comma();
+		break;
+
+	case lsym_preprocessing:
+		process_preprocessing();
+		break;
+
+	case lsym_comment:
+		process_comment();
+		break;
+
+	default:
+		break;
+	}
+}
+
 static int
 indent(void)
 {
@@ -1046,126 +1171,7 @@ indent(void)
 
 		update_ps_decl_ptr(lsym);
 
-		switch (lsym) {
-
-		case lsym_newline:
-			process_newline();
-			break;
-
-		case lsym_lparen_or_lbracket:
-			process_lparen_or_lbracket();
-			break;
-
-		case lsym_rparen_or_rbracket:
-			process_rparen_or_rbracket();
-			break;
-
-		case lsym_unary_op:
-			process_unary_op();
-			break;
-
-		case lsym_binary_op:
-			process_binary_op();
-			break;
-
-		case lsym_postfix_op:
-			process_postfix_op();
-			break;
-
-		case lsym_question:
-			process_question();
-			break;
-
-		case lsym_case_label:
-			ps.seen_case = true;
-			goto copy_token;
-
-		case lsym_colon:
-			process_colon();
-			break;
-
-		case lsym_semicolon:
-			process_semicolon();
-			break;
-
-		case lsym_lbrace:
-			process_lbrace();
-			break;
-
-		case lsym_rbrace:
-			process_rbrace();
-			break;
-
-		case lsym_switch:
-			ps.spaced_expr_psym = psym_switch_expr;
-			goto copy_token;
-
-		case lsym_for:
-			ps.spaced_expr_psym = psym_for_exprs;
-			goto copy_token;
-
-		case lsym_if:
-			ps.spaced_expr_psym = psym_if_expr;
-			goto copy_token;
-
-		case lsym_while:
-			ps.spaced_expr_psym = psym_while_expr;
-			goto copy_token;
-
-		case lsym_do:
-			process_do();
-			goto copy_token;
-
-		case lsym_else:
-			process_else();
-			goto copy_token;
-
-		case lsym_typedef:
-		case lsym_storage_class:
-			goto copy_token;
-
-		case lsym_tag:
-			if (ps.nparen > 0)
-goto copy_token;
-			/* FALLTHROUGH */
-		case lsym_type_outside_parentheses:
-			process_type();
-			goto copy_token;
-
-		case lsym_type_in_parentheses:
-		case lsym_offsetof:
-		case lsym_sizeof:
-		case lsym_word:
-		case lsym_funcname:
-		case lsym_return:
-			process_ident(lsym);
-	copy_token:
-			if (ps

CVS commit: src/usr.bin/indent

2023-05-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May 23 11:37:23 UTC 2023

Modified Files:
src/usr.bin/indent: indent.c

Log Message:
indent: extract processing of a single token to separate function

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.306 -r1.307 src/usr.bin/indent/indent.c

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



CVS commit: src/include/arpa

2023-05-23 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue May 23 10:22:42 UTC 2023

Modified Files:
src/include/arpa: nameser.h

Log Message:
s/configuratin/configuration/ in comment, from Brad Harder (bch) by email.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/include/arpa/nameser.h

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



CVS commit: src/include/arpa

2023-05-23 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue May 23 10:22:42 UTC 2023

Modified Files:
src/include/arpa: nameser.h

Log Message:
s/configuratin/configuration/ in comment, from Brad Harder (bch) by email.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/include/arpa/nameser.h

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

Modified files:

Index: src/include/arpa/nameser.h
diff -u src/include/arpa/nameser.h:1.27 src/include/arpa/nameser.h:1.28
--- src/include/arpa/nameser.h:1.27	Wed Dec  8 20:50:01 2021
+++ src/include/arpa/nameser.h	Tue May 23 10:22:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nameser.h,v 1.27 2021/12/08 20:50:01 andvar Exp $	*/
+/*	$NetBSD: nameser.h,v 1.28 2023/05/23 10:22:42 andvar Exp $	*/
 
 /*
  * Portions Copyright (C) 2004, 2005, 2008, 2009  Internet Systems Consortium, Inc. ("ISC")
@@ -343,7 +343,7 @@ typedef enum __ns_type {
 	ns_t_rrsig = 46,	/*%< RRset Signature */
 	ns_t_nsec = 47,		/*%< Negative security */
 	ns_t_dnskey = 48,	/*%< DNS Key */
-	ns_t_dhcid = 49,	/*%< Dynamic host configuratin identifier */
+	ns_t_dhcid = 49,	/*%< Dynamic host configuration identifier */
 	ns_t_nsec3 = 50,	/*%< Negative security type 3 */
 	ns_t_nsec3param = 51,	/*%< Negative security type 3 parameters */
 	ns_t_hip = 55,		/*%< Host Identity Protocol */



CVS commit: src/sys/arch/sparc/dev

2023-05-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May 23 10:20:12 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.93 src/sys/arch/sparc/dev/cgfourteen.c:1.94
--- src/sys/arch/sparc/dev/cgfourteen.c:1.93	Wed May 25 21:01:04 2022
+++ src/sys/arch/sparc/dev/cgfourteen.c	Tue May 23 10:20:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.93 2022/05/25 21:01:04 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.94 2023/05/23 10:20:12 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -168,6 +168,19 @@ static void cg14_copycols(void *, int, i
 static void cg14_erasecols(void *, int, int, int, long);
 static void cg14_copyrows(void *, int, int, int);
 static void cg14_eraserows(void *, int, int, long);
+
+/* 
+ * issue ALU instruction:
+ * sxi(OPCODE, srcA, srcB, dest, count)
+ */
+#define sxi(inst, a, b, d, cnt) sx_write(sc->sc_sx, SX_INSTRUCTIONS, inst((a), (b), (d), (cnt)))
+
+/*
+ * issue memory referencing instruction:
+ * sxm(OPCODE, address, start register, count)
+ */
+#define sxm(inst, addr, reg, count) sta((addr) & ~7, ASI_SX, inst((reg), (count), (addr) & 7))
+
 #endif /* NSX > 0 */
 
 #endif
@@ -358,7 +371,7 @@ cgfourteenattach(device_t parent, device
 		sc->sc_fbaddr, 0, 0, 0) & 0xf000;
 		aprint_normal_dev(sc->sc_dev, "using %s\n", 
 		device_xname(sc->sc_sx->sc_dev));
-		aprint_debug_dev(sc->sc_dev, "fb paddr: %08x\n",
+		aprint_normal_dev(sc->sc_dev, "fb paddr: %08x\n",
 		sc->sc_fb_paddr);
 		sx_write(sc->sc_sx, SX_PAGE_BOUND_LOWER, sc->sc_fb_paddr);
 		sx_write(sc->sc_sx, SX_PAGE_BOUND_UPPER,
@@ -379,7 +392,7 @@ cgfourteenattach(device_t parent, device
  * the last close. This kind of nonsense is needed to give screenblank
  * a fighting chance of working.
  */
-
+ 
 int
 cgfourteenopen(dev_t dev, int flags, int mode, struct lwp *l)
 {
@@ -567,8 +580,9 @@ cgfourteenmmap(dev_t dev, off_t off, int
 			0, prot, BUS_SPACE_MAP_LINEAR));
 	} else if (off >= CG14_SXIO_VOFF &&
 		   off < (CG14_SXIO_VOFF + 0x03ff)) {
+		off -= CG14_SXIO_VOFF;
 		return (bus_space_mmap(sc->sc_sx->sc_tag, 0x8LL,
-			sc->sc_fb_paddr + (off - CG14_SXIO_VOFF),
+			sc->sc_fb_paddr + off,
 			prot, BUS_SPACE_MAP_LINEAR));
 #endif
 	} else
@@ -1204,20 +1218,20 @@ cg14_rectfill(struct cgfourteen_softc *s
 		pptr = addr;
 		cnt = wi;
 		if (pre) {
-			sta(pptr & ~7, ASI_SX, SX_STBS(8, pre - 1, pptr & 7));
+			sxm(SX_STBS, pptr, 8, pre - 1);
 			pptr += pre;
 			cnt -= pre;
 		}
 		/* now do the aligned pixels in 32bit chunks */
 		while(cnt > 3) {
 			words = uimin(32, cnt >> 2);
-			sta(pptr & ~7, ASI_SX, SX_STS(8, words - 1, pptr & 7));
+			sxm(SX_STS, pptr, 8, words - 1);
 			pptr += words << 2;
 			cnt -= words << 2;
 		}
 		/* do any remaining pixels byte-wise again */
 		if (cnt > 0)
-			sta(pptr & ~7, ASI_SX, SX_STBS(8, cnt - 1, pptr & 7));
+			sxm(SX_STBS, pptr, 8, cnt - 1);
 		addr += stride;
 	}
 }
@@ -1275,28 +1289,25 @@ cg14_invert(struct cgfourteen_softc *sc,
 	for (line = 0; line < he; line++) {
 		pptr = addr;
 		/* load a whole scanline */
-		sta(pptr & ~7, ASI_SX, SX_LD(8, words - 1, pptr & 7));
+		sxm(SX_LD, pptr, 8, words - 1);
 		reg = 8;
 		if (pre) {
 			cg14_set_mask(sc, lmask);
-			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
-			SX_ROPB(8, 8, 40, 0));
+			sxi(SX_ROPB, 8, 8, 40, 0);
 			reg++;
 		}
 		if (cnt > 0) {
 			cg14_set_mask(sc, 0x);
 			/* XXX handle cnt > 16 */
-			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
-			SX_ROP(reg, reg, reg + 32, cnt - 1));
+			sxi(SX_ROP, reg, reg, reg + 32, cnt - 1);
 			reg += cnt;
 		}
 		if (post) {
 			cg14_set_mask(sc, rmask);
-			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
-			SX_ROPB(reg, 7, reg + 32, 0));
+			sxi(SX_ROPB, reg, 7, reg + 32, 0);
 			reg++;
 		}
-		sta(pptr & ~7, ASI_SX, SX_ST(40, words - 1, pptr & 7));		
+		sxm(SX_ST, pptr, 40, words - 1);		
 		addr += stride;
 	}
 }
@@ -1307,7 +1318,7 @@ cg14_slurp(int reg, uint32_t addr, int c
 	int num;
 	while (cnt > 0) {
 		num = uimin(32, cnt);
-		sta(addr & ~7, ASI_SX, SX_LD(reg, num - 1, addr & 7));
+		sxm(SX_LD, addr, reg, num - 1);
 		cnt -= num;
 		reg += num;
 		addr += (num << 2);
@@ -1320,7 +1331,7 @@ cg14_spit(int reg, uint32_t addr, int cn
 	int num;
 	while (cnt > 0) {
 		num = uimin(32, cnt);
-		sta(addr & ~7, ASI_SX, SX_ST(reg, num - 1, addr & 7));
+		sxm(SX_ST, addr, reg, num - 1);
 		cnt -= num;
 		reg += num;
 		addr += (num << 2);
@@ -1355,10 +1366,8 @@ cg14_bitblt(void *cookie, int xs, int ys
 			dptr = daddr;
 			cnt = wi;
 			if (pre > 0)

CVS commit: src/sys/arch/sparc/dev

2023-05-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May 23 10:20:12 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/kern

2023-05-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 23 08:16:43 UTC 2023

Modified Files:
src/sys/kern: subr_autoconf.c

Log Message:
autoconf(9): Omit config_detach kernel lock assertion too for now.

like in config_attach_pseudo, this assertion almost certainly
indicates real bugs, but let's try to get the tests back and running
again before addressing those.


To generate a diff of this commit:
cvs rdiff -u -r1.312 -r1.313 src/sys/kern/subr_autoconf.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/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.312 src/sys/kern/subr_autoconf.c:1.313
--- src/sys/kern/subr_autoconf.c:1.312	Tue May 23 00:31:42 2023
+++ src/sys/kern/subr_autoconf.c	Tue May 23 08:16:43 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.312 2023/05/23 00:31:42 riastradh Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.313 2023/05/23 08:16:43 riastradh Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.312 2023/05/23 00:31:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.313 2023/05/23 08:16:43 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -2319,8 +2319,6 @@ int
 config_detach(device_t dev, int flags)
 {
 
-	KASSERT(KERNEL_LOCKED_P());
-
 	device_acquire(dev);
 	return config_detach_release(dev, flags);
 }



CVS commit: src/sys/kern

2023-05-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 23 08:16:43 UTC 2023

Modified Files:
src/sys/kern: subr_autoconf.c

Log Message:
autoconf(9): Omit config_detach kernel lock assertion too for now.

like in config_attach_pseudo, this assertion almost certainly
indicates real bugs, but let's try to get the tests back and running
again before addressing those.


To generate a diff of this commit:
cvs rdiff -u -r1.312 -r1.313 src/sys/kern/subr_autoconf.c

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