CVS commit: src/sys/kern

2023-04-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Apr 17 08:14:51 UTC 2023

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/kern/subr_kobj.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_kobj.c
diff -u src/sys/kern/subr_kobj.c:1.76 src/sys/kern/subr_kobj.c:1.77
--- src/sys/kern/subr_kobj.c:1.76	Sun Jan 29 17:20:48 2023
+++ src/sys/kern/subr_kobj.c	Mon Apr 17 08:14:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_kobj.c,v 1.76 2023/01/29 17:20:48 skrll Exp $	*/
+/*	$NetBSD: subr_kobj.c,v 1.77 2023/04/17 08:14:51 skrll Exp $	*/
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.76 2023/01/29 17:20:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.77 2023/04/17 08:14:51 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_modular.h"
@@ -74,11 +74,12 @@ __KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,
 #ifdef MODULAR
 
 #include 
+
 #include 
 #include 
-#include 
 #include 
 #include 
+#include 
 
 #include 
 



CVS commit: src/sys/kern

2023-04-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Apr 17 08:14:51 UTC 2023

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/kern/subr_kobj.c

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



CVS commit: src/doc

2023-04-17 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Apr 17 10:27:38 UTC 2023

Modified Files:
src/doc: CHANGES

Log Message:
doc: Various changes in the last month.


To generate a diff of this commit:
cvs rdiff -u -r1.2959 -r1.2960 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/doc

2023-04-17 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Apr 17 10:27:38 UTC 2023

Modified Files:
src/doc: CHANGES

Log Message:
doc: Various changes in the last month.


To generate a diff of this commit:
cvs rdiff -u -r1.2959 -r1.2960 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.2959 src/doc/CHANGES:1.2960
--- src/doc/CHANGES:1.2959	Sun Apr 16 20:46:16 2023
+++ src/doc/CHANGES	Mon Apr 17 10:27:37 2023
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2959 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2960 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -62,9 +62,25 @@ Changes from NetBSD 10.0 to NetBSD 11.0:
 		in various ports. [riastradh 20230301]
 	sh(1): Adjust tilde expansion to comply with upcoming POSIX
 		Issue 8 requirements. [kre 20230306]
+	libm: Add more long double transcendental functions (as aliases of
+		double functions) from C99. [riastradh 20230313]
 	tzdata: updated to 2023a (using the 2023agtz fork) [kre 20230323]
 	tzdata: updated to 2023b (using the 2023bgtz fork) [kre 20230324]
+	xen: Allow a PVH dom0 to use VGA as console. [bouyer 20230324]
+	vioscsi(4), viornd(4), viomb(4): Mark VirtIO drivers as MPSAFE.
+		[mlelstv 20230325]
+	amiga: Fix bootblocks for Kickstart 3.2. [abs 20230325]
+	libc: Add __atomic_is_lock_free to help stdatomic.h usage with
+		GCC. [riastradh 20230330]
 	tzdata: updated to 2023c (using the 2023cgtz fork) [kre 20230331]
+	tprof(8): Add Intel Comet Lake support. [msaitoh 20230410]
+	vacation(1): Check 'Auto-Submitted:' header in addition to
+		'Precedence:', and set 'Precedence:' in addition to
+		'Auto-Submitted:'.  [hauke 20230411]
+	ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.
+		[riastradh 20230412]
+	audiorecord(1): Add support for recording 24-bit wav files.
+		[mlelstv 20230415]
 	lua: Import version 5.4.4.
 		Bumped shlib major because of incompatible API/ABI changes.
 		[nikita 20230416]



CVS commit: src/usr.sbin/tprof

2023-04-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Apr 17 07:13:36 UTC 2023

Modified Files:
src/usr.sbin/tprof: tprof.8

Log Message:
Add two note to the tprof(8)'s manual page.

 - "list" command prints the maximum number of counters that can be used
   simultaneously.
 - multiple -e arguments can be specified.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/tprof/tprof.8

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

Modified files:

Index: src/usr.sbin/tprof/tprof.8
diff -u src/usr.sbin/tprof/tprof.8:1.25 src/usr.sbin/tprof/tprof.8:1.26
--- src/usr.sbin/tprof/tprof.8:1.25	Mon Apr 10 06:08:55 2023
+++ src/usr.sbin/tprof/tprof.8	Mon Apr 17 07:13:35 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tprof.8,v 1.25 2023/04/10 06:08:55 msaitoh Exp $
+.\"	$NetBSD: tprof.8,v 1.26 2023/04/17 07:13:35 msaitoh Exp $
 .\"
 .\" Copyright (c)2011 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 10, 2023
+.Dd April 17, 2023
 .Dt TPROF 8
 .Os
 .Sh NAME
@@ -63,7 +63,13 @@ specifies the action to take.
 Valid actions are:
 .Bl -tag -width offline -offset indent
 .It list
-Display a list of performance counter events available on the system.
+Display the following information:
+.Bl -bullet -compact
+.It
+a list of performance counter events available on the system
+.It
+the maximum number of counters that can be used simultaneously
+.El
 .It monitor Xo
 .Fl e
 .Ar name[:option][,scale]
@@ -82,6 +88,9 @@ specifies the source of the event; it mu
 (userland) and
 .Ar k
 (kernel). If omitted, it is assumed that both are specified.
+Multiple
+.Fl e
+arguments can be specified.
 The collected samples are written into the file
 .Ar scale
 specifies the ratio of the speed to the cycle counter, or the counter until



CVS commit: src/usr.sbin/tprof

2023-04-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Apr 17 07:13:36 UTC 2023

Modified Files:
src/usr.sbin/tprof: tprof.8

Log Message:
Add two note to the tprof(8)'s manual page.

 - "list" command prints the maximum number of counters that can be used
   simultaneously.
 - multiple -e arguments can be specified.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/tprof/tprof.8

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



CVS commit: src/sys/arch/powerpc/booke

2023-04-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Apr 17 06:48:07 UTC 2023

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/powerpc/booke/trap.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/powerpc/booke

2023-04-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Apr 17 06:48:07 UTC 2023

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.39 src/sys/arch/powerpc/booke/trap.c:1.40
--- src/sys/arch/powerpc/booke/trap.c:1.39	Wed Oct 26 07:35:20 2022
+++ src/sys/arch/powerpc/booke/trap.c	Mon Apr 17 06:48:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.39 2022/10/26 07:35:20 skrll Exp $	*/
+/*	$NetBSD: trap.c,v 1.40 2023/04/17 06:48:07 skrll Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.39 2022/10/26 07:35:20 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.40 2023/04/17 06:48:07 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -300,7 +300,7 @@ isi_exception(struct trapframe *tf, ksig
 		if (VM_PAGEMD_EXECPAGE_P(mdpg))
 			UVMHIST_LOG(pmapexechist,
 			"srr0=%#x pg=%p (pa %#"PRIxPADDR"): "
-			"no syncicache (already execpage)", 
+			"no syncicache (already execpage)",
 			tf->tf_srr0, (uintptr_t)pg, pa, 0);
 		else
 			UVMHIST_LOG(pmapexechist,
@@ -459,7 +459,7 @@ pgm_exception(struct trapframe *tf, ksig
 
 	UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmapexechist);
 
-	UVMHIST_LOG(pmapexechist, " srr0/1=%#x/%#x esr=%#x pte=%#x", 
+	UVMHIST_LOG(pmapexechist, " srr0/1=%#x/%#x esr=%#x pte=%#x",
 	tf->tf_srr0, tf->tf_srr1, tf->tf_esr,
 	*trap_pte_lookup(tf, trunc_page(tf->tf_srr0), PSL_IS));
 



CVS commit: src/external/cddl/osnet/dev/dtrace/aarch64

2023-04-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Apr 17 06:57:02 UTC 2023

Modified Files:
src/external/cddl/osnet/dev/dtrace/aarch64: dtrace_subr.c

Log Message:
(missed in pervious commit)

Rename VM_KERNEL_IO_ADDRESS to VM_KERNEL_IO_BASE to match RISC-V

It's less letters, matches other similar variables and will help with
sharing code between the two architectures.

NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c

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/dev/dtrace/aarch64

2023-04-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Apr 17 06:57:02 UTC 2023

Modified Files:
src/external/cddl/osnet/dev/dtrace/aarch64: dtrace_subr.c

Log Message:
(missed in pervious commit)

Rename VM_KERNEL_IO_ADDRESS to VM_KERNEL_IO_BASE to match RISC-V

It's less letters, matches other similar variables and will help with
sharing code between the two architectures.

NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.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/dev/dtrace/aarch64/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.5 src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.6
--- src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.5	Tue Apr  6 12:48:36 2021
+++ src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c	Mon Apr 17 06:57:02 2023
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dtrace_subr.c,v 1.5 2021/04/06 12:48:36 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtrace_subr.c,v 1.6 2023/04/17 06:57:02 skrll Exp $");
 
 #include 
 #include 
@@ -129,7 +129,7 @@ dtrace_toxic_ranges(void (*func)(uintptr
 {
 
 	(*func)(0, (uintptr_t)AARCH64_DIRECTMAP_START);
-	(*func)((uintptr_t)VM_KERNEL_IO_ADDRESS, ~(uintptr_t)0);
+	(*func)((uintptr_t)VM_KERNEL_IO_BASE, ~(uintptr_t)0);
 }
 
 static void



CVS commit: src/sys/arch/powerpc/booke

2023-04-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Apr 17 06:46:53 UTC 2023

Modified Files:
src/sys/arch/powerpc/booke: booke_pmap.c

Log Message:
KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/powerpc/booke/booke_pmap.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/powerpc/booke/booke_pmap.c
diff -u src/sys/arch/powerpc/booke/booke_pmap.c:1.37 src/sys/arch/powerpc/booke/booke_pmap.c:1.38
--- src/sys/arch/powerpc/booke/booke_pmap.c:1.37	Fri Apr  7 12:09:13 2023
+++ src/sys/arch/powerpc/booke/booke_pmap.c	Mon Apr 17 06:46:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_pmap.c,v 1.37 2023/04/07 12:09:13 skrll Exp $	*/
+/*	$NetBSD: booke_pmap.c,v 1.38 2023/04/17 06:46:53 skrll Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -37,7 +37,7 @@
 #define __PMAP_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.37 2023/04/07 12:09:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.38 2023/04/17 06:46:53 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_multiprocessor.h"
@@ -249,7 +249,7 @@ pmap_bootstrap(vaddr_t startkernel, vadd
 	ptp = stp->seg_tab;
 	ppg = (void *)dm_segtabs;
 	memset(ppg, 0, NBPG * dm_nsegtabs);
-	for (size_t i = 0; i < dm_nsegtabs; i++, ptp++, ppg ++) {
+	for (size_t i = 0; i < dm_nsegtabs; i++, ptp++, ppg++) {
 		*ptp = ppg;
 	}
 



CVS commit: src/sys/arch/powerpc/booke

2023-04-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Apr 17 06:46:53 UTC 2023

Modified Files:
src/sys/arch/powerpc/booke: booke_pmap.c

Log Message:
KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/powerpc/booke/booke_pmap.c

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



CVS commit: src/usr.sbin/tprof

2023-04-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Apr 17 08:37:24 UTC 2023

Modified Files:
src/usr.sbin/tprof: tprof.8 tprof.c tprof.h tprof_top.c

Log Message:
Use the default counter if -e argument is not specified.

 monitor command:
 The default counter is selected if -e argument is not specified.
 list command:
 Print the name of the default counter for monitor and top command.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/tprof/tprof.8
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/tprof/tprof.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/tprof/tprof.h
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/tprof/tprof_top.c

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



CVS commit: src/usr.sbin/tprof

2023-04-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Apr 17 08:37:24 UTC 2023

Modified Files:
src/usr.sbin/tprof: tprof.8 tprof.c tprof.h tprof_top.c

Log Message:
Use the default counter if -e argument is not specified.

 monitor command:
 The default counter is selected if -e argument is not specified.
 list command:
 Print the name of the default counter for monitor and top command.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/tprof/tprof.8
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/tprof/tprof.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/tprof/tprof.h
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/tprof/tprof_top.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.sbin/tprof/tprof.8
diff -u src/usr.sbin/tprof/tprof.8:1.26 src/usr.sbin/tprof/tprof.8:1.27
--- src/usr.sbin/tprof/tprof.8:1.26	Mon Apr 17 07:13:35 2023
+++ src/usr.sbin/tprof/tprof.8	Mon Apr 17 08:37:24 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tprof.8,v 1.26 2023/04/17 07:13:35 msaitoh Exp $
+.\"	$NetBSD: tprof.8,v 1.27 2023/04/17 08:37:24 msaitoh Exp $
 .\"
 .\" Copyright (c)2011 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -69,10 +69,11 @@ Display the following information:
 a list of performance counter events available on the system
 .It
 the maximum number of counters that can be used simultaneously
+.It
+the default counter for monitor and top command
 .El
 .It monitor Xo
-.Fl e
-.Ar name[:option][,scale]
+.Op Fl e Ar name[:option][,scale]
 .Op Fl e Ar ...
 .Op Fl o Ar outfile
 .Ar command
@@ -91,6 +92,9 @@ specifies the source of the event; it mu
 Multiple
 .Fl e
 arguments can be specified.
+If none of the
+.Fl e
+arguments are speficied, the CPU's default counter is used.
 The collected samples are written into the file
 .Ar scale
 specifies the ratio of the speed to the cycle counter, or the counter until

Index: src/usr.sbin/tprof/tprof.c
diff -u src/usr.sbin/tprof/tprof.c:1.20 src/usr.sbin/tprof/tprof.c:1.21
--- src/usr.sbin/tprof/tprof.c:1.20	Mon Dec 26 08:00:13 2022
+++ src/usr.sbin/tprof/tprof.c	Mon Apr 17 08:37:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof.c,v 1.20 2022/12/26 08:00:13 ryo Exp $	*/
+/*	$NetBSD: tprof.c,v 1.21 2023/04/17 08:37:24 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: tprof.c,v 1.20 2022/12/26 08:00:13 ryo Exp $");
+__RCSID("$NetBSD: tprof.c,v 1.21 2023/04/17 08:37:24 msaitoh Exp $");
 #endif /* not lint */
 
 #include 
@@ -260,7 +260,12 @@ process_stat(void *arg)
 static void
 tprof_list(int argc, char **argv)
 {
-	printf("%u events can be counted at the same time\n", ncounters);
+	const char *defaultevent = tprof_cycle_event_name();
+
+	printf("%u events can be counted at the same time.\n", ncounters);
+	if (defaultevent != NULL)
+		printf("The default counter for monitor and top command is "
+		"\"%s\".\n", defaultevent);
 	tprof_event_list();
 }
 
@@ -356,6 +361,29 @@ tprof_parse_event(tprof_param_t *param, 
 	return error;
 }
 
+const char *
+tprof_cycle_event_name(void)
+{
+	const char *cycleevent;
+
+	switch (tprof_info.ti_ident) {
+	case TPROF_IDENT_INTEL_GENERIC:
+		cycleevent = "unhalted-core-cycles";
+		break;
+	case TPROF_IDENT_AMD_GENERIC:
+		cycleevent = "LsNotHaltedCyc";
+		break;
+	case TPROF_IDENT_ARMV8_GENERIC:
+	case TPROF_IDENT_ARMV7_GENERIC:
+		cycleevent = "CPU_CYCLES";
+		break;
+	default:
+		cycleevent = NULL;
+		break;
+	}
+	return cycleevent;
+}
+
 static void
 tprof_monitor_common(bool do_profile, int argc, char **argv)
 {
@@ -404,8 +432,17 @@ tprof_monitor_common(bool do_profile, in
 	}
 	argc -= optind;
 	argv += optind;
-	if (argc == 0 || nevent == 0) {
+	if (argc == 0)
 		usage();
+	if (nevent == 0) {
+		const char *defaultevent = tprof_cycle_event_name();
+		if (defaultevent == NULL)
+			errx(EXIT_FAILURE, "cpu not supported");
+
+		tprof_event_lookup(defaultevent, [nevent]);
+		eventname[nevent] = defaultevent;
+		params[nevent].p_flags |= TPROF_PARAM_KERN;
+		nevent++;
 	}
 
 	if (do_profile) {

Index: src/usr.sbin/tprof/tprof.h
diff -u src/usr.sbin/tprof/tprof.h:1.4 src/usr.sbin/tprof/tprof.h:1.5
--- src/usr.sbin/tprof/tprof.h:1.4	Fri Dec 16 08:02:04 2022
+++ src/usr.sbin/tprof/tprof.h	Mon Apr 17 08:37:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof.h,v 1.4 2022/12/16 08:02:04 ryo Exp $	*/
+/*	$NetBSD: tprof.h,v 1.5 2023/04/17 08:37:24 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,6 +34,7 @@ extern int ncpu;
 extern int devfd;
 extern u_int ncounters;
 
+const char *tprof_cycle_event_name(void);
 int tprof_event_init(uint32_t);
 void tprof_event_list(void);
 void tprof_event_lookup(const char *, struct tprof_param *);

Index: src/usr.sbin/tprof/tprof_top.c
diff -u src/usr.sbin/tprof/tprof_top.c:1.8 src/usr.sbin/tprof/tprof_top.c:1.9
--- src/usr.sbin/tprof/tprof_top.c:1.8	Fri Dec 23 19:37:06 2022
+++ 

CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 20:07:32 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lparser.c

Log Message:
lua: apply upstream bugfix for "'break' may not properly close variable in a 
'for' loop."

Function 'leaveblock' was generating "break" label before removing
variables from the closing block. If 'createlabel' created a 'close'
instruction (which it did when matching a goto/break that exited
the scope of an upvalue), that instruction would use the wrong level.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/mit/lua/dist/src/lparser.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/mit/lua/dist/src/lparser.c
diff -u src/external/mit/lua/dist/src/lparser.c:1.13 src/external/mit/lua/dist/src/lparser.c:1.14
--- src/external/mit/lua/dist/src/lparser.c:1.13	Mon Apr 17 19:17:49 2023
+++ src/external/mit/lua/dist/src/lparser.c	Mon Apr 17 20:07:32 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lparser.c,v 1.13 2023/04/17 19:17:49 nikita Exp $	*/
+/*	$NetBSD: lparser.c,v 1.14 2023/04/17 20:07:32 nikita Exp $	*/
 
 /*
 ** Id: lparser.c 
@@ -678,19 +678,19 @@ static void leaveblock (FuncState *fs) {
   LexState *ls = fs->ls;
   int hasclose = 0;
   int stklevel = reglevel(fs, bl->nactvar);  /* level outside the block */
-  if (bl->isloop)  /* fix pending breaks? */
+  removevars(fs, bl->nactvar);  /* remove block locals */
+  lua_assert(bl->nactvar == fs->nactvar);  /* back to level on entry */
+  if (bl->isloop)  /* has to fix pending breaks? */
 hasclose = createlabel(ls, luaS_newliteral(ls->L, "break"), 0, 0);
-  if (!hasclose && bl->previous && bl->upval)
+  if (!hasclose && bl->previous && bl->upval)  /* still need a 'close'? */
 luaK_codeABC(fs, OP_CLOSE, stklevel, 0, 0);
-  fs->bl = bl->previous;
-  removevars(fs, bl->nactvar);
-  lua_assert(bl->nactvar == fs->nactvar);
   fs->freereg = stklevel;  /* free registers */
   ls->dyd->label.n = bl->firstlabel;  /* remove local labels */
-  if (bl->previous)  /* inner block? */
-movegotosout(fs, bl);  /* update pending gotos to outer block */
+  fs->bl = bl->previous;  /* current block now is previous one */
+  if (bl->previous)  /* was it a nested block? */
+movegotosout(fs, bl);  /* update pending gotos to enclosing block */
   else {
-if (bl->firstgoto < ls->dyd->gt.n)  /* pending gotos in outer block? */
+if (bl->firstgoto < ls->dyd->gt.n)  /* still pending gotos? */
   undefgoto(ls, >dyd->gt.arr[bl->firstgoto]);  /* error */
   }
 }



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 20:07:32 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lparser.c

Log Message:
lua: apply upstream bugfix for "'break' may not properly close variable in a 
'for' loop."

Function 'leaveblock' was generating "break" label before removing
variables from the closing block. If 'createlabel' created a 'close'
instruction (which it did when matching a goto/break that exited
the scope of an upvalue), that instruction would use the wrong level.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/mit/lua/dist/src/lparser.c

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



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 20:17:58 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lgc.c

Log Message:
lua: apply upstream bugfix for "GC not setting a proper target for next cycle 
after a full collection in generational mode."


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/mit/lua/dist/src/lgc.c

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



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 19:16:38 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lua.c

Log Message:
lua: Apply upstream bugfix for "lua.c assumes that argv has at least one 
element."


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/lua.c

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



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 19:16:38 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lua.c

Log Message:
lua: Apply upstream bugfix for "lua.c assumes that argv has at least one 
element."


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/lua.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/mit/lua/dist/src/lua.c
diff -u src/external/mit/lua/dist/src/lua.c:1.10 src/external/mit/lua/dist/src/lua.c:1.11
--- src/external/mit/lua/dist/src/lua.c:1.10	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lua.c	Mon Apr 17 19:16:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lua.c,v 1.10 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lua.c,v 1.11 2023/04/17 19:16:38 nikita Exp $	*/
 
 /*
 ** Id: lua.c 
@@ -179,10 +179,11 @@ static void print_version (void) {
 ** to the script (everything after 'script') go to positive indices;
 ** other arguments (before the script name) go to negative indices.
 ** If there is no script name, assume interpreter's name as base.
+** (If there is no interpreter's name either, 'script' is -1, so
+** table sizes are zero.)
 */
 static void createargtable (lua_State *L, char **argv, int argc, int script) {
   int i, narg;
-  if (script == argc) script = 0;  /* no script name? */
   narg = argc - (script + 1);  /* number of positive indices */
   lua_createtable(L, narg, script + 1);
   for (i = 0; i < argc; i++) {
@@ -270,14 +271,23 @@ static int handle_script (lua_State *L, 
 
 /*
 ** Traverses all arguments from 'argv', returning a mask with those
-** needed before running any Lua code (or an error code if it finds
-** any invalid argument). 'first' returns the first not-handled argument
-** (either the script name or a bad argument in case of error).
+** needed before running any Lua code or an error code if it finds any
+** invalid argument. In case of error, 'first' is the index of the bad
+** argument.  Otherwise, 'first' is -1 if there is no program name,
+** 0 if there is no script name, or the index of the script name.
 */
 static int collectargs (char **argv, int *first) {
   int args = 0;
   int i;
-  for (i = 1; argv[i] != NULL; i++) {
+  if (argv[0] != NULL) {  /* is there a program name? */
+if (argv[0][0])  /* not empty? */
+  progname = argv[0];  /* save it */
+  }
+  else {  /* no program name */
+*first = -1;
+return 0;
+  }
+  for (i = 1; argv[i] != NULL; i++) {  /* handle arguments */
 *first = i;
 if (argv[i][0] != '-')  /* not an option? */
 return args;  /* stop handling options */
@@ -318,7 +328,7 @@ static int collectargs (char **argv, int
 return has_error;
 }
   }
-  *first = i;  /* no script name */
+  *first = 0;  /* no script name */
   return args;
 }
 
@@ -611,6 +621,7 @@ static int pmain (lua_State *L) {
   char **argv = (char **)lua_touserdata(L, 2);
   int script;
   int args = collectargs(argv, );
+  int optlim = (script > 0) ? script : argc; /* first argv not an option */
   luaL_checkversion(L);  /* check that interpreter has correct version */
   if (argv[0] && argv[0][0]) progname = argv[0];
   if (args == has_error) {  /* bad arg? */
@@ -630,14 +641,15 @@ static int pmain (lua_State *L) {
 if (handle_luainit(L) != LUA_OK)  /* run LUA_INIT */
   return 0;  /* error running LUA_INIT */
   }
-  if (!runargs(L, argv, script))  /* execute arguments -e and -l */
+  if (!runargs(L, argv, optlim))  /* execute arguments -e and -l */
 return 0;  /* something failed */
-  if (script < argc &&  /* execute main script (if there is one) */
-  handle_script(L, argv + script) != LUA_OK)
-return 0;
+  if (script > 0) {  /* execute main script (if there is one) */
+  if (handle_script(L, argv + script) != LUA_OK)
+return 0;
+  }
   if (args & has_i)  /* -i option? */
 doREPL(L);  /* do read-eval-print loop */
-  else if (script == argc && !(args & (has_e | has_v))) {  /* no arguments? */
+  else if (script < 1 && !(args & (has_e | has_v))) { /* no active option? */
 if (lua_stdin_is_tty()) {  /* running in interactive mode? */
   print_version();
   doREPL(L);  /* do read-eval-print loop */



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 19:35:36 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: ldebug.c lvm.c

Log Message:
lua: apply upstream bugfix for "Lua-stack overflow when C stack overflows while
handling an error." (CVE-2022-33099)

 Save stack space while handling errors

Because error handling (luaG_errormsg) uses slots from EXTRA_STACK,
and some errors can recur (e.g., string overflow while creating an
error message in 'luaG_runerror', or a C-stack overflow before calling
the message handler), the code should use stack slots with parsimony.

This commit fixes the bug "Lua-stack overflow when C stack overflows
while handling an error".


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/mit/lua/dist/src/ldebug.c
cvs rdiff -u -r1.15 -r1.16 src/external/mit/lua/dist/src/lvm.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/mit/lua/dist/src/ldebug.c
diff -u src/external/mit/lua/dist/src/ldebug.c:1.12 src/external/mit/lua/dist/src/ldebug.c:1.13
--- src/external/mit/lua/dist/src/ldebug.c:1.12	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/ldebug.c	Mon Apr 17 19:35:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldebug.c,v 1.12 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: ldebug.c,v 1.13 2023/04/17 19:35:36 nikita Exp $	*/
 
 /*
 ** Id: ldebug.c 
@@ -828,8 +828,11 @@ l_noret luaG_runerror (lua_State *L, con
   va_start(argp, fmt);
   msg = luaO_pushvfstring(L, fmt, argp);  /* format message */
   va_end(argp);
-  if (isLua(ci))  /* if Lua function, add source:line information */
+  if (isLua(ci)) {  /* if Lua function, add source:line information */
 luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));
+setobjs2s(L, L->top - 2, L->top - 1);  /* remove 'msg' from the stack */
+L->top--;
+  }
   luaG_errormsg(L);
 }
 

Index: src/external/mit/lua/dist/src/lvm.c
diff -u src/external/mit/lua/dist/src/lvm.c:1.15 src/external/mit/lua/dist/src/lvm.c:1.16
--- src/external/mit/lua/dist/src/lvm.c:1.15	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lvm.c	Mon Apr 17 19:35:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lvm.c,v 1.15 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lvm.c,v 1.16 2023/04/17 19:35:36 nikita Exp $	*/
 
 /*
 ** Id: lvm.c 
@@ -698,8 +698,10 @@ void luaV_concat (lua_State *L, int tota
   /* collect total length and number of strings */
   for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {
 size_t l = vslen(s2v(top - n - 1));
-if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl))
+if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) {
+  L->top = top - total;  /* pop strings to avoid wasting stack */
   luaG_runerror(L, "string length overflow");
+}
 tl += l;
   }
   if (tl <= LUAI_MAXSHORTLEN) {  /* is result a short string? */
@@ -714,7 +716,7 @@ void luaV_concat (lua_State *L, int tota
   setsvalue2s(L, top - n, ts);  /* create result */
 }
 total -= n-1;  /* got 'n' strings to create 1 new */
-L->top -= n-1;  /* popped 'n' strings and pushed one */
+L->top = top - (n - 1);  /* popped 'n' strings and pushed one */
   } while (total > 1);  /* repeat until only 1 result left */
 }
 



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 19:35:36 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: ldebug.c lvm.c

Log Message:
lua: apply upstream bugfix for "Lua-stack overflow when C stack overflows while
handling an error." (CVE-2022-33099)

 Save stack space while handling errors

Because error handling (luaG_errormsg) uses slots from EXTRA_STACK,
and some errors can recur (e.g., string overflow while creating an
error message in 'luaG_runerror', or a C-stack overflow before calling
the message handler), the code should use stack slots with parsimony.

This commit fixes the bug "Lua-stack overflow when C stack overflows
while handling an error".


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/mit/lua/dist/src/ldebug.c
cvs rdiff -u -r1.15 -r1.16 src/external/mit/lua/dist/src/lvm.c

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



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 19:54:19 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lapi.c ldo.c lfunc.c lfunc.h

Log Message:
lua: aply upstream bugfix for "'lua_settop' may use a pointer to stack 
invalidated by 'luaF_close'."


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/mit/lua/dist/src/lapi.c
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/ldo.c
cvs rdiff -u -r1.9 -r1.10 src/external/mit/lua/dist/src/lfunc.c \
src/external/mit/lua/dist/src/lfunc.h

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



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 19:54:19 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lapi.c ldo.c lfunc.c lfunc.h

Log Message:
lua: aply upstream bugfix for "'lua_settop' may use a pointer to stack 
invalidated by 'luaF_close'."


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/mit/lua/dist/src/lapi.c
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/ldo.c
cvs rdiff -u -r1.9 -r1.10 src/external/mit/lua/dist/src/lfunc.c \
src/external/mit/lua/dist/src/lfunc.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/mit/lua/dist/src/lapi.c
diff -u src/external/mit/lua/dist/src/lapi.c:1.13 src/external/mit/lua/dist/src/lapi.c:1.14
--- src/external/mit/lua/dist/src/lapi.c:1.13	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lapi.c	Mon Apr 17 19:54:19 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapi.c,v 1.13 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lapi.c,v 1.14 2023/04/17 19:54:19 nikita Exp $	*/
 
 /*
 ** Id: lapi.c 
@@ -208,7 +208,7 @@ LUA_API void lua_settop (lua_State *L, i
   newtop = L->top + diff;
   if (diff < 0 && L->tbclist >= newtop) {
 lua_assert(hastocloseCfunc(ci->nresults));
-luaF_close(L, newtop, CLOSEKTOP, 0);
+newtop = luaF_close(L, newtop, CLOSEKTOP, 0);
   }
   L->top = newtop;  /* correct top only after closing any upvalue */
   lua_unlock(L);
@@ -221,8 +221,7 @@ LUA_API void lua_closeslot (lua_State *L
   level = index2stack(L, idx);
   api_check(L, hastocloseCfunc(L->ci->nresults) && L->tbclist == level,
  "no variable to close at given level");
-  luaF_close(L, level, CLOSEKTOP, 0);
-  level = index2stack(L, idx);  /* stack may be moved */
+  level = luaF_close(L, level, CLOSEKTOP, 0);
   setnilvalue(s2v(level));
   lua_unlock(L);
 }

Index: src/external/mit/lua/dist/src/ldo.c
diff -u src/external/mit/lua/dist/src/ldo.c:1.10 src/external/mit/lua/dist/src/ldo.c:1.11
--- src/external/mit/lua/dist/src/ldo.c:1.10	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/ldo.c	Mon Apr 17 19:54:19 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldo.c,v 1.10 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: ldo.c,v 1.11 2023/04/17 19:54:19 nikita Exp $	*/
 
 /*
 ** Id: ldo.c 
@@ -431,14 +431,15 @@ l_sinline void moveresults (lua_State *L
   break;
 default:  /* two/more results and/or to-be-closed variables */
   if (hastocloseCfunc(wanted)) {  /* to-be-closed variables? */
-ptrdiff_t savedres = savestack(L, res);
 L->ci->callstatus |= CIST_CLSRET;  /* in case of yields */
 L->ci->u2.nres = nres;
-luaF_close(L, res, CLOSEKTOP, 1);
+res = luaF_close(L, res, CLOSEKTOP, 1);
 L->ci->callstatus &= ~CIST_CLSRET;
-if (L->hookmask)  /* if needed, call hook after '__close's */
+if (L->hookmask) {  /* if needed, call hook after '__close's */
+  ptrdiff_t savedres = savestack(L, res);
   rethook(L, L->ci, nres);
-res = restorestack(L, savedres);  /* close and hook can move stack */
+  res = restorestack(L, savedres);  /* hook can move stack */
+}
 wanted = decodeNresults(wanted);
 if (wanted == LUA_MULTRET)
   wanted = nres;  /* we want all results */
@@ -655,8 +656,7 @@ static int finishpcallk (lua_State *L,  
   else {  /* error */
 StkId func = restorestack(L, ci->u2.funcidx);
 L->allowhook = getoah(ci->callstatus);  /* restore 'allowhook' */
-luaF_close(L, func, status, 1);  /* can yield or raise an error */
-func = restorestack(L, ci->u2.funcidx);  /* stack may be moved */
+func = luaF_close(L, func, status, 1);  /* can yield or raise an error */
 luaD_seterrorobj(L, status, func);
 luaD_shrinkstack(L);   /* restore stack size in case of overflow */
 setcistrecst(ci, LUA_OK);  /* clear original status */

Index: src/external/mit/lua/dist/src/lfunc.c
diff -u src/external/mit/lua/dist/src/lfunc.c:1.9 src/external/mit/lua/dist/src/lfunc.c:1.10
--- src/external/mit/lua/dist/src/lfunc.c:1.9	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lfunc.c	Mon Apr 17 19:54:19 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfunc.c,v 1.9 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lfunc.c,v 1.10 2023/04/17 19:54:19 nikita Exp $	*/
 
 /*
 ** Id: lfunc.c 
@@ -227,9 +227,9 @@ static void poptbclist (lua_State *L) {
 
 /*
 ** Close all upvalues and to-be-closed variables up to the given stack
-** level.
+** level. Return restored 'level'.
 */
-void luaF_close (lua_State *L, StkId level, int status, int yy) {
+StkId luaF_close (lua_State *L, StkId level, int status, int yy) {
   ptrdiff_t levelrel = savestack(L, level);
   luaF_closeupval(L, level);  /* first, close the upvalues */
   while (L->tbclist >= level) {  /* traverse tbc's down to that level */
@@ -238,6 +238,7 @@ void luaF_close (lua_State *L, StkId lev
 prepcallclosemth(L, tbc, status, 

CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 20:37:43 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lvm.c

Log Message:
lua: apply upstream bugfix for "Wrong line in error message for arithmetic 
errors."

It also causes 'L->top' to be wrong when the error happens,
triggering an 'assert'.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/external/mit/lua/dist/src/lvm.c

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



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 20:37:43 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lvm.c

Log Message:
lua: apply upstream bugfix for "Wrong line in error message for arithmetic 
errors."

It also causes 'L->top' to be wrong when the error happens,
triggering an 'assert'.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/external/mit/lua/dist/src/lvm.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/mit/lua/dist/src/lvm.c
diff -u src/external/mit/lua/dist/src/lvm.c:1.16 src/external/mit/lua/dist/src/lvm.c:1.17
--- src/external/mit/lua/dist/src/lvm.c:1.16	Mon Apr 17 19:35:36 2023
+++ src/external/mit/lua/dist/src/lvm.c	Mon Apr 17 20:37:43 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lvm.c,v 1.16 2023/04/17 19:35:36 nikita Exp $	*/
+/*	$NetBSD: lvm.c,v 1.17 2023/04/17 20:37:43 nikita Exp $	*/
 
 /*
 ** Id: lvm.c 
@@ -1467,6 +1467,7 @@ void luaV_execute (lua_State *L, CallInf
 vmbreak;
   }
   vmcase(OP_MODK) {
+savestate(L, ci);  /* in case of division by 0 */
 op_arithK(L, luaV_mod, luaV_modf);
 vmbreak;
   }
@@ -1481,6 +1482,7 @@ void luaV_execute (lua_State *L, CallInf
   }
 #endif /* _KERNEL */
   vmcase(OP_IDIVK) {
+savestate(L, ci);  /* in case of division by 0 */
 op_arithK(L, luaV_idiv, luai_numidiv);
 vmbreak;
   }
@@ -1527,6 +1529,7 @@ void luaV_execute (lua_State *L, CallInf
 vmbreak;
   }
   vmcase(OP_MOD) {
+savestate(L, ci);  /* in case of division by 0 */
 op_arith(L, luaV_mod, luaV_modf);
 vmbreak;
   }
@@ -1541,6 +1544,7 @@ void luaV_execute (lua_State *L, CallInf
   }
 #endif /* _KERNEL */
   vmcase(OP_IDIV) {  /* floor division */
+savestate(L, ci);  /* in case of division by 0 */
 op_arith(L, luaV_idiv, luai_numidiv);
 vmbreak;
   }



CVS commit: [netbsd-10] src/lib/libc

2023-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 17 18:22:20 UTC 2023

Modified Files:
src/lib/libc/include [netbsd-10]: extern.h
src/lib/libc/stdio [netbsd-10]: Makefile.inc vfwprintf.c

Log Message:
Pull up following revision(s) (requested by he in ticket #137):

lib/libc/stdio/Makefile.inc: revision 1.48
lib/libc/stdio/vfwprintf.c: revision 1.40
lib/libc/include/extern.h: revision 1.27

PR/57250: Martin Husemann: dtoa mishandles infinite doubles on 32bit big
endian machines. When long double support was added, the old code was kept
for the regular double code. This code was never used because WIDE_DOUBLE
was always defined in the Makefile. Remove that old code, and conditionalize
the WIDE_DOUBLE code based on if long doubles are different than doubles on
the specific platform.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.26.6.1 src/lib/libc/include/extern.h
cvs rdiff -u -r1.47 -r1.47.26.1 src/lib/libc/stdio/Makefile.inc
cvs rdiff -u -r1.39 -r1.39.2.1 src/lib/libc/stdio/vfwprintf.c

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



CVS commit: [netbsd-10] src/lib/libc

2023-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 17 18:22:20 UTC 2023

Modified Files:
src/lib/libc/include [netbsd-10]: extern.h
src/lib/libc/stdio [netbsd-10]: Makefile.inc vfwprintf.c

Log Message:
Pull up following revision(s) (requested by he in ticket #137):

lib/libc/stdio/Makefile.inc: revision 1.48
lib/libc/stdio/vfwprintf.c: revision 1.40
lib/libc/include/extern.h: revision 1.27

PR/57250: Martin Husemann: dtoa mishandles infinite doubles on 32bit big
endian machines. When long double support was added, the old code was kept
for the regular double code. This code was never used because WIDE_DOUBLE
was always defined in the Makefile. Remove that old code, and conditionalize
the WIDE_DOUBLE code based on if long doubles are different than doubles on
the specific platform.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.26.6.1 src/lib/libc/include/extern.h
cvs rdiff -u -r1.47 -r1.47.26.1 src/lib/libc/stdio/Makefile.inc
cvs rdiff -u -r1.39 -r1.39.2.1 src/lib/libc/stdio/vfwprintf.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/include/extern.h
diff -u src/lib/libc/include/extern.h:1.26 src/lib/libc/include/extern.h:1.26.6.1
--- src/lib/libc/include/extern.h:1.26	Fri May 15 14:37:21 2020
+++ src/lib/libc/include/extern.h	Mon Apr 17 18:22:20 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.26 2020/05/15 14:37:21 joerg Exp $	*/
+/*	$NetBSD: extern.h,v 1.26.6.1 2023/04/17 18:22:20 martin Exp $	*/
 
 /*
  * Copyright (c) 1997 Christos Zoulas.  All rights reserved.
@@ -49,11 +49,17 @@ struct sigaction;
 int __sigaction_sigtramp(int, const struct sigaction *,
 struct sigaction *, const void *, int);
 
+/* is "long double" and "double" different? */
+#if (__LDBL_MANT_DIG__ != __DBL_MANT_DIG__) || \
+(__LDBL_MAX_EXP__ != __DBL_MAX_EXP__)
+#define WIDE_DOUBLE
+#endif
+
 #ifdef WIDE_DOUBLE
-char *__hdtoa(double, const char *, int, int *, int *, char **);
 char *__hldtoa(long double, const char *, int, int *, int *,  char **);
 char *__ldtoa(long double *, int, int, int *, int *, char **);
 #endif
+char *__hdtoa(double, const char *, int, int *, int *, char **);
 
 #ifndef __LIBC12_SOURCE__
 struct syslog_data;

Index: src/lib/libc/stdio/Makefile.inc
diff -u src/lib/libc/stdio/Makefile.inc:1.47 src/lib/libc/stdio/Makefile.inc:1.47.26.1
--- src/lib/libc/stdio/Makefile.inc:1.47	Tue Dec 29 17:55:23 2015
+++ src/lib/libc/stdio/Makefile.inc	Mon Apr 17 18:22:20 2023
@@ -1,11 +1,9 @@
 #	from: @(#)Makefile.inc	5.7 (Berkeley) 6/27/91
-#	$NetBSD: Makefile.inc,v 1.47 2015/12/29 17:55:23 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.47.26.1 2023/04/17 18:22:20 martin Exp $
 
 # stdio sources
 .PATH: ${.CURDIR}/stdio
 
-CPPFLAGS+=-DWIDE_DOUBLE
-
 SRCS+=	clrerr.c dprintf.c fclose.c fdopen.c feof.c ferror.c \
 	fflush.c fgetc.c fgetln.c fgetpos.c fgets.c fgetstr.c fgetwc.c \
 	fgetwln.c fgetws.c fileno.c findfp.c flags.c flockfile.c fopen.c \

Index: src/lib/libc/stdio/vfwprintf.c
diff -u src/lib/libc/stdio/vfwprintf.c:1.39 src/lib/libc/stdio/vfwprintf.c:1.39.2.1
--- src/lib/libc/stdio/vfwprintf.c:1.39	Tue Apr 19 20:32:16 2022
+++ src/lib/libc/stdio/vfwprintf.c	Mon Apr 17 18:22:20 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfwprintf.c,v 1.39 2022/04/19 20:32:16 rillig Exp $	*/
+/*	$NetBSD: vfwprintf.c,v 1.39.2.1 2023/04/17 18:22:20 martin Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
 static char sccsid[] = "@(#)vfprintf.c	8.1 (Berkeley) 6/4/93";
 __FBSDID("$FreeBSD: src/lib/libc/stdio/vfwprintf.c,v 1.27 2007/01/09 00:28:08 imp Exp $");
 #else
-__RCSID("$NetBSD: vfwprintf.c,v 1.39 2022/04/19 20:32:16 rillig Exp $");
+__RCSID("$NetBSD: vfwprintf.c,v 1.39.2.1 2023/04/17 18:22:20 martin Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -581,9 +581,6 @@ WDECL(vf,printf_l)(FILE * __restrict fp,
 #define	DEFPREC		6
 
 static int exponent(CHAR_T *, int, int);
-#ifndef WIDE_DOUBLE
-static char *cvt(double, int, int, char *, int *, int, int *);
-#endif
 
 #endif /* !NO_FLOATING_POINT */
 
@@ -649,17 +646,14 @@ WDECL(__vf,printf_unlocked_l)(FILE *fp, 
 	 * F:	at least two digits for decimal, at least one digit for hex
 	 */
 	char *decimal_point;	/* locale specific decimal point */
-#ifdef WIDE_DOUBLE
 	int signflag;		/* true if float is negative */
 	union {			/* floating point arguments %[aAeEfFgG] */
 		double dbl;
+#ifdef WIDE_DOUBLE
 		long double ldbl;
+#endif
 	} fparg;
 	char *dtoaend;		/* pointer to end of converted digits */
-#else
-	double _double;		/* double precision arguments %[eEfgG] */
-	char softsign;		/* temporary negative sign for floats */
-#endif
 	char *dtoaresult;	/* buffer allocated by dtoa */
 	int expt;		/* integer value of exponent */
 	char expchar;		/* exponent character: [eEpP\0] */
@@ -1058,7 +1052,6 @@ reswitch:	switch (ch) {
 			base = 10;
 			goto number;
 #ifndef NO_FLOATING_POINT
-#ifdef WIDE_DOUBLE
 		case 

CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 19:19:00 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lcode.c

Log Message:
lua: apply upstream bugfix for "Wrong code generation for constants in bitwise 
operations."


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/mit/lua/dist/src/lcode.c

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



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 19:19:00 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lcode.c

Log Message:
lua: apply upstream bugfix for "Wrong code generation for constants in bitwise 
operations."


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/mit/lua/dist/src/lcode.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/mit/lua/dist/src/lcode.c
diff -u src/external/mit/lua/dist/src/lcode.c:1.12 src/external/mit/lua/dist/src/lcode.c:1.13
--- src/external/mit/lua/dist/src/lcode.c:1.12	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lcode.c	Mon Apr 17 19:19:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lcode.c,v 1.12 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lcode.c,v 1.13 2023/04/17 19:19:00 nikita Exp $	*/
 
 /*
 ** Id: lcode.c 
@@ -1426,7 +1426,10 @@ static void finishbinexpval (FuncState *
 */
 static void codebinexpval (FuncState *fs, OpCode op,
expdesc *e1, expdesc *e2, int line) {
-  int v2 = luaK_exp2anyreg(fs, e2);  /* both operands are in registers */
+  int v2 = luaK_exp2anyreg(fs, e2);  /* make sure 'e2' is in a register */
+  /* 'e1' must be already in a register or it is a constant */
+  lua_assert((VNIL <= e1->k && e1->k <= VKSTR) ||
+ e1->k == VNONRELOC || e1->k == VRELOC);
   lua_assert(OP_ADD <= op && op <= OP_SHR);
   finishbinexpval(fs, e1, e2, op, v2, 0, line, OP_MMBIN,
   cast(TMS, (op - OP_ADD) + TM_ADD));
@@ -1513,7 +1516,7 @@ static void codecommutative (FuncState *
 
 
 /*
-** Code bitwise operations; they are all associative, so the function
+** Code bitwise operations; they are all commutative, so the function
 ** tries to put an integer constant as the 2nd operand (a K operand).
 */
 static void codebitwise (FuncState *fs, BinOpr opr,
@@ -1521,11 +1524,11 @@ static void codebitwise (FuncState *fs, 
   int flip = 0;
   int v2;
   OpCode op;
-  if (e1->k == VKINT && luaK_exp2RK(fs, e1)) {
+  if (e1->k == VKINT && luaK_exp2K(fs, e1)) {
 swapexps(e1, e2);  /* 'e2' will be the constant operand */
 flip = 1;
   }
-  else if (!(e2->k == VKINT && luaK_exp2RK(fs, e2))) {  /* no constants? */
+  else if (!(e2->k == VKINT && luaK_exp2K(fs, e2))) {  /* no constants? */
 op = cast(OpCode, opr + OP_ADD);
 codebinexpval(fs, op, e1, e2, line);  /* all-register opcodes */
 return;
@@ -1586,7 +1589,7 @@ static void codeeq (FuncState *fs, BinOp
 op = OP_EQI;
 r2 = im;  /* immediate operand */
   }
-  else if (luaK_exp2RK(fs, e2)) {  /* 1st expression is constant? */
+  else if (luaK_exp2RK(fs, e2)) {  /* 2nd expression is constant? */
 op = OP_EQK;
 r2 = e2->u.info;  /* constant index */
   }
@@ -1651,7 +1654,8 @@ void luaK_infix (FuncState *fs, BinOpr o
 case OPR_SHL: case OPR_SHR: {
   if (!tonumeral(v, NULL))
 luaK_exp2anyreg(fs, v);
-  /* else keep numeral, which may be folded with 2nd operand */
+  /* else keep numeral, which may be folded or used as an immediate
+operand */
   break;
 }
 case OPR_EQ: case OPR_NE: {



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 19:17:49 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lparser.c

Log Message:
lua: apply upstream bugfix for "Lua can generate wrong code when _ENV is 
."


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/mit/lua/dist/src/lparser.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/mit/lua/dist/src/lparser.c
diff -u src/external/mit/lua/dist/src/lparser.c:1.12 src/external/mit/lua/dist/src/lparser.c:1.13
--- src/external/mit/lua/dist/src/lparser.c:1.12	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lparser.c	Mon Apr 17 19:17:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lparser.c,v 1.12 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lparser.c,v 1.13 2023/04/17 19:17:49 nikita Exp $	*/
 
 /*
 ** Id: lparser.c 
@@ -472,6 +472,7 @@ static void singlevar (LexState *ls, exp
 expdesc key;
 singlevaraux(fs, ls->envn, var, 1);  /* get environment variable */
 lua_assert(var->k != VVOID);  /* this one must exist */
+luaK_exp2anyregup(fs, var);  /* but could be a constant */
 codestring(, varname);  /* key is variable name */
 luaK_indexed(fs, var, );  /* env[varname] */
   }



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 19:17:49 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lparser.c

Log Message:
lua: apply upstream bugfix for "Lua can generate wrong code when _ENV is 
."


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/mit/lua/dist/src/lparser.c

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



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 20:17:58 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lgc.c

Log Message:
lua: apply upstream bugfix for "GC not setting a proper target for next cycle 
after a full collection in generational mode."


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/mit/lua/dist/src/lgc.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/mit/lua/dist/src/lgc.c
diff -u src/external/mit/lua/dist/src/lgc.c:1.11 src/external/mit/lua/dist/src/lgc.c:1.12
--- src/external/mit/lua/dist/src/lgc.c:1.11	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lgc.c	Mon Apr 17 20:17:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lgc.c,v 1.11 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lgc.c,v 1.12 2023/04/17 20:17:58 nikita Exp $	*/
 
 /*
 ** Id: lgc.c 
@@ -1044,7 +1044,25 @@ void luaC_checkfinalizer (lua_State *L, 
 ** ===
 */
 
-static void setpause (global_State *g);
+
+/*
+** Set the "time" to wait before starting a new GC cycle; cycle will
+** start when memory use hits the threshold of ('estimate' * pause /
+** PAUSEADJ). (Division by 'estimate' should be OK: it cannot be zero,
+** because Lua cannot even start with less than PAUSEADJ bytes).
+*/
+static void setpause (global_State *g) {
+  l_mem threshold, debt;
+  int pause = getgcparam(g->gcpause);
+  l_mem estimate = g->GCestimate / PAUSEADJ;  /* adjust 'estimate' */
+  lua_assert(estimate > 0);
+  threshold = (pause < MAX_LMEM / estimate)  /* overflow? */
+? estimate * pause  /* no overflow */
+: MAX_LMEM;  /* overflow; truncate to maximum */
+  debt = gettotalbytes(g) - threshold;
+  if (debt > 0) debt = 0;
+  luaE_setdebt(g, debt);
+}
 
 
 /*
@@ -1289,6 +1307,15 @@ static void atomic2gen (lua_State *L, gl
 
 
 /*
+** Set debt for the next minor collection, which will happen when
+** memory grows 'genminormul'%.
+*/
+static void setminordebt (global_State *g) {
+  luaE_setdebt(g, -(cast(l_mem, (gettotalbytes(g) / 100)) * g->genminormul));
+}
+
+
+/*
 ** Enter generational mode. Must go until the end of an atomic cycle
 ** to ensure that all objects are correctly marked and weak tables
 ** are cleared. Then, turn all objects into old and finishes the
@@ -1300,6 +1327,7 @@ static lu_mem entergen (lua_State *L, gl
   luaC_runtilstate(L, bitmask(GCSpropagate));  /* start new cycle */
   numobjs = atomic(L);  /* propagates all and then do the atomic stuff */
   atomic2gen(L, g);
+  setminordebt(g);  /* set debt assuming next cycle will be minor */
   return numobjs;
 }
 
@@ -1346,15 +1374,6 @@ static lu_mem fullgen (lua_State *L, glo
 
 
 /*
-** Set debt for the next minor collection, which will happen when
-** memory grows 'genminormul'%.
-*/
-static void setminordebt (global_State *g) {
-  luaE_setdebt(g, -(cast(l_mem, (gettotalbytes(g) / 100)) * g->genminormul));
-}
-
-
-/*
 ** Does a major collection after last collection was a "bad collection".
 **
 ** When the program is building a big structure, it allocates lots of
@@ -1425,8 +1444,8 @@ static void genstep (lua_State *L, globa
   lu_mem numobjs = fullgen(L, g);  /* do a major collection */
   if (gettotalbytes(g) < majorbase + (majorinc / 2)) {
 /* collected at least half of memory growth since last major
-   collection; keep doing minor collections */
-setminordebt(g);
+   collection; keep doing minor collections. */
+lua_assert(g->lastatomic == 0);
   }
   else {  /* bad collection */
 g->lastatomic = numobjs;  /* signal that last collection was bad */
@@ -1453,26 +1472,6 @@ static void genstep (lua_State *L, globa
 
 
 /*
-** Set the "time" to wait before starting a new GC cycle; cycle will
-** start when memory use hits the threshold of ('estimate' * pause /
-** PAUSEADJ). (Division by 'estimate' should be OK: it cannot be zero,
-** because Lua cannot even start with less than PAUSEADJ bytes).
-*/
-static void setpause (global_State *g) {
-  l_mem threshold, debt;
-  int pause = getgcparam(g->gcpause);
-  l_mem estimate = g->GCestimate / PAUSEADJ;  /* adjust 'estimate' */
-  lua_assert(estimate > 0);
-  threshold = (pause < MAX_LMEM / estimate)  /* overflow? */
-? estimate * pause  /* no overflow */
-: MAX_LMEM;  /* overflow; truncate to maximum */
-  debt = gettotalbytes(g) - threshold;
-  if (debt > 0) debt = 0;
-  luaE_setdebt(g, debt);
-}
-
-
-/*
 ** Enter first sweep phase.
 ** The call to 'sweeptolive' makes the pointer point to an object
 ** inside the list (instead of to the header), so that the real sweep do



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 20:27:40 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lutf8lib.c

Log Message:
lua: apply upstream bugfix for "'utf8.codes' does not raise an error on 
spurious continuation bytes."


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/mit/lua/dist/src/lutf8lib.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/mit/lua/dist/src/lutf8lib.c
diff -u src/external/mit/lua/dist/src/lutf8lib.c:1.9 src/external/mit/lua/dist/src/lutf8lib.c:1.10
--- src/external/mit/lua/dist/src/lutf8lib.c:1.9	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lutf8lib.c	Mon Apr 17 20:27:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lutf8lib.c,v 1.9 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lutf8lib.c,v 1.10 2023/04/17 20:27:40 nikita Exp $	*/
 
 /*
 ** Id: lutf8lib.c 
@@ -29,6 +29,8 @@
 
 #define MAXUTF		0x7FFFu
 
+#define MSGInvalid	"invalid UTF-8 code"
+
 /*
 ** Integer type for decoded UTF-8 values; MAXUTF needs 31 bits.
 */
@@ -39,7 +41,8 @@ typedef unsigned long utfint;
 #endif
 
 
-#define iscont(p)	((*(p) & 0xC0) == 0x80)
+#define iscont(c)	(((c) & 0xC0) == 0x80)
+#define iscontp(p)	iscont(*(p))
 
 
 /* from strlib */
@@ -69,7 +72,7 @@ static const char *utf8_decode (const ch
 int count = 0;  /* to count number of continuation bytes */
 for (; c & 0x40; c <<= 1) {  /* while it needs continuation bytes... */
   unsigned int cc = (unsigned char)s[++count];  /* read next byte */
-  if ((cc & 0xC0) != 0x80)  /* not a continuation byte? */
+  if (!iscont(cc))  /* not a continuation byte? */
 return NULL;  /* invalid byte sequence */
   res = (res << 6) | (cc & 0x3F);  /* add lower 6 bits from cont. byte */
 }
@@ -144,7 +147,7 @@ static int codepoint (lua_State *L) {
 utfint code;
 s = utf8_decode(s, , !lax);
 if (s == NULL)
-  return luaL_error(L, "invalid UTF-8 code");
+  return luaL_error(L, MSGInvalid);
 lua_pushinteger(L, code);
 n++;
   }
@@ -194,16 +197,16 @@ static int byteoffset (lua_State *L) {
"position out of bounds");
   if (n == 0) {
 /* find beginning of current byte sequence */
-while (posi > 0 && iscont(s + posi)) posi--;
+while (posi > 0 && iscontp(s + posi)) posi--;
   }
   else {
-if (iscont(s + posi))
+if (iscontp(s + posi))
   return luaL_error(L, "initial position is a continuation byte");
 if (n < 0) {
while (n < 0 && posi > 0) {  /* move back */
  do {  /* find beginning of previous character */
posi--;
- } while (posi > 0 && iscont(s + posi));
+ } while (posi > 0 && iscontp(s + posi));
  n++;
}
  }
@@ -212,7 +215,7 @@ static int byteoffset (lua_State *L) {
while (n > 0 && posi < (lua_Integer)len) {
  do {  /* find beginning of next character */
posi++;
- } while (iscont(s + posi));  /* (cannot pass final '\0') */
+ } while (iscontp(s + posi));  /* (cannot pass final '\0') */
  n--;
}
  }
@@ -230,15 +233,15 @@ static int iter_aux (lua_State *L, int s
   const char *s = luaL_checklstring(L, 1, );
   lua_Unsigned n = (lua_Unsigned)lua_tointeger(L, 2);
   if (n < len) {
-while (iscont(s + n)) n++;  /* skip continuation bytes */
+while (iscontp(s + n)) n++;  /* skip continuation bytes */
   }
   if (n >= len)  /* (also handles original 'n' being negative) */
 return 0;  /* no more codepoints */
   else {
 utfint code;
 const char *next = utf8_decode(s + n, , strict);
-if (next == NULL)
-  return luaL_error(L, "invalid UTF-8 code");
+if (next == NULL || iscontp(next))
+  return luaL_error(L, MSGInvalid);
 lua_pushinteger(L, n + 1);
 lua_pushinteger(L, code);
 return 2;
@@ -257,7 +260,8 @@ static int iter_auxlax (lua_State *L) {
 
 static int iter_codes (lua_State *L) {
   int lax = lua_toboolean(L, 2);
-  luaL_checkstring(L, 1);
+  const char *s = luaL_checkstring(L, 1);
+  luaL_argcheck(L, !iscontp(s), 1, MSGInvalid);
   lua_pushcfunction(L, lax ? iter_auxlax : iter_auxstrict);
   lua_pushvalue(L, 1);
   lua_pushinteger(L, 0);



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 20:27:40 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lutf8lib.c

Log Message:
lua: apply upstream bugfix for "'utf8.codes' does not raise an error on 
spurious continuation bytes."


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/mit/lua/dist/src/lutf8lib.c

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



CVS commit: [netbsd-8] src/sys/kern

2023-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 17 18:13:44 UTC 2023

Modified Files:
src/sys/kern [netbsd-8]: subr_prf.c

Log Message:
Fix merge mishap in applying the changes from rev 1.171 in ticket #1804:
patch accidently applied the change to a nearby very similar function
(aprint_verbose_internal instead of aprint_error_internal).


To generate a diff of this commit:
cvs rdiff -u -r1.160.8.1 -r1.160.8.2 src/sys/kern/subr_prf.c

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



CVS commit: [netbsd-8] src/sys/kern

2023-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 17 18:13:44 UTC 2023

Modified Files:
src/sys/kern [netbsd-8]: subr_prf.c

Log Message:
Fix merge mishap in applying the changes from rev 1.171 in ticket #1804:
patch accidently applied the change to a nearby very similar function
(aprint_verbose_internal instead of aprint_error_internal).


To generate a diff of this commit:
cvs rdiff -u -r1.160.8.1 -r1.160.8.2 src/sys/kern/subr_prf.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_prf.c
diff -u src/sys/kern/subr_prf.c:1.160.8.1 src/sys/kern/subr_prf.c:1.160.8.2
--- src/sys/kern/subr_prf.c:1.160.8.1	Fri Feb 24 14:17:18 2023
+++ src/sys/kern/subr_prf.c	Mon Apr 17 18:13:44 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_prf.c,v 1.160.8.1 2023/02/24 14:17:18 martin Exp $	*/
+/*	$NetBSD: subr_prf.c,v 1.160.8.2 2023/04/17 18:13:44 martin Exp $	*/
 
 /*-
  * Copyright (c) 1986, 1988, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.160.8.1 2023/02/24 14:17:18 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.160.8.2 2023/04/17 18:13:44 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -804,6 +804,7 @@ aprint_error_internal(const char *prefix
 
 	if (prefix)
 		kprintf_internal("%s: ", flags, NULL, NULL, prefix);
+	kprintf_internal("autoconfiguration error: ", TOLOG, NULL, NULL);
 	kprintf(fmt, flags, NULL, NULL, ap);
 
 	kprintf_unlock();
@@ -907,7 +908,6 @@ aprint_verbose_internal(const char *pref
 
 	if (prefix)
 		kprintf_internal("%s: ", flags, NULL, NULL, prefix);
-	kprintf_internal("autoconfiguration error: ", TOLOG, NULL, NULL);
 	kprintf(fmt, flags, NULL, NULL, ap);
 
 	kprintf_unlock();



CVS commit: [netbsd-10] src/doc

2023-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 17 18:34:56 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Tickets #137 and #138


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.54 -r1.1.2.55 src/doc/CHANGES-10.0

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



CVS commit: [netbsd-10] src/doc

2023-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 17 18:34:56 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Tickets #137 and #138


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.54 -r1.1.2.55 src/doc/CHANGES-10.0

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-10.0
diff -u src/doc/CHANGES-10.0:1.1.2.54 src/doc/CHANGES-10.0:1.1.2.55
--- src/doc/CHANGES-10.0:1.1.2.54	Sat Apr 15 12:09:07 2023
+++ src/doc/CHANGES-10.0	Mon Apr 17 18:34:56 2023
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-10.0,v 1.1.2.54 2023/04/15 12:09:07 jdc Exp $
+# $NetBSD: CHANGES-10.0,v 1.1.2.55 2023/04/17 18:34:56 martin Exp $
 
 A complete list of changes from the initial NetBSD 10.0 branch on 2022-12-16
 until the 10.0 release:
@@ -1608,4 +1608,16 @@ sys/arch/x86/x86/intr.c1.164
 	x86: PR 57197: work around a secret argument to clockintr().
 	[riastradh, ticket #136]
 
+lib/libc/include/extern.h			1.27
+lib/libc/stdio/Makefile.inc			1.48
+lib/libc/stdio/vfwprintf.c			1.40
+
+	PR 57250: fix dtoa for big endian machines where long double uses
+	the same represantation as double.
+	[he, ticket #137]
+
+tests/lib/libc/stdio/t_printf.c			1.9,1.10
+
+	Add a test for PR 57250.
+	[he, ticket #138]
 



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 20:33:12 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lcorolib.c lstate.c lua.h

Log Message:
lua: apply ustream bugfix for "C-stack overflow with deep nesting of 
coroutine.close."


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/mit/lua/dist/src/lcorolib.c
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/lstate.c
cvs rdiff -u -r1.12 -r1.13 src/external/mit/lua/dist/src/lua.h

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



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 20:33:12 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: lcorolib.c lstate.c lua.h

Log Message:
lua: apply ustream bugfix for "C-stack overflow with deep nesting of 
coroutine.close."


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/mit/lua/dist/src/lcorolib.c
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/lstate.c
cvs rdiff -u -r1.12 -r1.13 src/external/mit/lua/dist/src/lua.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/mit/lua/dist/src/lcorolib.c
diff -u src/external/mit/lua/dist/src/lcorolib.c:1.8 src/external/mit/lua/dist/src/lcorolib.c:1.9
--- src/external/mit/lua/dist/src/lcorolib.c:1.8	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lcorolib.c	Mon Apr 17 20:33:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lcorolib.c,v 1.8 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lcorolib.c,v 1.9 2023/04/17 20:33:12 nikita Exp $	*/
 
 /*
 ** Id: lcorolib.c 
@@ -80,7 +80,7 @@ static int luaB_auxwrap (lua_State *L) {
   if (l_unlikely(r < 0)) {  /* error? */
 int stat = lua_status(co);
 if (stat != LUA_OK && stat != LUA_YIELD) {  /* error in the coroutine? */
-  stat = lua_resetthread(co);  /* close its tbc variables */
+  stat = lua_resetthread(co, L);  /* close its tbc variables */
   lua_assert(stat != LUA_OK);
   lua_xmove(co, L, 1);  /* move error message to the caller */
 }
@@ -176,7 +176,7 @@ static int luaB_close (lua_State *L) {
   int status = auxstatus(L, co);
   switch (status) {
 case COS_DEAD: case COS_YIELD: {
-  status = lua_resetthread(co);
+  status = lua_resetthread(co, L);
   if (status == LUA_OK) {
 lua_pushboolean(L, 1);
 return 1;

Index: src/external/mit/lua/dist/src/lstate.c
diff -u src/external/mit/lua/dist/src/lstate.c:1.10 src/external/mit/lua/dist/src/lstate.c:1.11
--- src/external/mit/lua/dist/src/lstate.c:1.10	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lstate.c	Mon Apr 17 20:33:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lstate.c,v 1.10 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lstate.c,v 1.11 2023/04/17 20:33:12 nikita Exp $	*/
 
 /*
 ** Id: lstate.c 
@@ -347,9 +347,10 @@ int luaE_resetthread (lua_State *L, int 
 }
 
 
-LUA_API int lua_resetthread (lua_State *L) {
+LUA_API int lua_resetthread (lua_State *L, lua_State *from) {
   int status;
   lua_lock(L);
+  L->nCcalls = (from) ? getCcalls(from) : 0;
   status = luaE_resetthread(L, L->status);
   lua_unlock(L);
   return status;

Index: src/external/mit/lua/dist/src/lua.h
diff -u src/external/mit/lua/dist/src/lua.h:1.12 src/external/mit/lua/dist/src/lua.h:1.13
--- src/external/mit/lua/dist/src/lua.h:1.12	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lua.h	Mon Apr 17 20:33:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lua.h,v 1.12 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lua.h,v 1.13 2023/04/17 20:33:12 nikita Exp $	*/
 
 /*
 ** Id: lua.h 
@@ -157,7 +157,7 @@ extern const char lua_ident[];
 LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
 LUA_API void   (lua_close) (lua_State *L);
 LUA_API lua_State *(lua_newthread) (lua_State *L);
-LUA_API int(lua_resetthread) (lua_State *L);
+LUA_API int(lua_resetthread) (lua_State *L, lua_State *from);
 
 LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
 



CVS commit: src/sys/dev/audio

2023-04-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Apr 17 20:33:45 UTC 2023

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

Log Message:
Input and output codecs produce and consume internal audio data, so
don't byteswap it.


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

2023-04-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Apr 17 20:33:45 UTC 2023

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

Log Message:
Input and output codecs produce and consume internal audio data, so
don't byteswap it.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/dev/audio/audio.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.136 src/sys/dev/audio/audio.c:1.137
--- src/sys/dev/audio/audio.c:1.136	Thu Aug 25 11:16:33 2022
+++ src/sys/dev/audio/audio.c	Mon Apr 17 20:33:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.136 2022/08/25 11:16:33 riastradh Exp $	*/
+/*	$NetBSD: audio.c,v 1.137 2023/04/17 20:33:45 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -181,7 +181,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.136 2022/08/25 11:16:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.137 2023/04/17 20:33:45 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -5628,7 +5628,7 @@ audio_pmixer_process(struct audio_softc 
 	}
 
 	m = mixer->mixsample;
-	if (mixer->swap_endian) {
+	if (!mixer->codec && mixer->swap_endian) {
 		for (i = 0; i < sample_count; i++) {
 			*h++ = bswap16(*m++);
 		}
@@ -6031,7 +6031,7 @@ audio_rmixer_process(struct audio_softc 
 		mixersrc = >hwbuf;
 	}
 
-	if (mixer->swap_endian) {
+	if (!mixer->codec && mixer->swap_endian) {
 		/* inplace conversion */
 		p = auring_headptr_aint(mixersrc);
 		for (i = 0; i < count * mixer->track_fmt.channels; i++, p++) {



CVS commit: [netbsd-10] src/tests/lib/libc/stdio

2023-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 17 18:24:52 UTC 2023

Modified Files:
src/tests/lib/libc/stdio [netbsd-10]: t_printf.c

Log Message:
Pull up following revision(s) (requested by he in ticket #138):

tests/lib/libc/stdio/t_printf.c: revision 1.9
tests/lib/libc/stdio/t_printf.c: revision 1.10

Add a test for PR/57250 from Havard Eidnes

Fix the test for "inf" output, also include newline in printf format...


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

2023-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 17 18:24:52 UTC 2023

Modified Files:
src/tests/lib/libc/stdio [netbsd-10]: t_printf.c

Log Message:
Pull up following revision(s) (requested by he in ticket #138):

tests/lib/libc/stdio/t_printf.c: revision 1.9
tests/lib/libc/stdio/t_printf.c: revision 1.10

Add a test for PR/57250 from Havard Eidnes

Fix the test for "inf" output, also include newline in printf format...


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.42.1 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.8 src/tests/lib/libc/stdio/t_printf.c:1.8.42.1
--- src/tests/lib/libc/stdio/t_printf.c:1.8	Wed Apr 11 16:21:42 2012
+++ src/tests/lib/libc/stdio/t_printf.c	Mon Apr 17 18:24:52 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: t_printf.c,v 1.8 2012/04/11 16:21:42 jruoho Exp $ */
+/* $NetBSD: t_printf.c,v 1.8.42.1 2023/04/17 18:24:52 martin Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 ATF_TC(snprintf_c99);
 ATF_TC_HEAD(snprintf_c99, tc)
@@ -179,6 +180,50 @@ ATF_TC_BODY(sprintf_zeropad, tc)
 #endif
 }
 
+ATF_TC(snprintf_double_a);
+ATF_TC_HEAD(snprintf_double_a, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test printf a format");
+}
+
+ATF_TC_BODY(snprintf_double_a, tc)
+{
+	char buf[1000];
+
+	snprintf(buf, sizeof buf, "%.3a", (double)10.6);
+	ATF_REQUIRE_STREQ("0x1.533p+3", buf);
+}
+
+/* is "long double" and "double" different? */
+#if (__LDBL_MANT_DIG__ != __DBL_MANT_DIG__) || \
+(__LDBL_MAX_EXP__ != __DBL_MAX_EXP__)
+#define WIDE_DOUBLE
+#endif
+
+#ifndef WIDE_DOUBLE
+ATF_TC(pr57250_fix);
+ATF_TC_HEAD(pr57250_fix, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test for PR57250");
+}
+
+ATF_TC_BODY(pr57250_fix, tc)
+{
+	char *eptr;
+	char buf[1000];
+	long double ld;
+
+	errno = 0;
+	ld = strtold("1e309", );
+	ATF_CHECK(errno != 0);
+	ld = (double)ld;
+	ATF_CHECK(isfinite(ld) == 0);
+	snprintf(buf, sizeof buf, "%Lf\n", ld);
+	ATF_REQUIRE_STREQ(buf, "inf\n");
+}
+#endif
+
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -189,6 +234,10 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, snprintf_posarg_error);
 	ATF_TP_ADD_TC(tp, snprintf_float);
 	ATF_TP_ADD_TC(tp, sprintf_zeropad);
+	ATF_TP_ADD_TC(tp, snprintf_double_a);
+#ifndef WIDE_DOUBLE
+	ATF_TP_ADD_TC(tp, pr57250_fix);
+#endif
 
 	return atf_no_error();
 }



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 21:17:58 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: ldump.c lundump.c

Log Message:
lua: apply upstream bugfix for "Loading a corrupted binary file can segfault."


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/ldump.c
cvs rdiff -u -r1.9 -r1.10 src/external/mit/lua/dist/src/lundump.c

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



CVS commit: src/external/mit/lua/dist/src

2023-04-17 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Mon Apr 17 21:17:58 UTC 2023

Modified Files:
src/external/mit/lua/dist/src: ldump.c lundump.c

Log Message:
lua: apply upstream bugfix for "Loading a corrupted binary file can segfault."


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/ldump.c
cvs rdiff -u -r1.9 -r1.10 src/external/mit/lua/dist/src/lundump.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/mit/lua/dist/src/ldump.c
diff -u src/external/mit/lua/dist/src/ldump.c:1.10 src/external/mit/lua/dist/src/ldump.c:1.11
--- src/external/mit/lua/dist/src/ldump.c:1.10	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/ldump.c	Mon Apr 17 21:17:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldump.c,v 1.10 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: ldump.c,v 1.11 2023/04/17 21:17:57 nikita Exp $	*/
 
 /*
 ** Id: ldump.c 
@@ -14,6 +14,7 @@
 
 #ifndef _KERNEL
 #include 
+#include 
 #endif /* _KERNEL */
 
 #include "lua.h"
@@ -59,8 +60,17 @@ static void dumpByte (DumpState *D, int 
 }
 
 
+#ifdef _KERNEL
 /* dumpInt Buff Size */
 #define DIBS((sizeof(size_t) * 8 / 7) + 1)
+#endif /* _KERNEL */
+#ifndef _KERNEL
+/*
+** 'dumpSize' buffer size: each byte can store up to 7 bits. (The "+6"
+** rounds up the division.)
+*/
+#define DIBS((sizeof(size_t) * CHAR_BIT + 6) / 7)
+#endif /* _KERNEL */
 
 static void dumpSize (DumpState *D, size_t x) {
   lu_byte buff[DIBS];

Index: src/external/mit/lua/dist/src/lundump.c
diff -u src/external/mit/lua/dist/src/lundump.c:1.9 src/external/mit/lua/dist/src/lundump.c:1.10
--- src/external/mit/lua/dist/src/lundump.c:1.9	Sun Apr 16 20:46:17 2023
+++ src/external/mit/lua/dist/src/lundump.c	Mon Apr 17 21:17:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lundump.c,v 1.9 2023/04/16 20:46:17 nikita Exp $	*/
+/*	$NetBSD: lundump.c,v 1.10 2023/04/17 21:17:57 nikita Exp $	*/
 
 /*
 ** Id: lundump.c 
@@ -254,6 +254,8 @@ static void loadDebug (LoadState *S, Pro
 f->locvars[i].endpc = loadInt(S);
   }
   n = loadInt(S);
+  if (n != 0)  /* does it have debug information? */
+n = f->sizeupvalues;  /* must be this many */
   for (i = 0; i < n; i++)
 f->upvalues[i].name = loadStringN(S, f);
 }



CVS commit: src/usr.sbin/tprof

2023-04-17 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue Apr 18 00:21:24 UTC 2023

Modified Files:
src/usr.sbin/tprof: tprof.8

Log Message:
tprof.8: fix typo, s/speficied/specified/


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/tprof/tprof.8

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



CVS commit: src/usr.sbin/tprof

2023-04-17 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue Apr 18 00:21:24 UTC 2023

Modified Files:
src/usr.sbin/tprof: tprof.8

Log Message:
tprof.8: fix typo, s/speficied/specified/


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/tprof/tprof.8

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

Modified files:

Index: src/usr.sbin/tprof/tprof.8
diff -u src/usr.sbin/tprof/tprof.8:1.29 src/usr.sbin/tprof/tprof.8:1.30
--- src/usr.sbin/tprof/tprof.8:1.29	Mon Apr 17 21:51:40 2023
+++ src/usr.sbin/tprof/tprof.8	Tue Apr 18 00:21:23 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tprof.8,v 1.29 2023/04/17 21:51:40 uwe Exp $
+.\"	$NetBSD: tprof.8,v 1.30 2023/04/18 00:21:23 gutteridge Exp $
 .\"
 .\" Copyright (c)2011 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -103,7 +103,7 @@ Multiple
 arguments can be specified.
 If none of the
 .Fl e
-arguments are speficied, the CPU's default counter is used.
+arguments are specified, the CPU's default counter is used.
 .Pp
 .Ar scale
 specifies the ratio of the speed to the cycle counter, or the counter until



CVS commit: src/usr.sbin/tprof

2023-04-17 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Apr 17 21:51:40 UTC 2023

Modified Files:
src/usr.sbin/tprof: tprof.8

Log Message:
tprof(8): fix markup nits


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/tprof/tprof.8

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



CVS commit: src/usr.sbin/tprof

2023-04-17 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Mon Apr 17 21:46:12 UTC 2023

Modified Files:
src/usr.sbin/tprof: tprof.8

Log Message:
tprof.8: new sentence, new line


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/tprof/tprof.8

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



CVS commit: src/usr.sbin/tprof

2023-04-17 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Mon Apr 17 21:46:12 UTC 2023

Modified Files:
src/usr.sbin/tprof: tprof.8

Log Message:
tprof.8: new sentence, new line


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/tprof/tprof.8

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

Modified files:

Index: src/usr.sbin/tprof/tprof.8
diff -u src/usr.sbin/tprof/tprof.8:1.27 src/usr.sbin/tprof/tprof.8:1.28
--- src/usr.sbin/tprof/tprof.8:1.27	Mon Apr 17 08:37:24 2023
+++ src/usr.sbin/tprof/tprof.8	Mon Apr 17 21:46:12 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tprof.8,v 1.27 2023/04/17 08:37:24 msaitoh Exp $
+.\"	$NetBSD: tprof.8,v 1.28 2023/04/17 21:46:12 gutteridge Exp $
 .\"
 .\" Copyright (c)2011 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -88,7 +88,8 @@ specifies the source of the event; it mu
 .Ar u
 (userland) and
 .Ar k
-(kernel). If omitted, it is assumed that both are specified.
+(kernel).
+If omitted, it is assumed that both are specified.
 Multiple
 .Fl e
 arguments can be specified.



CVS commit: src/usr.sbin/tprof

2023-04-17 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Apr 17 21:51:40 UTC 2023

Modified Files:
src/usr.sbin/tprof: tprof.8

Log Message:
tprof(8): fix markup nits


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/tprof/tprof.8

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

Modified files:

Index: src/usr.sbin/tprof/tprof.8
diff -u src/usr.sbin/tprof/tprof.8:1.28 src/usr.sbin/tprof/tprof.8:1.29
--- src/usr.sbin/tprof/tprof.8:1.28	Mon Apr 17 21:46:12 2023
+++ src/usr.sbin/tprof/tprof.8	Mon Apr 17 21:51:40 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tprof.8,v 1.28 2023/04/17 21:46:12 gutteridge Exp $
+.\"	$NetBSD: tprof.8,v 1.29 2023/04/17 21:51:40 uwe Exp $
 .\"
 .\" Copyright (c)2011 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -37,7 +37,9 @@
 .Sh DESCRIPTION
 The
 .Nm
-tool can be used to monitor hardware events (PMCs) during the execution of
+tool can be used to monitor hardware events
+.Tn ( PMC Ns s )
+during the execution of
 certain commands.
 .Pp
 The
@@ -48,11 +50,8 @@ keeps recording samples from the kernel 
 and reports statistics to the standard error.
 .Pp
 The
-.Nm tprof
-pseudo driver and a suitable backend should be loaded beforehand.
-See
 .Xr tprof 4
-for the details.
+pseudo driver and a suitable backend should be loaded beforehand.
 .Pp
 The
 .Nm
@@ -61,8 +60,10 @@ The first argument,
 .Ar op ,
 specifies the action to take.
 Valid actions are:
-.Bl -tag -width offline -offset indent
-.It list
+.Bl -tag -width Cm
+.
+.It Cm list
+.
 Display the following information:
 .Bl -bullet -compact
 .It
@@ -70,24 +71,31 @@ a list of performance counter events ava
 .It
 the maximum number of counters that can be used simultaneously
 .It
-the default counter for monitor and top command
+the default counter for
+.Cm monitor
+and
+.Cm top
+commands
 .El
-.It monitor Xo
-.Op Fl e Ar name[:option][,scale]
+.
+.It Cm monitor Xo
+.Op Fl e Ar name\| Ns Oo Cm \&: Ns Ar option\^ Oc Ns Oo Cm \&, Ns Ar scale\^ Oc
 .Op Fl e Ar ...
 .Op Fl o Ar outfile
 .Ar command
 .Xc
-Monitor the execution of command
+.
+Monitor the execution of
 .Ar command .
+The
 .Ar name
-specifies the name of the event to count; it must be taken from the list of
+specifies the event to count; it must be taken from the list of
 available events.
 .Ar option
 specifies the source of the event; it must be a combination of
-.Ar u
+.Cm u
 (userland) and
-.Ar k
+.Cm k
 (kernel).
 If omitted, it is assumed that both are specified.
 Multiple
@@ -96,7 +104,7 @@ arguments can be specified.
 If none of the
 .Fl e
 arguments are speficied, the CPU's default counter is used.
-The collected samples are written into the file
+.Pp
 .Ar scale
 specifies the ratio of the speed to the cycle counter, or the counter until
 overflow.
@@ -105,38 +113,43 @@ speed of the cycle counter by default, b
 too large (counter increasing too slowly) to be sufficient for profiling.
 For example, to specify an event that increases about 1000 times slower than
 the cycle counter, specify
-.Dq Pa -e event,1000 .
+.Ql -e event,1000 .
 Also, if
-.Dq Pa -e event,=200
+.Ql -e event,=200
 is specified, profiling is performed every time the counter is increased by 200.
+.Pp
+The collected samples are written into the file
 .Ar outfile
 if specified.
 The default is
-.Dq Pa tprof.out .
-.It count Xo
-.Fl e
-.Ar name[:option]
+.Pa tprof.out .
+.
+.It Cm count Xo
+.Fl e Ar name\| Ns Op Cm \&: Ns Ar option
 .Op Fl e Ar ...
 .Op Fl i Ar interval
 .Ar command
 .Xc
+.
 Same as
-.Ar monitor ,
+.Cm monitor ,
 but does not do any profiling,
 only outputs counters every
 .Ar interval
 second.
-.It analyze Xo
+.
+.It Cm analyze Xo
 .Op Fl CkLPs
 .Op Fl p Ar pid
 .Ar file
 .Xc
+.
 Analyze the samples produced by a previous run of
-.Nm tprof ,
+.Nm ,
 stored in
 .Ar file ,
 and generate a plain text representation of them.
-.Bl -tag -width XPXpidXX -offset indent
+.Bl -tag -width Fl
 .It Fl C
 Don't distinguish CPUs.
 All samples are treated as its CPU number is 0.
@@ -156,27 +169,28 @@ and ignore the rest.
 .It Fl s
 Per symbol.
 .El
-.It top Xo
-.Oo
-.Fl e
-.Ar name[,scale]
+.
+.It Cm top Xo
+.Op Fl acu
+.Op Fl e Ar name\| Ns Oo Cm \&, Ns Ar scale\^ Oc
 .Op Fl e Ar ...
-.Oc
 .Op Fl i Ar interval
-.Op Fl acu
 .Xc
+.
 Displays profiling results in real-time.
 .Ar name
 specifies the name of the event to count.
-.Bl -tag -width XXintervalX -offset indent
-.It Fl i Ar interval
-set the update interval in seconds. The default value is 1.
+.Bl -tag -width Fl
 .It Fl a
-Starts in accumulation mode. The display is updated every
+Starts in accumulation mode.
+The display is updated every
 .Ar interval
 second, but the values are accumulative.
 .It Fl c
-show the delta of the event counters.
+Show the delta of the event counters.
+.It Fl i Ar interval
+Set the update interval in seconds.
+The default value is 1.
 .It Fl u
 Userland processes are also included in the profiling.
 .El
@@ -186,23 +200,27 @@