CVS commit: src/sys/arch/aarch64

2020-08-02 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Aug  3 06:30:00 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: TODO copyinout.S genassym.cf
src/sys/arch/aarch64/include: cpufunc.h types.h

Log Message:
Implement MD ucas(9) (__HAVE_UCAS_FULL)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/aarch64/aarch64/TODO
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/aarch64/copyinout.S
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/aarch64/include/cpufunc.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/aarch64/include/types.h

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/TODO
diff -u src/sys/arch/aarch64/aarch64/TODO:1.8 src/sys/arch/aarch64/aarch64/TODO:1.9
--- src/sys/arch/aarch64/aarch64/TODO:1.8	Wed Dec  4 13:47:03 2019
+++ src/sys/arch/aarch64/aarch64/TODO	Mon Aug  3 06:29:59 2020
@@ -1,7 +1,6 @@
-$NetBSD: TODO,v 1.8 2019/12/04 13:47:03 jmcneill Exp $
+$NetBSD: TODO,v 1.9 2020/08/03 06:29:59 ryo Exp $
 
 TODO list for NetBSD/aarch64
   - kernel preemption
-  - Implement __HAVE_UCAS_FULL or __HAVE_UCAS_MP (don't use full generic impl)
   - pmap should be work even if PID_MAX >= 65536 (don't depend 16bit ASID)
   - TLB ASID in pmap should be randomized

Index: src/sys/arch/aarch64/aarch64/copyinout.S
diff -u src/sys/arch/aarch64/aarch64/copyinout.S:1.12 src/sys/arch/aarch64/aarch64/copyinout.S:1.13
--- src/sys/arch/aarch64/aarch64/copyinout.S:1.12	Mon Aug  3 05:56:49 2020
+++ src/sys/arch/aarch64/aarch64/copyinout.S	Mon Aug  3 06:29:59 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: copyinout.S,v 1.12 2020/08/03 05:56:49 ryo Exp $ */
+/* $NetBSD: copyinout.S,v 1.13 2020/08/03 06:29:59 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: copyinout.S,v 1.12 2020/08/03 05:56:49 ryo Exp $");
+RCSID("$NetBSD: copyinout.S,v 1.13 2020/08/03 06:29:59 ryo Exp $");
 
 #ifdef ARMV81_PAN
 #define PAN_ENABLE	\
@@ -348,3 +348,50 @@ ENTRY(kcopy)
 	exit_cpu_onfault
 	ret
 END(kcopy)
+
+
+/* LINTSTUB: int _ucas_32(volatile uint32_t *uptr, uint32_t old, uint32_t new, uint32_t *retp); */
+ENTRY(_ucas_32)
+	tbnz	x0, AARCH64_ADDRTOP_TAG_BIT, 3f	/* not userspace */
+	ands	x8, x0, #3
+	cbnz	x8, 3f/* not aligned */
+
+	enter_cpu_onfault
+
+1:	ldxr	w4, [x0]		/* load old value */
+	cmp	w4, w1			/*   compare? */
+	b.ne	2f			/* return if different */
+	stxr	w5, w2, [x0]		/* store new value */
+	cbnz	w5, 1b			/*   succeed? nope, try again. */
+2:	str	w4, [x3]
+	mov	x8, #0			/* error = 0 */
+
+	exit_cpu_onfault
+	ret
+3:
+	mov	x0, #EFAULT
+	ret
+END(_ucas_32)
+
+/* LINTSTUB: int _ucas_64(volatile uint64_t *uptr, uint64_t old, uint64_t new, uint64_t *retp); */
+ENTRY(_ucas_64)
+	tbnz	x0, AARCH64_ADDRTOP_TAG_BIT, 3f	/* not userspace */
+	ands	x8, x0, #7
+	cbnz	x8, 3f/* not aligned */
+
+	enter_cpu_onfault
+
+1:	ldxr	x4, [x0]		/* load old value */
+	cmp	x4, x1			/*   compare? */
+	b.ne	2f			/* return if different */
+	stxr	w5, x2, [x0]		/* store new value */
+	cbnz	w5, 1b			/*   succeed? nope, try again. */
+2:	str	x4, [x3]
+	mov	x8, #0			/* error = 0 */
+
+	exit_cpu_onfault
+	ret
+3:
+	mov	x0, #EFAULT
+	ret
+END(_ucas_64)

Index: src/sys/arch/aarch64/aarch64/genassym.cf
diff -u src/sys/arch/aarch64/aarch64/genassym.cf:1.27 src/sys/arch/aarch64/aarch64/genassym.cf:1.28
--- src/sys/arch/aarch64/aarch64/genassym.cf:1.27	Mon Aug  3 05:56:50 2020
+++ src/sys/arch/aarch64/aarch64/genassym.cf	Mon Aug  3 06:29:59 2020
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.27 2020/08/03 05:56:50 ryo Exp $
+# $NetBSD: genassym.cf,v 1.28 2020/08/03 06:29:59 ryo Exp $
 #-
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -56,6 +56,7 @@ include 
 include 
 include 
 include 
+include 
 include 
 
 define	__HAVE_FAST_SOFTINTS	1
@@ -76,6 +77,8 @@ define	USPACE			(UPAGES * PAGE_SIZE)
 
 #define	PV_PA			offsetof(pv_addr_t, pv_pa)
 
+define	AARCH64_ADDRTOP_TAG_BIT	AARCH64_ADDRTOP_TAG_BIT
+
 define	L0_ADDR_BITS		L0_ADDR_BITS
 define	L0_SHIFT		L0_SHIFT
 define	L0_TABLE		L0_TABLE

Index: src/sys/arch/aarch64/include/cpufunc.h
diff -u src/sys/arch/aarch64/include/cpufunc.h:1.17 src/sys/arch/aarch64/include/cpufunc.h:1.18
--- src/sys/arch/aarch64/include/cpufunc.h:1.17	Sun Aug  2 06:58:16 2020
+++ src/sys/arch/aarch64/include/cpufunc.h	Mon Aug  3 06:30:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.17 2020/08/02 06:58:16 maxv Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.18 2020/08/03 06:30:00 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -167,6 +167,7 @@ cpu_earlydevice_va_p(void)
 #endif /* _KERNEL */
 
 /* definitions of TAG and PAC in pointers */
+#define AARCH64_ADDRTOP_TAG_BIT		55
 #define AARCH64_ADDRTOP_TAG		__BIT(55)	/* ECR_EL1.TBI[01]=1 */
 #define AARCH64_ADDRTOP_MSB		__BIT(63)	/* ECR_EL1.TBI[01]=0 */
 #define AAR

CVS commit: src/sys/arch/aarch64

2020-08-02 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Aug  3 05:56:50 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: copyinout.S cpuswitch.S fault.c fusu.S
genassym.cf
src/sys/arch/aarch64/include: frame.h machdep.h

Log Message:
Fix a problem in which a fault occured in an interrupt handler during 
copyin/copyout was erroneously detected as being occured by copyin.

- keep idepth in faultbuf and compare it to avoid unnecessary fault recovery
- make cpu_set_onfault() nestable to use bus_space_{peek,poke}()
  in hardware interrupt handlers during copyin & copyout.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/aarch64/aarch64/copyinout.S
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/aarch64/aarch64/cpuswitch.S
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/aarch64/fault.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/aarch64/fusu.S
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/include/frame.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/aarch64/include/machdep.h

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/copyinout.S
diff -u src/sys/arch/aarch64/aarch64/copyinout.S:1.11 src/sys/arch/aarch64/aarch64/copyinout.S:1.12
--- src/sys/arch/aarch64/aarch64/copyinout.S:1.11	Sun Aug  2 06:58:16 2020
+++ src/sys/arch/aarch64/aarch64/copyinout.S	Mon Aug  3 05:56:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: copyinout.S,v 1.11 2020/08/02 06:58:16 maxv Exp $ */
+/* $NetBSD: copyinout.S,v 1.12 2020/08/03 05:56:49 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: copyinout.S,v 1.11 2020/08/02 06:58:16 maxv Exp $");
+RCSID("$NetBSD: copyinout.S,v 1.12 2020/08/03 05:56:49 ryo Exp $");
 
 #ifdef ARMV81_PAN
 #define PAN_ENABLE	\
@@ -63,7 +63,7 @@ RCSID("$NetBSD: copyinout.S,v 1.11 2020/
 	mov	x19, x0			/* x19 = arg0 */
 	mov	x20, x1			/* x20 = arg1 */
 
-	/* if (cpu_set_onfault(fb) != 0) return -1 */
+	/* if (cpu_set_onfault(fb) != 0) return error */
 	sub	sp, sp, #FB_T_SIZE	/* allocate struct faultbuf */
 	mov	x0, sp			/* x0 = faultbuf */
 	stp	x2, x3, [sp, #-16]!	/* save x2, x3 */
@@ -79,10 +79,8 @@ RCSID("$NetBSD: copyinout.S,v 1.11 2020/
 	.endm
 
 	.macro exit_cpu_onfault
-	/* curlwp->l_md.md_onfault = NULL */
-	mrs	x0, tpidr_el1			/* curcpu */
-	ldr	x0, [x0, #CI_CURLWP]		/* x0 = curlwp */
-	str	xzr, [x0, #L_MD_ONFAULT]	/* lwp->l_md_onfault = NULL */
+	bl	cpu_unset_onfault
+	mov	x8, xzr
 9:
 	PAN_ENABLE/* enable PAN */
 	add	sp, sp, #FB_T_SIZE		/* pop stack */

Index: src/sys/arch/aarch64/aarch64/cpuswitch.S
diff -u src/sys/arch/aarch64/aarch64/cpuswitch.S:1.22 src/sys/arch/aarch64/aarch64/cpuswitch.S:1.23
--- src/sys/arch/aarch64/aarch64/cpuswitch.S:1.22	Thu Jul 23 13:12:54 2020
+++ src/sys/arch/aarch64/aarch64/cpuswitch.S	Mon Aug  3 05:56:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuswitch.S,v 1.22 2020/07/23 13:12:54 skrll Exp $ */
+/* $NetBSD: cpuswitch.S,v 1.23 2020/08/03 05:56:50 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include "opt_ddb.h"
 #include "opt_kasan.h"
 
-RCSID("$NetBSD: cpuswitch.S,v 1.22 2020/07/23 13:12:54 skrll Exp $")
+RCSID("$NetBSD: cpuswitch.S,v 1.23 2020/08/03 05:56:50 ryo Exp $")
 
 	ARMV8_DEFINE_OPTIONS
 
@@ -447,22 +447,40 @@ END(cpu_Debugger)
  */
 ENTRY_NP(cpu_set_onfault)
 	mrs	x3, tpidr_el1
-	ldr	x2, [x3, #CI_CURLWP]	/* curlwp = curcpu()->ci_curlwp */
+	ldr	x2, [x3, #CI_CURLWP]	/* x2 = curcpu()->ci_curlwp */
+	ldr	x1, [x2, #L_MD_ONFAULT]
+	str	x1, [x0, #FB_OLD]	/* fb->fb_old = curlwp->l_md.md_onfault */
+	ldr	w1, [x3, #CI_INTR_DEPTH]
+	str	w1, [x0, #FB_IDEPTH]	/* fb->fb_idepth = curcpu()->ci_intr_depth */
 	str	x0, [x2, #L_MD_ONFAULT] /* l_md.md_onfault = fb */
 
-	stp	x19, x20, [x0, #(FB_X19 * 8)]
-	stp	x21, x22, [x0, #(FB_X21 * 8)]
-	stp	x23, x24, [x0, #(FB_X23 * 8)]
-	stp	x25, x26, [x0, #(FB_X25 * 8)]
-	stp	x27, x28, [x0, #(FB_X27 * 8)]
-	stp	x29, x30, [x0, #(FB_X29 * 8)]
+	stp	x19, x20, [x0, #FB_REG_X19]
+	stp	x21, x22, [x0, #FB_REG_X21]
+	stp	x23, x24, [x0, #FB_REG_X23]
+	stp	x25, x26, [x0, #FB_REG_X25]
+	stp	x27, x28, [x0, #FB_REG_X27]
+	stp	x29, x30, [x0, #FB_REG_X29]
 	mov	x1, sp
-	str	x1, [x0, #(FB_SP * 8)]
+	str	x1, [x0, #FB_REG_SP]
 	mov	x0, #0
 	ret
 END(cpu_set_onfault)
 
 /*
+ * void cpu_unset_onfault(void)
+ */
+ENTRY_NP(cpu_unset_onfault)
+	mrs	x3, tpidr_el1
+	ldr	x2, [x3, #CI_CURLWP]	/* curlwp = curcpu()->ci_curlwp */
+	ldr	x0, [x2, #L_MD_ONFAULT]	/* x0 = curlwp->l_md.md_onfault */
+	cbz	x0, 1f
+	ldr	x0, [x0, #FB_OLD]	/* restore old faultbuf */
+	str	x0, [x2, #L_MD_ONFAULT]
+1:
+	ret
+END(cpu_unset_onfault)
+
+/*
  * setjmp(9)
  * int setjmp(label_t *label);
  * void longjmp(label_t *label);

Index: src/sys/arch/aarch64/aarch64/fault.c
diff -u src/sys/arch/aarch64/aarch64/fault.c:1.15 src/sys/arch/a

CVS commit: src/etc

2020-08-02 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Aug  3 04:32:13 UTC 2020

Modified Files:
src/etc/etc.amd64: MAKEDEV.conf
src/etc/etc.i386: MAKEDEV.conf

Log Message:
Create 8 /dev/ldX by default, as with other disk drivers and ports


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/etc/etc.amd64/MAKEDEV.conf
cvs rdiff -u -r1.31 -r1.32 src/etc/etc.i386/MAKEDEV.conf

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

Modified files:

Index: src/etc/etc.amd64/MAKEDEV.conf
diff -u src/etc/etc.amd64/MAKEDEV.conf:1.30 src/etc/etc.amd64/MAKEDEV.conf:1.31
--- src/etc/etc.amd64/MAKEDEV.conf:1.30	Sun Jul 26 15:47:27 2020
+++ src/etc/etc.amd64/MAKEDEV.conf	Mon Aug  3 04:32:13 2020
@@ -1,4 +1,4 @@
-# $NetBSD: MAKEDEV.conf,v 1.30 2020/07/26 15:47:27 jdolecek Exp $
+# $NetBSD: MAKEDEV.conf,v 1.31 2020/08/03 04:32:13 nia Exp $
 
 # As of 2003-04-17, the "init" case must not create more than 890 entries.
 all_md)
@@ -17,7 +17,7 @@ all_md)
 	makedev nvme2 nvme2ns1 nvme2ns2 nvme2ns3 nvme2ns4
 	makedev nvme3 nvme3ns1 nvme3ns2 nvme3ns3 nvme3ns4
 	makedev raid0 raid1 raid2 raid3
-	makedev ld0 ld1 ld2 ld3
+	makedev ld0 ld1 ld2 ld3 ld4 ld5 ld6 ld7
 	makedev xbd0 xbd1 xbd2 xbd3 xen
 	makedev usbs
 	makedev local

Index: src/etc/etc.i386/MAKEDEV.conf
diff -u src/etc/etc.i386/MAKEDEV.conf:1.31 src/etc/etc.i386/MAKEDEV.conf:1.32
--- src/etc/etc.i386/MAKEDEV.conf:1.31	Sun Apr  5 14:09:17 2020
+++ src/etc/etc.i386/MAKEDEV.conf	Mon Aug  3 04:32:13 2020
@@ -1,4 +1,4 @@
-# $NetBSD: MAKEDEV.conf,v 1.31 2020/04/05 14:09:17 jdolecek Exp $
+# $NetBSD: MAKEDEV.conf,v 1.32 2020/08/03 04:32:13 nia Exp $
 
 # As of 2005-03-15, the "init" case must not create more than 1024 entries.
 all_md)
@@ -18,7 +18,7 @@ all_md)
 	makedev nvme2 nvme2ns1 nvme2ns2 nvme2ns3 nvme2ns4
 	makedev nvme3 nvme3ns1 nvme3ns2 nvme3ns3 nvme3ns4
 	makedev raid0 raid1 raid2 raid3
-	makedev ld0 ld1 ld2 ld3
+	makedev ld0 ld1 ld2 ld3 ld4 ld5 ld6 ld7
 	makedev xbd0 xbd1 xbd2 xbd3 xen
 	makedev usbs
 	makedev ipty



CVS commit: src/usr.bin/script

2020-08-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Aug  3 03:34:43 UTC 2020

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

Log Message:
remove trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/script/script.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/script/script.c
diff -u src/usr.bin/script/script.c:1.23 src/usr.bin/script/script.c:1.24
--- src/usr.bin/script/script.c:1.23	Sun Aug  2 12:23:33 2020
+++ src/usr.bin/script/script.c	Sun Aug  2 23:34:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: script.c,v 1.23 2020/08/02 16:23:33 christos Exp $	*/
+/*	$NetBSD: script.c,v 1.24 2020/08/03 03:34:43 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)script.c	8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: script.c,v 1.23 2020/08/02 16:23:33 christos Exp $");
+__RCSID("$NetBSD: script.c,v 1.24 2020/08/03 03:34:43 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -166,7 +166,7 @@ main(int argc, char *argv[])
 			err(EXIT_FAILURE, "openpty");
 	} else {
 		if (openpty(&master, &slave, NULL, NULL, NULL) == -1)
-			err(EXIT_FAILURE, "openpty");		
+			err(EXIT_FAILURE, "openpty");
 	}
 
 	if (!quiet)
@@ -200,7 +200,7 @@ main(int argc, char *argv[])
 	if (!rawout)
 		(void)fclose(fscript);
 	while ((scc = read(STDIN_FILENO, ibuf, BUFSIZ)) > 0) {
-		cc = (size_t)scc;	
+		cc = (size_t)scc;
 		if (rawout)
 			record(fscript, ibuf, cc, 'i');
 		(void)write(master, ibuf, cc);
@@ -413,7 +413,7 @@ playback(FILE *fp)
 	int reg;
 
 	if (fstat(fileno(fp), &pst) == -1)
-		err(EXIT_FAILURE, "fstat failed");	
+		err(EXIT_FAILURE, "fstat failed");
 
 	reg = S_ISREG(pst.st_mode);
 



CVS commit: src/sys/arch/sh3/sh3

2020-08-02 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Aug  3 03:34:11 UTC 2020

Modified Files:
src/sys/arch/sh3/sh3: locore_subr.S

Log Message:
_cpu_exception_suspend, _cpu_exception_resume - cosmetics

Use PSL_BL instead of magic hex in comments.  Use spaces between
operands.  Same object code is generated.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/sh3/sh3/locore_subr.S

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/sh3/sh3/locore_subr.S
diff -u src/sys/arch/sh3/sh3/locore_subr.S:1.58 src/sys/arch/sh3/sh3/locore_subr.S:1.59
--- src/sys/arch/sh3/sh3/locore_subr.S:1.58	Wed Jan  8 20:59:19 2020
+++ src/sys/arch/sh3/sh3/locore_subr.S	Mon Aug  3 03:34:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore_subr.S,v 1.58 2020/01/08 20:59:19 skrll Exp $	*/
+/*	$NetBSD: locore_subr.S,v 1.59 2020/08/03 03:34:11 uwe Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #include 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: locore_subr.S,v 1.58 2020/01/08 20:59:19 skrll Exp $")
+__KERNEL_RCSID(0, "$NetBSD: locore_subr.S,v 1.59 2020/08/03 03:34:11 uwe Exp $")
 
 
 /*
@@ -298,15 +298,15 @@ NENTRY(_cpu_intr_resume)
  *	if exception occur, jump to 0xa000 (hard reset).
  */
 NENTRY(_cpu_exception_suspend)
-	stc	sr,	r0	/* r0 = SR */
-	mov	#0x10,	r1
-	swap.b	r1,	r1
-	mov	r0,	r2	/* r2 = r0 */
-	swap.w	r1,	r1	/* r1 = 0x1000 */
-	or	r1,	r2	/* r2 |= 0x1000 */
-	ldc	r2,	sr	/* SR = r2 */
+	stc	sr, r0		/* r0 = SR */
+	mov	#0x10, r1	/* bswap32(PSL_BL) - fits immediate */
+	swap.b	r1, r1
+	mov	r0, r2		/* r2 = r0 */
+	swap.w	r1, r1		/* r1 = PSL_BL */
+	or	r1, r2		/* r2 |= PSL_BL */
+	ldc	r2, sr		/* SR = r2 */
 	rts
-	 and	r1,	r0	/* r0 &= 0x1000 */
+	 and	r1, r0		/* r0 &= 0x1000 */
 	SET_ENTRY_SIZE(_cpu_exception_suspend)
 
 
@@ -315,14 +315,14 @@ NENTRY(_cpu_exception_suspend)
  *	restore 's' exception mask. (SR.BL)
  */
 NENTRY(_cpu_exception_resume)
-	stc	sr,	r0	/* r0 = SR */
-	mov	#0x10,	r1
-	swap.b	r1,	r1
-	swap.w	r1,	r1
-	not	r1,	r1	/* r1 = ~0x1000 */
-	and	r1,	r0	/* r0 &= ~0x1000 */
-	or	r4,	r0	/* r0 |= old SR.BL */
-	ldc	r0,	sr	/* SR = r0 (don't move to delay slot) */
+	stc	sr, r0		/* r0 = SR */
+	mov	#0x10, r1	/* bswap32(PSL_BL) - fits immediate */
+	swap.b	r1, r1
+	swap.w	r1, r1
+	not	r1, r1		/* r1 = ~PSL_BL */
+	and	r1, r0		/* r0 &= ~PSL_BL */
+	or	r4, r0		/* r0 |= old SR.BL */
+	ldc	r0, sr		/* SR = r0 (don't move to delay slot) */
 	rts
 	 nop
 	SET_ENTRY_SIZE(_cpu_exception_resume)



CVS commit: othersrc/external/historical/eawk/doc

2020-08-02 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Mon Aug  3 02:09:49 UTC 2020

Modified Files:
othersrc/external/historical/eawk/doc: extensions

Log Message:
Fix typo - thanks to Brad Harder (yukonbob)!


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/doc/extensions

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

Modified files:

Index: othersrc/external/historical/eawk/doc/extensions
diff -u othersrc/external/historical/eawk/doc/extensions:1.1 othersrc/external/historical/eawk/doc/extensions:1.2
--- othersrc/external/historical/eawk/doc/extensions:1.1	Sat Jun  1 22:27:32 2013
+++ othersrc/external/historical/eawk/doc/extensions	Mon Aug  3 02:09:49 2020
@@ -2,7 +2,7 @@ Extending eawk
 ==
 
 To add new functionality to eawk, extensions are used. They can be layered
-on top of each other, and provide access to thirs-party libraries. To write
+on top of each other, and provide access to third-party libraries. To write
 and use an extensions, we'll look at the base64 encoding extension in eawk:
 
 -- see extend/base64/base64.c



CVS commit: src/sys/arch/sh3/sh3

2020-08-02 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Aug  3 01:56:19 UTC 2020

Modified Files:
src/sys/arch/sh3/sh3: db_interface.c

Log Message:
db_tlbdump_cmd - get rid of RUN_P2/P1, use functions instead.

Move the bits of code to read TLB entries into separate functions and
call them via P2 pointers instead of doing P2/P1 switch inline.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/sh3/sh3/db_interface.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/sh3/sh3/db_interface.c
diff -u src/sys/arch/sh3/sh3/db_interface.c:1.63 src/sys/arch/sh3/sh3/db_interface.c:1.64
--- src/sys/arch/sh3/sh3/db_interface.c:1.63	Mon Aug  3 01:18:45 2020
+++ src/sys/arch/sh3/sh3/db_interface.c	Mon Aug  3 01:56:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.63 2020/08/03 01:18:45 uwe Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.64 2020/08/03 01:56:18 uwe Exp $	*/
 
 /*-
  * Copyright (C) 2002 UCHIYAMA Yasushi.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.63 2020/08/03 01:18:45 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.64 2020/08/03 01:56:18 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -66,6 +66,13 @@ db_regs_t ddb_regs;		/* register state *
 static void kdb_printtrap(u_int, int);
 
 static void db_tlbdump_cmd(db_expr_t, bool, db_expr_t, const char *);
+#ifdef SH4
+static __noinline void
+__db_get_itlb_sh4(uint32_t, uint32_t *, uint32_t *, uint32_t *);
+static __noinline void
+__db_get_utlb_sh4(uint32_t, uint32_t *, uint32_t *, uint32_t *);
+#endif
+
 static char *__db_procname_by_asid(int);
 static void __db_tlbdump_pfn(uint32_t);
 #ifdef SH4
@@ -320,8 +327,13 @@ db_tlbdump_cmd(db_expr_t addr, bool have
 #endif /* SH3 */
 #ifdef SH4
 	if (CPU_IS_SH4) {
+		void (*get_itlb_p2)(uint32_t, uint32_t *, uint32_t *, uint32_t *);
+		void (*get_utlb_p2)(uint32_t, uint32_t *, uint32_t *, uint32_t *);
 		uint32_t aa, da1, da2;
 
+		get_itlb_p2 = (void *)SH3_P1SEG_TO_P2SEG(__db_get_itlb_sh4);
+		get_utlb_p2 = (void *)SH3_P1SEG_TO_P2SEG(__db_get_utlb_sh4);
+
 		/* MMU configuration */
 		r = _reg_read_4(SH4_MMUCR);
 		db_printf("%s virtual storage mode, SQ access: (kernel%s)\n",
@@ -338,11 +350,7 @@ db_tlbdump_cmd(db_expr_t addr, bool have
 		for (i = 0; i < 4; i++) {
 			e = i << SH4_ITLB_E_SHIFT;
 
-			RUN_P2;
-			aa = _reg_read_4(SH4_ITLB_AA | e);
-			da1 = _reg_read_4(SH4_ITLB_DA1 | e);
-			da2 = _reg_read_4(SH4_ITLB_DA2 | e);
-			RUN_P1;
+			(*get_itlb_p2)(e, &aa, &da1, &da2);
 
 			db_printf("0x%08x   %3d",
 			aa & SH4_ITLB_AA_VPN_MASK,
@@ -367,11 +375,7 @@ db_tlbdump_cmd(db_expr_t addr, bool have
 		for (i = 0; i < 64; i++) {
 			e = i << SH4_UTLB_E_SHIFT;
 
-			RUN_P2;
-			aa = _reg_read_4(SH4_UTLB_AA | e);
-			da1 = _reg_read_4(SH4_UTLB_DA1 | e);
-			da2 = _reg_read_4(SH4_UTLB_DA2 | e);
-			RUN_P1;
+			(*get_utlb_p2)(e, &aa, &da1, &da2);
 
 			db_printf("0x%08x   %3d",
 			aa & SH4_UTLB_AA_VPN_MASK,
@@ -397,6 +401,29 @@ db_tlbdump_cmd(db_expr_t addr, bool have
 #endif /* SH4 */
 }
 
+
+#ifdef SH4
+static __noinline void
+__db_get_itlb_sh4(uint32_t e, uint32_t *paa, uint32_t *pda1, uint32_t *pda2)
+{
+
+	*paa = _reg_read_4(SH4_ITLB_AA | e);
+	*pda1 = _reg_read_4(SH4_ITLB_DA1 | e);
+	*pda2 = _reg_read_4(SH4_ITLB_DA2 | e);
+}
+
+
+static __noinline void
+__db_get_utlb_sh4(uint32_t e, uint32_t *paa, uint32_t *pda1, uint32_t *pda2)
+{
+
+	*paa = _reg_read_4(SH4_UTLB_AA | e);
+	*pda1 = _reg_read_4(SH4_UTLB_DA1 | e);
+	*pda2 = _reg_read_4(SH4_UTLB_DA2 | e);
+}
+#endif	/* SH4 */
+
+
 static void
 __db_tlbdump_pfn(uint32_t r)
 {



CVS commit: src/doc

2020-08-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Aug  3 01:38:10 UTC 2020

Modified Files:
src/doc: 3RDPARTY

Log Message:
fix blocklist mailing list, update bind


To generate a diff of this commit:
cvs rdiff -u -r1.1738 -r1.1739 src/doc/3RDPARTY

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1738 src/doc/3RDPARTY:1.1739
--- src/doc/3RDPARTY:1.1738	Sun Aug  2 16:39:52 2020
+++ src/doc/3RDPARTY	Sun Aug  2 21:38:10 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1738 2020/08/02 20:39:52 christos Exp $
+#	$NetBSD: 3RDPARTY,v 1.1739 2020/08/03 01:38:10 christos Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -121,11 +121,11 @@ bc includes dc, both of which are in the
 
 Package:	bind [named and utils]
 Version:	9.16.3/MPL
-Current Vers:	9.16.3/MPL
+Current Vers:	9.16.5/MPL 9.17.3/MPL
 Maintainer:	ISC
 Archive Site:	ftp://ftp.isc.org/isc/bind9/
 Home Page:	http://www.isc.org/software/bind/
-Date:		2020-06-13
+Date:		2020-08-02
 Mailing List:	https://lists.isc.org/mailman/listinfo/bind-announce
 Mailing List:	https://lists.isc.org/mailman/listinfo/bind-users
 Responsible:	christos
@@ -145,7 +145,6 @@ Maintainer:	Christos Zoulas https://github.com/zoulasc/blocklist
 Home Page:	https://github.com/zoulasc/blocklist
 Date:		2020-06-13
-Mailing List:	bug...@gnu.org
 Responsible:	christos
 License:	BSD-like (2-clause) 
 Location:	external/bsd/blocklist



CVS commit: src/sys/arch/sh3/sh3

2020-08-02 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Aug  3 01:18:45 UTC 2020

Modified Files:
src/sys/arch/sh3/sh3: db_interface.c

Log Message:
Declare __db_cachedump_sh3/sh4 __noinline too.

Previous commit only did that for the definitions.  Forgot to apply
the attribute to the declarations too.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/sh3/sh3/db_interface.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/sh3/sh3/db_interface.c
diff -u src/sys/arch/sh3/sh3/db_interface.c:1.62 src/sys/arch/sh3/sh3/db_interface.c:1.63
--- src/sys/arch/sh3/sh3/db_interface.c:1.62	Mon Aug  3 01:14:26 2020
+++ src/sys/arch/sh3/sh3/db_interface.c	Mon Aug  3 01:18:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.62 2020/08/03 01:14:26 uwe Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.63 2020/08/03 01:18:45 uwe Exp $	*/
 
 /*-
  * Copyright (C) 2002 UCHIYAMA Yasushi.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.62 2020/08/03 01:14:26 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.63 2020/08/03 01:18:45 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -74,10 +74,10 @@ static void __db_tlbdump_page_size_sh4(u
 
 static void db_cachedump_cmd(db_expr_t, bool, db_expr_t, const char *);
 #ifdef SH3
-static void __db_cachedump_sh3(vaddr_t);
+static __noinline void __db_cachedump_sh3(vaddr_t);
 #endif
 #ifdef SH4
-static void __db_cachedump_sh4(vaddr_t);
+static __noinline void __db_cachedump_sh4(vaddr_t);
 #endif
 
 static void db_frame_cmd(db_expr_t, bool, db_expr_t, const char *);



CVS commit: src/sys/arch/sh3/sh3

2020-08-02 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Aug  3 01:14:26 UTC 2020

Modified Files:
src/sys/arch/sh3/sh3: db_interface.c

Log Message:
db_cachedump_cmd - call the dump function via P2 directly.

Instead of calling RUN_P2 at the very beginning of both cpu-specific
cache dump functions just call them via P2 pointers.  This effectively
just makes db_cachedump_cmd into a shared RUN_P2 code for both of
them.  Drop RUN_P1 at the end as we are getting back to P1 anyway
because that's where the return address is.  Any necessary padding is
provided by the sh_icache_sync_all() call.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sh3/sh3/db_interface.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/sh3/sh3/db_interface.c
diff -u src/sys/arch/sh3/sh3/db_interface.c:1.61 src/sys/arch/sh3/sh3/db_interface.c:1.62
--- src/sys/arch/sh3/sh3/db_interface.c:1.61	Fri Jan 28 21:06:07 2011
+++ src/sys/arch/sh3/sh3/db_interface.c	Mon Aug  3 01:14:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.61 2011/01/28 21:06:07 uwe Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.62 2020/08/03 01:14:26 uwe Exp $	*/
 
 /*-
  * Copyright (C) 2002 UCHIYAMA Yasushi.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.61 2011/01/28 21:06:07 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.62 2020/08/03 01:14:26 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -447,25 +447,27 @@ static void
 db_cachedump_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
 const char *modif)
 {
+	void (*cachedump_p2)(vaddr_t);
+
 #ifdef SH3
 	if (CPU_IS_SH3)
-		__db_cachedump_sh3(have_addr ? addr : 0);
+		cachedump_p2 = (void *)SH3_P1SEG_TO_P2SEG(__db_cachedump_sh3);
 #endif
 #ifdef SH4
 	if (CPU_IS_SH4)
-		__db_cachedump_sh4(have_addr ? addr : 0);
+		cachedump_p2 = (void *)SH3_P1SEG_TO_P2SEG(__db_cachedump_sh4);
 #endif
+	(*cachedump_p2)(have_addr ? addr : 0);
 }
 
 #ifdef SH3
-static void
+static __noinline void
 __db_cachedump_sh3(vaddr_t va_start)
 {
 	uint32_t r;
 	vaddr_t va, va_end, cca;
 	int entry, way;
 
-	RUN_P2;
 	/* disable cache */
 	_reg_write_4(SH3_CCR,
 	_reg_read_4(SH3_CCR) & ~SH3_CCR_CE);
@@ -497,20 +499,16 @@ __db_cachedump_sh3(vaddr_t va_start)
 	/* enable cache */
 	_reg_bset_4(SH3_CCR, SH3_CCR_CE);
 	sh_icache_sync_all();
-
-	RUN_P1;
 }
 #endif /* SH3 */
 
 #ifdef SH4
-static void
+static __noinline void
 __db_cachedump_sh4(vaddr_t va)
 {
 	uint32_t r, e;
 	int i, istart, iend;
 
-	RUN_P2; /* must access from P2 */
-
 	/* disable I/D-cache */
 	_reg_write_4(SH4_CCR,
 	_reg_read_4(SH4_CCR) & ~(SH4_CCR_ICE | SH4_CCR_OCE));
@@ -548,8 +546,6 @@ __db_cachedump_sh4(vaddr_t va)
 	_reg_write_4(SH4_CCR,
 	_reg_read_4(SH4_CCR) | SH4_CCR_ICE | SH4_CCR_OCE);
 	sh_icache_sync_all();
-
-	RUN_P1;
 }
 #endif /* SH4 */
 



CVS commit: othersrc/external/historical/eawk

2020-08-02 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Mon Aug  3 00:43:12 UTC 2020

Modified Files:
othersrc/external/historical/eawk/dist: ext.c
othersrc/external/historical/eawk/lib: Makefile

Log Message:
Make this compile with gcc 8.4.0


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/external/historical/eawk/dist/ext.c
cvs rdiff -u -r1.2 -r1.3 othersrc/external/historical/eawk/lib/Makefile

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

Modified files:

Index: othersrc/external/historical/eawk/dist/ext.c
diff -u othersrc/external/historical/eawk/dist/ext.c:1.1 othersrc/external/historical/eawk/dist/ext.c:1.2
--- othersrc/external/historical/eawk/dist/ext.c:1.1	Fri May 31 05:56:36 2013
+++ othersrc/external/historical/eawk/dist/ext.c	Mon Aug  3 00:43:12 2020
@@ -100,7 +100,8 @@ eawk_use_module(eawk_t *eawk, const char
 	void		*init;
 	void		*lib;
 	char		 path[MAXPATHLEN];
-	char		 buf[64];
+	char		 buf[MAXPATHLEN * 2];
+	char		 funcname[64];
 	int		(*func)(eawk_t *);
 
 	if (eawk_find_lib(eawk, module) < 0) {
@@ -110,9 +111,9 @@ eawk_use_module(eawk_t *eawk, const char
 			fprintf(stderr, "%s\n", buf);
 			return 0;
 		}
-		snprintf(buf, sizeof(buf), "eawk_use_%s", module);
-		if ((init = dlsym(lib, buf)) == NULL) {
-			snprintf(buf, sizeof(buf), "lib \"%s\" func %s not found", path, buf);
+		snprintf(funcname, sizeof(funcname), "eawk_use_%s", module);
+		if ((init = dlsym(lib, funcname)) == NULL) {
+			snprintf(buf, sizeof(buf), "lib \"%s\" func %s not found", path, funcname);
 			fprintf(stderr, "%s\n", buf);
 			return 0;
 		}

Index: othersrc/external/historical/eawk/lib/Makefile
diff -u othersrc/external/historical/eawk/lib/Makefile:1.2 othersrc/external/historical/eawk/lib/Makefile:1.3
--- othersrc/external/historical/eawk/lib/Makefile:1.2	Wed Jan 17 01:38:37 2018
+++ othersrc/external/historical/eawk/lib/Makefile	Mon Aug  3 00:43:12 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2018/01/17 01:38:37 agc Exp $
+#	$NetBSD: Makefile,v 1.3 2020/08/03 00:43:12 agc Exp $
 
 .include 
 
@@ -11,6 +11,7 @@ CPPFLAGS+=	-I. -I${DIST} -DHAS_ISBLANK
 YFLAGS+= -p eawk_ -d 
 CPPFLAGS.run.c+= -Wno-format-nonliteral
 CPPFLAGS.tran.c+= -Wno-format-nonliteral
+CPPFLAGS.lex.c+= -Wno-multistatement-macros
 #CPPFLAGS+= -DYYPARSE_PARAM_TYPE='void *'
 #CPPFLAGS+= -DYYPARSE_PARAM=awkp
 #CPPFLAGS+= -DYYLEX_PARAM=awkp



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

2020-08-02 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Aug  2 23:20:25 UTC 2020

Modified Files:
src/sys/arch/mips/include: mipsNN.h

Log Message:
Document the PerfCntCrl registers (CP0 Register 25, Selects 0, 2, 4, 6).


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/mips/include/mipsNN.h

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

Modified files:

Index: src/sys/arch/mips/include/mipsNN.h
diff -u src/sys/arch/mips/include/mipsNN.h:1.11 src/sys/arch/mips/include/mipsNN.h:1.12
--- src/sys/arch/mips/include/mipsNN.h:1.11	Fri Jul 31 03:35:05 2020
+++ src/sys/arch/mips/include/mipsNN.h	Sun Aug  2 23:20:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mipsNN.h,v 1.11 2020/07/31 03:35:05 simonb Exp $	*/
+/*	$NetBSD: mipsNN.h,v 1.12 2020/08/02 23:20:25 simonb Exp $	*/
 
 /*
  * Copyright 2000, 2001
@@ -473,6 +473,48 @@
 
 
 /*
+ * Values in PerfCntCrl Register (CP0 Register 25, Selects 0, 2, 4, 6)
+ */
+
+/* "M" (R): next PerCntCtl register present. */
+#define	MIPSNN_PERFCTL_M__BIT(31)
+
+/* "W" (R): Width - is a 64-bit counter. */
+#define	MIPSNN_PERFCTL_W__BIT(30)
+
+/* "Impl" (RAZ): Impl - implementation dependent field. */
+#define	MIPSNN_PERFCTL_IMPL__BITS(29,25)
+
+/* "EC" (Z): Reserved for Virtualisation Mode. */
+#define	MIPSNN_PERFCTL_EC__BITS(24,23)
+
+/* "PCTD" (RW): Performance Counter Trace Disable. */
+#define	MIPSNN_PERFCTL_PCTD__BIT(15)
+
+/*
+ * "EVENT" (RW): Event number.  Note: The MIPS32/MIPS64 PRA specs define
+ * EventExt from 14:11 and Event from 10:5.  For ease of use, we define a
+ * single 10 bit Event field.
+ */
+#define	MIPSNN_PERFCTL_EVENT__BITS(14,5)
+
+/* "IE" (RW): Interrupt Enable. */
+#define	MIPSNN_PERFCTL_IE__BIT(4)
+
+/* "U" (RW): Enables event counting in user mode. */
+#define	MIPSNN_PERFCTL_U__BIT(3)
+
+/* "S" (RW): Enables event counting in supervisor mode. */
+#define	MIPSNN_PERFCTL_S__BIT(2)
+
+/* "K" (RW): Enables event counting in kernel mode. */
+#define	MIPSNN_PERFCTL_K__BIT(1)
+
+/* "EXL" (RW): Enables event counting when EXL bit in Status is one. */
+#define	MIPSNN_PERFCTL_EXL__BIT(0)
+
+
+/*
  * Values in Configuration Register 6 (CP0 Register 16, Select 6)
  * for RMI XLP processors
  */



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

2020-08-02 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Aug  2 23:04:23 UTC 2020

Modified Files:
src/sys/arch/mips/include: cpuregs.h

Log Message:
Add a few more perfcnt CP0 registers.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/mips/include/cpuregs.h

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

Modified files:

Index: src/sys/arch/mips/include/cpuregs.h
diff -u src/sys/arch/mips/include/cpuregs.h:1.107 src/sys/arch/mips/include/cpuregs.h:1.108
--- src/sys/arch/mips/include/cpuregs.h:1.107	Fri Jul 31 02:56:48 2020
+++ src/sys/arch/mips/include/cpuregs.h	Sun Aug  2 23:04:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuregs.h,v 1.107 2020/07/31 02:56:48 simonb Exp $	*/
+/*	$NetBSD: cpuregs.h,v 1.108 2020/08/02 23:04:23 simonb Exp $	*/
 
 /*
  * Copyright (c) 2009 Miodrag Vallat.
@@ -547,6 +547,10 @@
  * 25/1	MIPS_COP_0_PERFCNT0_CNT	..ii Performance Counter 0 value register.
  * 25/2	MIPS_COP_0_PERFCNT1_CTL	..ii Performance Counter 1 control register.
  * 25/3	MIPS_COP_0_PERFCNT1_CNT	..ii Performance Counter 1 value register.
+ * 25/4	MIPS_COP_0_PERFCNT0_CTL	..ii Performance Counter 2 control register.
+ * 25/5	MIPS_COP_0_PERFCNT0_CNT	..ii Performance Counter 2 value register.
+ * 25/6	MIPS_COP_0_PERFCNT1_CTL	..ii Performance Counter 3 control register.
+ * 25/7	MIPS_COP_0_PERFCNT1_CNT	..ii Performance Counter 3 value register.
  * 26	MIPS_COP_0_ECC		.3ii ECC / Error Control register.
  * 27	MIPS_COP_0_CACHE_ERR	.3ii Cache Error register.
  * 27	MIPS_COP_0_CACHE_ERR_I	...6 [CAVIUM] Cache Error register (instr).
@@ -657,6 +661,10 @@
 #define	MIPS_COP_0_PERFCNT0_CNT	_(25), 1
 #define	MIPS_COP_0_PERFCNT1_CTL	_(25), 2
 #define	MIPS_COP_0_PERFCNT1_CNT	_(25), 3
+#define	MIPS_COP_0_PERFCNT2_CTL	_(25), 4
+#define	MIPS_COP_0_PERFCNT2_CNT	_(25), 5
+#define	MIPS_COP_0_PERFCNT3_CTL	_(25), 6
+#define	MIPS_COP_0_PERFCNT3_CNT	_(25), 7
 #define	MIPS_COP_0_DATA_LO	_(28), 1
 #define	MIPS_COP_0_DATA_HI	_(29), 3
 #define	MIPS_COP_0_DATA_HI_DATA	_(29)



CVS commit: src/usr.bin/make/unit-tests

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 22:43:14 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
make(1): set more predictable environment for counter test

Having an environment variable or a global variable called "C" would
change the debug output since an existing variable is not set to the
empty value first.  See parse.c, keyword "!Var_Exists".


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/make/unit-tests/Makefile

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/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.81 src/usr.bin/make/unit-tests/Makefile:1.82
--- src/usr.bin/make/unit-tests/Makefile:1.81	Sun Aug  2 14:53:02 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun Aug  2 22:43:14 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.81 2020/08/02 14:53:02 rillig Exp $
+# $NetBSD: Makefile,v 1.82 2020/08/02 22:43:14 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -85,6 +85,7 @@ TESTS+=		varquote
 TESTS+=		varshell
 
 # Override environment variables for some of the tests.
+ENV.counter=		-i
 ENV.envfirst=		FROM_ENV=value-from-env
 ENV.export=		-i PATH=${PATH:Q}
 ENV.varmisc=		FROM_ENV=env
@@ -92,7 +93,7 @@ ENV.varmisc+=		FROM_ENV_BEFORE=env
 ENV.varmisc+=		FROM_ENV_AFTER=env
 
 # Override make flags for some of the tests; default is -k.
-FLAGS.counter=		-dv
+FLAGS.counter=		-r -dv
 FLAGS.doterror=		# none
 FLAGS.envfirst=		-e
 FLAGS.export=		-r



CVS commit: src/doc

2020-08-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug  2 20:39:52 UTC 2020

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
new acpica


To generate a diff of this commit:
cvs rdiff -u -r1.1737 -r1.1738 src/doc/3RDPARTY
cvs rdiff -u -r1.2723 -r1.2724 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/3RDPARTY
diff -u src/doc/3RDPARTY:1.1737 src/doc/3RDPARTY:1.1738
--- src/doc/3RDPARTY:1.1737	Wed Jul 29 02:50:33 2020
+++ src/doc/3RDPARTY	Sun Aug  2 16:39:52 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1737 2020/07/29 06:50:33 wiz Exp $
+#	$NetBSD: 3RDPARTY,v 1.1738 2020/08/02 20:39:52 christos Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -41,12 +41,12 @@
 #
 
 Package:	acpica
-Version:	20200430
-Current Vers:	20200528
+Version:	20200717
+Current Vers:	20200717
 Maintainer:	Intel
 Archive Site:	http://www.acpica.org/downloads/
 Home Page:	http://www.acpica.org/
-Date:		2020-06-13
+Date:		2020-08-02
 Mailing List:	de...@acpica.org
 License:	BSD-like
 Responsible:	jruoho

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2723 src/doc/CHANGES:1.2724
--- src/doc/CHANGES:1.2723	Sun Aug  2 03:15:05 2020
+++ src/doc/CHANGES	Sun Aug  2 16:39:52 2020
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2723 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2724 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -266,3 +266,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 		unconditionally. [maxv 20200801]
 	aarch64: Add support for Privileged Access Never (PAN).
 		[maxv 20200802]
+	acpi(4): Updated ACPICA to 20200717. [christos 20200802]



CVS commit: src/sys/external/bsd/acpica/dist

2020-08-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug  2 20:25:55 UTC 2020

Modified Files:
src/sys/external/bsd/acpica/dist/compiler: aslcompiler.l aslerror.c
aslload.c aslxref.c
src/sys/external/bsd/acpica/dist/debugger: dbdisply.c
src/sys/external/bsd/acpica/dist/include: acpixf.h actypes.h
src/sys/external/bsd/acpica/dist/os_specific/service_layers:
oslinuxtbl.c
src/sys/external/bsd/acpica/dist/utilities: utdecode.c utdelete.c
Removed Files:
src/sys/external/bsd/acpica/dist/generate/unix/acpinames: Makefile
src/sys/external/bsd/acpica/dist/tools/acpinames: acpinames.h anmain.c
anstubs.c antables.c

Log Message:
merge conflicts


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 \
src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/acpica/dist/compiler/aslerror.c
cvs rdiff -u -r1.18 -r1.19 \
src/sys/external/bsd/acpica/dist/compiler/aslload.c \
src/sys/external/bsd/acpica/dist/compiler/aslxref.c
cvs rdiff -u -r1.17 -r1.18 \
src/sys/external/bsd/acpica/dist/debugger/dbdisply.c
cvs rdiff -u -r1.1.1.10 -r0 \
src/sys/external/bsd/acpica/dist/generate/unix/acpinames/Makefile
cvs rdiff -u -r1.26 -r1.27 src/sys/external/bsd/acpica/dist/include/acpixf.h
cvs rdiff -u -r1.21 -r1.22 src/sys/external/bsd/acpica/dist/include/actypes.h
cvs rdiff -u -r1.11 -r1.12 \
src/sys/external/bsd/acpica/dist/os_specific/service_layers/oslinuxtbl.c
cvs rdiff -u -r1.1.1.9 -r0 \
src/sys/external/bsd/acpica/dist/tools/acpinames/acpinames.h
cvs rdiff -u -r1.1.1.13 -r0 \
src/sys/external/bsd/acpica/dist/tools/acpinames/anmain.c \
src/sys/external/bsd/acpica/dist/tools/acpinames/anstubs.c
cvs rdiff -u -r1.1.1.10 -r0 \
src/sys/external/bsd/acpica/dist/tools/acpinames/antables.c
cvs rdiff -u -r1.16 -r1.17 \
src/sys/external/bsd/acpica/dist/utilities/utdecode.c
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/acpica/dist/utilities/utdelete.c

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

Modified files:

Index: src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l
diff -u src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l:1.16 src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l:1.17
--- src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l:1.16	Mon May 25 19:19:28 2020
+++ src/sys/external/bsd/acpica/dist/compiler/aslcompiler.l	Sun Aug  2 16:25:54 2020
@@ -585,6 +585,7 @@ NamePathTail[.]{NameSeg}
 "GeneralPurposeIo"  { count (0); return (PARSEOP_REGIONSPACE_GPIO); }   /* ACPI 5.0 */
 "GenericSerialBus"  { count (0); return (PARSEOP_REGIONSPACE_GSBUS); }  /* ACPI 5.0 */
 "PCC"   { count (0); return (PARSEOP_REGIONSPACE_PCC); }/* ACPI 5.0 */
+"PlatformRtMechanism"   { count (0); return (PARSEOP_REGIONSPACE_PRM); }
 "FFixedHW"  { count (0); return (PARSEOP_REGIONSPACE_FFIXEDHW); }
 
 /* ResourceTypeKeyword: Resource Usage - Resource Descriptors */

Index: src/sys/external/bsd/acpica/dist/compiler/aslerror.c
diff -u src/sys/external/bsd/acpica/dist/compiler/aslerror.c:1.15 src/sys/external/bsd/acpica/dist/compiler/aslerror.c:1.16
--- src/sys/external/bsd/acpica/dist/compiler/aslerror.c:1.15	Sat Mar 28 15:49:26 2020
+++ src/sys/external/bsd/acpica/dist/compiler/aslerror.c	Sun Aug  2 16:25:54 2020
@@ -948,7 +948,7 @@ GetModifiedLevel (
 UINT8   Level,
 UINT16  MessageId)
 {
-UINT16  i;
+UINT32  i;
 UINT16  ExceptionCode;
 
 

Index: src/sys/external/bsd/acpica/dist/compiler/aslload.c
diff -u src/sys/external/bsd/acpica/dist/compiler/aslload.c:1.18 src/sys/external/bsd/acpica/dist/compiler/aslload.c:1.19
--- src/sys/external/bsd/acpica/dist/compiler/aslload.c:1.18	Mon May 25 19:19:28 2020
+++ src/sys/external/bsd/acpica/dist/compiler/aslload.c	Sun Aug  2 16:25:54 2020
@@ -1069,13 +1069,13 @@ LdAnalyzeExternals (
  * previously declared External
  */
 Node->Flags &= ~ANOBJ_IS_EXTERNAL;
-Node->Type = (UINT8) ExternalOpType;
+Node->Type = (UINT8) ActualOpType;
 
 /* Just retyped a node, probably will need to open a scope */
 
-if (AcpiNsOpensScope (ExternalOpType))
+if (AcpiNsOpensScope (ActualOpType))
 {
-Status = AcpiDsScopeStackPush (Node, ExternalOpType, WalkState);
+Status = AcpiDsScopeStackPush (Node, ActualOpType, WalkState);
 if (ACPI_FAILURE (Status))
 {
 return (Status);
@@ -1096,11 +1096,11 @@ LdAnalyzeExternals (
 }
 else if ((Node->Flags & ANOBJ_IS_EXTERNAL) &&
  (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) &&
- (ExternalOpType == ACPI_TYPE_ANY))
+ (ActualOpType == ACPI_TYPE_A

CVS import: src/sys/external/bsd/acpica/dist

2020-08-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug  2 20:23:36 UTC 2020

Update of /cvsroot/src/sys/external/bsd/acpica/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv8749

Log Message:
VERSION 20200717
Submitted by Bob Moore on 17 July, 2020 - 13:35

17 July 2020. Summary of changes for version 20200717:

1) ACPICA kernel-resident subsystem:

Do not increment OperationRegion reference counts for field units.
Recent server firmware has revealed that this reference count can
overflow on large servers that declare many field units (thousands)
under the same OperationRegion. This occurs because each field unit
declaration will add a reference count to the source OperationRegion.
This release solves the reference count overflow for OperationRegion
objects by preventing fieldUnits from incrementing their parent
OperationRegion's reference count.

Replaced one-element arrays with flexible-arrays, which were
introduced in C99.

Restored the readme file containing the directions for generation
of ACPICA from source on MSVC 2017. Updated the file for MSVC 2017.
File is located at: generate/msvc2017/readme.txt

2) iASL Compiler/Disassembler and ACPICA tools:

iASL: Fixed a regression found in version 20200214. Prevent iASL
from emitting an extra byte of garbage data when control methods
declared a single parameter type without using braces. This extra
byte is known to cause a blue screen on the Windows AML interpreter.

iASL: Made a change to allow external declarations to specify the
type of a named object even when some name segments are not defined.
This change allows the following ASL code to compile (When DEV0 is
not defined or not defined yet):

External (\_SB.DEV0.OBJ1, IntObj)
External (\_SB.DEV0, DeviceObj)

iASL: Fixed a problem where method names in "Alias ()" statement
could be misinterpreted. They are now interpreted correctly as
method invocations.

iASL: capture a method parameter count (Within the Method info
segment, as well as the argument node) when using parameter type
lists.

VERSION 20200528
Submitted by Bob Moore on 28 May, 2020 - 13:24

28 May 2020. Summary of changes for version 20200528:

1) ACPICA kernel-resident subsystem:

Removed old/obsolete Visual Studio files which were used to build
the Windows versions of the ACPICA tools. Since we have moved to
Visual Studio 2017, we are no longer supporting Visual Studio 2006
and 2009 project files. The new subdirectory and solution file are
located at:

acpica/generate/msvc2017/AcpiComponents.sln

2) iASL Compiler/Disassembler and ACPICA tools:

iASL: added support for a new OperationRegion Address Space (subtype):
PlatformRtMechanism. Support for this new keyword is being released
for early prototyping. It will appear in the next release of the
ACPI specification.

iASL: do not optimize the NameString parameter of the CondRefOf
operator. In the previous iASL compiler release, the NameString
parameter of the CondRefOf was optimized. There is evidence that
some implementations of the AML interpreter do not perform the
recursive search-to-parent search during the execution of the
CondRefOf operator. Therefore, the CondRefOf operator behaves
differently when the NameString parameter is a single name segment
(a NameSeg) as opposed to a full NamePath (starting at the root
scope) or a NameString containing parent prefixes.

iASL: Prevent an inadvertent remark message. This change prevents
a remark if within a control method the following exist:
1) An Operation Region is defined, and
2) A Field operator is defined that refers to the region.  This
happens because at the top level, the Field operator does not
actually create a new named object, it simply references the
operation region.

Removed support for the acpinames utility. The acpinames was a
simple utility used to populate and display the ACPI namespace
without executing any AML code. However, ACPICA now supports
executable opcodes outside of control methods. This means that
executable AML opcodes such as If and Store opcodes need to be
executed during table load. Therefore, acpinames would need to be
updated to match the same behavior as the acpiexec utility and
since acpiexec can already dump the entire namespace (via the
'namespace' command), we no longer have the need to maintain
acpinames.

In order to dump the contents of the ACPI namepsace using acpiexec,
execute the following command from the command line:

acpiexec -b "n" [aml files]


Status:

Vendor Tag: intel
Release Tags:   acpica-20200717

U src/sys/external/bsd/acpica/dist/changes.txt
U src/sys/external/bsd/acpica/dist/Makefile
U src/sys/external/bsd/acpica/dist/generate/lint/files.lnt
U src/sys/external/bsd/acpica/dist/generate/lint/lint.bat
U src/sys/external/bsd/acpica/dist/generate/lint/lset.bat
U src/sys/external/bsd/acpica/dist/generate/lint/options.lnt
U src/sys/external/bsd/acpica/dist/generate/lint/readme.txt
U src/sys/external/bsd/acpica/dist/generate/lint/std16.lnt
U src/sys/exter

CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 20:13:05 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): remove duplicate code in :ts modifier

The pointer xp had already been there with the correct value, and
there's no point in not using it.  This reduces the code size on x86_64
by 48 bytes, which is more than I had expected.


To generate a diff of this commit:
cvs rdiff -u -r1.406 -r1.407 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.406 src/usr.bin/make/var.c:1.407
--- src/usr.bin/make/var.c:1.406	Sun Aug  2 19:59:17 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 20:13:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.406 2020/08/02 19:59:17 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.407 2020/08/02 20:13:05 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.406 2020/08/02 19:59:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.407 2020/08/02 20:13:05 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.406 2020/08/02 19:59:17 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.407 2020/08/02 20:13:05 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2388,7 +2388,7 @@ ApplyModifier_ToSep(const char *sep, App
 
 	char *end;
 	get_numeric:
-	st->sep = strtoul(sep + 1 + (sep[1] == 'x'), &end, base);
+	st->sep = strtoul(xp, &end, base);
 	if (*end != ':' && *end != st->endc)
 		return AMR_BAD;
 	st->next = end;



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 19:59:17 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): clean up NULL pointer comparisons, use separate variable

st->newVal is not meant to be a general-purpose storage.

Eliminate the unnecessary initialization of freeIt since Var_Parse
initializes it in every case.


To generate a diff of this commit:
cvs rdiff -u -r1.405 -r1.406 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.405 src/usr.bin/make/var.c:1.406
--- src/usr.bin/make/var.c:1.405	Sun Aug  2 19:49:17 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 19:59:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.405 2020/08/02 19:49:17 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.406 2020/08/02 19:59:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.405 2020/08/02 19:49:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.406 2020/08/02 19:59:17 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.405 2020/08/02 19:49:17 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.406 2020/08/02 19:59:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2061,7 +2061,7 @@ ApplyModifier_Path(const char *mod, Appl
 } else {
 	st->newVal = Dir_FindFile(st->v->name, Suff_FindPath(gn));
 }
-if (!st->newVal)
+if (st->newVal == NULL)
 	st->newVal = bmake_strdup(st->v->name);
 st->next = mod + 1;
 return AMR_OK;
@@ -2087,7 +2087,7 @@ ApplyModifier_Exclam(const char *mod, Ap
 	st->newVal = varNoError;
 free(cmd);
 
-if (emsg)
+if (emsg != NULL)
 	Error(emsg, st->val);	/* XXX: why still return AMR_OK? */
 
 if (st->v->flags & VAR_JUNK)
@@ -2749,12 +2749,12 @@ ApplyModifier_Assign(const char *mod, Ap
 	break;
 	case '!': {
 	const char *emsg;
-	st->newVal = Cmd_Exec(val, &emsg);
+	char *cmd_output = Cmd_Exec(val, &emsg);
 	if (emsg)
 		Error(emsg, st->val);
 	else
-		Var_Set(st->v->name, st->newVal, v_ctxt);
-	free(st->newVal);
+		Var_Set(st->v->name, cmd_output, v_ctxt);
+	free(cmd_output);
 	break;
 	}
 	case '?':
@@ -3592,7 +3592,7 @@ Var_Subst(const char *str, GNode *ctxt, 
 	Buf_AddBytesBetween(&buf, cp, str);
 	} else {
 	int length;
-	void *freeIt = NULL;
+	void *freeIt;
 	const char *val = Var_Parse(str, ctxt, eflags, &length, &freeIt);
 
 	/*



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 19:49:17 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): make :hash modifier more efficient

It's not necessary to allocate a 256-byte buffer just to store 9 bytes
in it, and to null-terminate it after writing every single byte to it.


To generate a diff of this commit:
cvs rdiff -u -r1.404 -r1.405 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.404 src/usr.bin/make/var.c:1.405
--- src/usr.bin/make/var.c:1.404	Sun Aug  2 19:11:57 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 19:49:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.404 2020/08/02 19:11:57 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.405 2020/08/02 19:49:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.404 2020/08/02 19:11:57 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.405 2020/08/02 19:49:17 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.404 2020/08/02 19:11:57 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.405 2020/08/02 19:49:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1815,14 +1815,14 @@ VarHash(const char *str)
 h *= 0xc2b2ae35;
 h ^= h >> 16;
 
-Buffer buf;
-Buf_InitZ(&buf, 0);
-for (len = 0; len < 8; ++len) {
-	Buf_AddByte(&buf, hexdigits[h & 15]);
+char *buf = bmake_malloc(9);
+size_t i;
+for (i = 0; i < 8; i++) {
+	buf[i] = hexdigits[h & 0x0f];
 	h >>= 4;
 }
-
-return Buf_Destroy(&buf, FALSE);
+buf[8] = '\0';
+return buf;
 }
 
 static char *



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 19:11:57 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): move qsort helper functions closer to ApplyModifier_Order


To generate a diff of this commit:
cvs rdiff -u -r1.403 -r1.404 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.403 src/usr.bin/make/var.c:1.404
--- src/usr.bin/make/var.c:1.403	Sun Aug  2 19:08:54 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 19:11:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.403 2020/08/02 19:08:54 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.404 2020/08/02 19:11:57 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.403 2020/08/02 19:08:54 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.404 2020/08/02 19:11:57 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.403 2020/08/02 19:08:54 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.404 2020/08/02 19:11:57 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1560,18 +1560,6 @@ ModifyWords(GNode *ctx, Byte sep, Boolea
 }
 
 
-static int
-VarWordCompare(const void *a, const void *b)
-{
-return strcmp(*(const char * const *)a, *(const char * const *)b);
-}
-
-static int
-VarWordCompareReverse(const void *a, const void *b)
-{
-return strcmp(*(const char * const *)b, *(const char * const *)a);
-}
-
 static char *
 WordList_JoinFree(char **av, int ac, char *as)
 {
@@ -2563,6 +2551,18 @@ bad_modifier:
 return AMR_BAD;
 }
 
+static int
+str_cmp_asc(const void *a, const void *b)
+{
+return strcmp(*(const char * const *)a, *(const char * const *)b);
+}
+
+static int
+str_cmp_desc(const void *a, const void *b)
+{
+return strcmp(*(const char * const *)b, *(const char * const *)a);
+}
+
 /* :O (order ascending) or :Or (order descending) or :Ox (shuffle) */
 static ApplyModifierResult
 ApplyModifier_Order(const char *mod, ApplyModifiersState *st)
@@ -2575,7 +2575,7 @@ ApplyModifier_Order(const char *mod, App
 
 if (mod[1] == st->endc || mod[1] == ':') {
 	/* :O sorts ascending */
-	qsort(av, ac, sizeof(char *), VarWordCompare);
+	qsort(av, ac, sizeof(char *), str_cmp_asc);
 
 } else if ((mod[1] == 'r' || mod[1] == 'x') &&
 	   (mod[2] == st->endc || mod[2] == ':')) {
@@ -2583,7 +2583,7 @@ ApplyModifier_Order(const char *mod, App
 
 	if (mod[1] == 'r') {
 	/* :Or sorts descending */
-	qsort(av, ac, sizeof(char *), VarWordCompareReverse);
+	qsort(av, ac, sizeof(char *), str_cmp_desc);
 
 	} else {
 	/* :Ox shuffles



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 19:08:54 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): merge duplicate code in the :O and :u modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.402 -r1.403 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.402 src/usr.bin/make/var.c:1.403
--- src/usr.bin/make/var.c:1.402	Sun Aug  2 18:57:55 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 19:08:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.402 2020/08/02 18:57:55 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.403 2020/08/02 19:08:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.402 2020/08/02 18:57:55 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.403 2020/08/02 19:08:54 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.402 2020/08/02 18:57:55 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.403 2020/08/02 19:08:54 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1572,13 +1572,29 @@ VarWordCompareReverse(const void *a, con
 return strcmp(*(const char * const *)b, *(const char * const *)a);
 }
 
-/* Remove adjacent duplicate words. */
 static char *
-VarUniq(const char *str)
+WordList_JoinFree(char **av, int ac, char *as)
 {
-Buffer buf;			/* Buffer for new string */
+Buffer buf;
 Buf_InitZ(&buf, 0);
 
+int i;
+for (i = 0; i < ac; i++) {
+	if (i != 0)
+	Buf_AddByte(&buf, ' ');
+	Buf_AddStr(&buf, av[i]);
+}
+
+free(av);
+free(as);
+
+return Buf_Destroy(&buf, FALSE);
+}
+
+/* Remove adjacent duplicate words. */
+static char *
+VarUniq(const char *str)
+{
 char *as;			/* Word list memory */
 int ac;
 char **av = brk_string(str, &ac, FALSE, &as);
@@ -1591,17 +1607,7 @@ VarUniq(const char *str)
 	ac = j + 1;
 }
 
-int i;
-for (i = 0; i < ac; i++) {
-	if (i != 0)
-	Buf_AddByte(&buf, ' ');
-	Buf_AddStr(&buf, av[i]);
-}
-
-free(as);
-free(av);
-
-return Buf_Destroy(&buf, FALSE);
+return WordList_JoinFree(av, ac, as);
 }
 
 
@@ -2601,20 +2607,7 @@ ApplyModifier_Order(const char *mod, App
 	return AMR_BAD;
 }
 
-Buffer buf;
-Buf_InitZ(&buf, 0);
-
-int i;
-for (i = 0; i < ac; i++) {
-	if (i != 0)
-	Buf_AddByte(&buf, ' ');
-	Buf_AddStr(&buf, av[i]);
-}
-
-free(as);
-free(av);
-
-st->newVal = Buf_Destroy(&buf, FALSE);
+st->newVal = WordList_JoinFree(av, ac, as);
 return AMR_OK;
 }
 



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 18:57:55 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): inline VarOrder into ApplyModifier_Order

Removing the extra mapping layer "otype" makes the code both faster and
smaller.


To generate a diff of this commit:
cvs rdiff -u -r1.401 -r1.402 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.401 src/usr.bin/make/var.c:1.402
--- src/usr.bin/make/var.c:1.401	Sun Aug  2 18:23:00 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 18:57:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.401 2020/08/02 18:23:00 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.402 2020/08/02 18:57:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.401 2020/08/02 18:23:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.402 2020/08/02 18:57:55 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.401 2020/08/02 18:23:00 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.402 2020/08/02 18:57:55 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1572,70 +1572,6 @@ VarWordCompareReverse(const void *a, con
 return strcmp(*(const char * const *)b, *(const char * const *)a);
 }
 
-/*-
- *---
- * VarOrder --
- *	Order the words in the string.
- *
- * Input:
- *	str		String whose words should be sorted.
- *	otype		How to order: s - sort, r - reverse, x - random.
- *
- * Results:
- *	A string containing the words ordered.
- *---
- */
-static char *
-VarOrder(const char *str, const char otype)
-{
-Buffer buf;			/* Buffer for the new string */
-Buf_InitZ(&buf, 0);
-
-char **av;			/* word list */
-char *as;			/* word list memory */
-int ac;
-av = brk_string(str, &ac, FALSE, &as);
-
-if (ac > 0) {
-	switch (otype) {
-	case 'r':		/* reverse sort alphabetically */
-	qsort(av, ac, sizeof(char *), VarWordCompareReverse);
-	break;
-	case 's':		/* sort alphabetically */
-	qsort(av, ac, sizeof(char *), VarWordCompare);
-	break;
-	case 'x':		/* randomize */
-	/*
-	 * We will use [ac..2] range for mod factors. This will produce
-	 * random numbers in [(ac-1)..0] interval, and minimal
-	 * reasonable value for mod factor is 2 (the mod 1 will produce
-	 * 0 with probability 1).
-	 */
-	(void)0;
-	int i;
-	for (i = ac - 1; i > 0; i--) {
-		int rndidx = random() % (i + 1);
-		char *t = av[i];
-		av[i] = av[rndidx];
-		av[rndidx] = t;
-	}
-	}
-}
-
-int i;
-for (i = 0; i < ac; i++) {
-	if (i != 0)
-	Buf_AddByte(&buf, ' ');
-	Buf_AddStr(&buf, av[i]);
-}
-
-free(as);
-free(av);
-
-return Buf_Destroy(&buf, FALSE);
-}
-
-
 /* Remove adjacent duplicate words. */
 static char *
 VarUniq(const char *str)
@@ -2621,23 +2557,64 @@ bad_modifier:
 return AMR_BAD;
 }
 
-/* :O or :Or or :Ox */
+/* :O (order ascending) or :Or (order descending) or :Ox (shuffle) */
 static ApplyModifierResult
 ApplyModifier_Order(const char *mod, ApplyModifiersState *st)
 {
-st->next = mod + 1;	/* skip to the rest in any case */
+st->next = mod + 1;		/* skip past the 'O' in any case */
+
+char *as;			/* word list memory */
+int ac;
+char **av = brk_string(st->val, &ac, FALSE, &as);
 
-char otype;
 if (mod[1] == st->endc || mod[1] == ':') {
-	otype = 's';
+	/* :O sorts ascending */
+	qsort(av, ac, sizeof(char *), VarWordCompare);
+
 } else if ((mod[1] == 'r' || mod[1] == 'x') &&
 	   (mod[2] == st->endc || mod[2] == ':')) {
-	otype = mod[1];
 	st->next = mod + 2;
+
+	if (mod[1] == 'r') {
+	/* :Or sorts descending */
+	qsort(av, ac, sizeof(char *), VarWordCompareReverse);
+
+	} else {
+	/* :Ox shuffles
+	 *
+	 * We will use [ac..2] range for mod factors. This will produce
+	 * random numbers in [(ac-1)..0] interval, and minimal
+	 * reasonable value for mod factor is 2 (the mod 1 will produce
+	 * 0 with probability 1).
+	 */
+	int i;
+	for (i = ac - 1; i > 0; i--) {
+		int rndidx = random() % (i + 1);
+		char *t = av[i];
+		av[i] = av[rndidx];
+		av[rndidx] = t;
+	}
+	}
 } else {
+	free(as);
+	free(av);
 	return AMR_BAD;
 }
-st->newVal = VarOrder(st->val, otype);
+
+Buffer buf;
+Buf_InitZ(&buf, 0);
+
+int i;
+for (i = 0; i < ac; i++) {
+	if (i != 0)
+	Buf_AddByte(&buf, ' ');
+	Buf_AddStr(&buf, av[i]);
+}
+
+free(as);
+free(av);
+
+st->newVal = Buf_Destroy(&buf, FALSE);
 return AMR_OK;
 }
 



CVS commit: src/sys/arch/x86/x86

2020-08-02 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug  2 18:23:33 UTC 2020

Modified Files:
src/sys/arch/x86/x86: fpu.c

Log Message:
Revert "Add kthread_fpu_enter/exit support to x86." for now.

Need to find all the paths out of interrupts back into _kernel_
context to add HANDLE_DEFERRED_FPU, I think, before this can be
enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/x86/x86/fpu.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/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.73 src/sys/arch/x86/x86/fpu.c:1.74
--- src/sys/arch/x86/x86/fpu.c:1.73	Sat Aug  1 02:13:34 2020
+++ src/sys/arch/x86/x86/fpu.c	Sun Aug  2 18:23:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.73 2020/08/01 02:13:34 riastradh Exp $	*/
+/*	$NetBSD: fpu.c,v 1.74 2020/08/02 18:23:33 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.73 2020/08/01 02:13:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.74 2020/08/02 18:23:33 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -107,7 +107,6 @@ __KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.73
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -132,35 +131,13 @@ void fpu_switch(struct lwp *, struct lwp
 
 uint32_t x86_fpu_mxcsr_mask __read_mostly = 0;
 
-/*
- * True if this a thread that is allowed to use the FPU -- either a
- * user thread, or a system thread with LW_SYSTEM_FPU enabled.
- */
-static inline bool
-lwp_can_haz_fpu(struct lwp *l)
-{
-
-	return (l->l_flag & (LW_SYSTEM|LW_SYSTEM_FPU)) != LW_SYSTEM;
-}
-
-/*
- * True if this is a system thread with its own private FPU state.
- */
-static inline bool
-lwp_system_fpu_p(struct lwp *l)
-{
-
-	return (l->l_flag & (LW_SYSTEM|LW_SYSTEM_FPU)) ==
-	(LW_SYSTEM|LW_SYSTEM_FPU);
-}
-
 static inline union savefpu *
 fpu_lwp_area(struct lwp *l)
 {
 	struct pcb *pcb = lwp_getpcb(l);
 	union savefpu *area = &pcb->pcb_savefpu;
 
-	KASSERT(lwp_can_haz_fpu(l));
+	KASSERT((l->l_flag & LW_SYSTEM) == 0);
 	if (l == curlwp) {
 		fpu_save();
 	}
@@ -178,7 +155,7 @@ fpu_save_lwp(struct lwp *l)
 
 	s = splvm();
 	if (l->l_md.md_flags & MDL_FPU_IN_CPU) {
-		KASSERT(lwp_can_haz_fpu(l));
+		KASSERT((l->l_flag & LW_SYSTEM) == 0);
 		fpu_area_save(area, x86_xsave_features);
 		l->l_md.md_flags &= ~MDL_FPU_IN_CPU;
 	}
@@ -330,7 +307,7 @@ fpu_switch(struct lwp *oldlwp, struct lw
 	cpu_index(ci), ci->ci_ilevel);
 
 	if (oldlwp->l_md.md_flags & MDL_FPU_IN_CPU) {
-		KASSERT(lwp_can_haz_fpu(oldlwp));
+		KASSERT(!(oldlwp->l_flag & LW_SYSTEM));
 		pcb = lwp_getpcb(oldlwp);
 		fpu_area_save(&pcb->pcb_savefpu, x86_xsave_features);
 		oldlwp->l_md.md_flags &= ~MDL_FPU_IN_CPU;
@@ -345,11 +322,11 @@ fpu_lwp_fork(struct lwp *l1, struct lwp 
 	union savefpu *fpu_save;
 
 	/* Kernel threads have no FPU. */
-	if (__predict_false(!lwp_can_haz_fpu(l2))) {
+	if (__predict_false(l2->l_flag & LW_SYSTEM)) {
 		return;
 	}
 	/* For init(8). */
-	if (__predict_false(!lwp_can_haz_fpu(l1))) {
+	if (__predict_false(l1->l_flag & LW_SYSTEM)) {
 		memset(&pcb2->pcb_savefpu, 0, x86_fpu_save_size);
 		return;
 	}
@@ -373,8 +350,6 @@ fpu_lwp_abandon(struct lwp *l)
 
 /* -- */
 
-static const union savefpu zero_fpu __aligned(64);
-
 /*
  * fpu_kern_enter()
  *
@@ -394,11 +369,6 @@ fpu_kern_enter(void)
 	struct cpu_info *ci;
 	int s;
 
-	if (lwp_system_fpu_p(l) && !cpu_intr_p()) {
-		KASSERT(!cpu_softintr_p());
-		return;
-	}
-
 	s = splvm();
 
 	ci = curcpu();
@@ -431,16 +401,10 @@ fpu_kern_enter(void)
 void
 fpu_kern_leave(void)
 {
-	struct cpu_info *ci;
+	static const union savefpu zero_fpu __aligned(64);
+	struct cpu_info *ci = curcpu();
 	int s;
 
-	if (lwp_system_fpu_p(curlwp) && !cpu_intr_p()) {
-		KASSERT(!cpu_softintr_p());
-		return;
-	}
-
-	ci = curcpu();
-
 	KASSERT(ci->ci_ilevel == IPL_VM);
 	KASSERT(ci->ci_kfpu_spl != -1);
 
@@ -462,23 +426,6 @@ fpu_kern_leave(void)
 	splx(s);
 }
 
-void
-kthread_fpu_enter_md(void)
-{
-
-	/* Enable the FPU by clearing CR0_TS.  */
-	clts();
-}
-
-void
-kthread_fpu_exit_md(void)
-{
-
-	/* Zero the FPU state and disable the FPU by setting CR0_TS.  */
-	fpu_area_restore(&zero_fpu, x86_xsave_features);
-	stts();
-}
-
 /* -- */
 
 /*



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 18:23:00 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): reduce scope of variables

This groups the variables by topic and only introduces them when they
are actually needed.  The compiler doesn't care, but during a debugging
session this means fewer uninitialized variables.

In VarUniq, the variable i has been split into two.  All others remain
exactly as before, just with a smaller scope.


To generate a diff of this commit:
cvs rdiff -u -r1.400 -r1.401 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.400 src/usr.bin/make/var.c:1.401
--- src/usr.bin/make/var.c:1.400	Sun Aug  2 17:10:54 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 18:23:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.400 2020/08/02 17:10:54 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.401 2020/08/02 18:23:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.400 2020/08/02 17:10:54 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.401 2020/08/02 18:23:00 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.400 2020/08/02 17:10:54 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.401 2020/08/02 18:23:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -468,9 +468,6 @@ static int
 Var_Export1(const char *name, VarExportFlags flags)
 {
 char tmp[BUFSIZ];
-Var *v;
-char *val = NULL;
-int n;
 VarExportFlags parent = flags & VAR_EXPORT_PARENT;
 
 if (*name == '.')
@@ -490,12 +487,15 @@ Var_Export1(const char *name, VarExportF
 	return 0;
 	}
 }
-v = VarFind(name, VAR_GLOBAL, 0);
+
+Var *v = VarFind(name, VAR_GLOBAL, 0);
 if (v == NULL)
 	return 0;
+
 if (!parent && (v->flags & VAR_EXPORTED) && !(v->flags & VAR_REEXPORT))
 	return 0;		/* nothing to do */
-val = Buf_GetAllZ(&v->val, NULL);
+
+char *val = Buf_GetAllZ(&v->val, NULL);
 if (!(flags & VAR_EXPORT_LITERAL) && strchr(val, '$')) {
 	if (parent) {
 	/*
@@ -513,7 +513,7 @@ Var_Export1(const char *name, VarExportF
 	 */
 	return 0;
 	}
-	n = snprintf(tmp, sizeof(tmp), "${%s}", name);
+	int n = snprintf(tmp, sizeof(tmp), "${%s}", name);
 	if (n < (int)sizeof(tmp)) {
 	val = Var_Subst(tmp, VAR_GLOBAL, VARE_WANTRES);
 	setenv(name, val, 1);
@@ -547,15 +547,13 @@ Var_ExportVars_callback(void *entry, voi
 void
 Var_ExportVars(void)
 {
-char tmp[BUFSIZ];
-char *val;
-
 /*
  * Several make's support this sort of mechanism for tracking
  * recursion - but each uses a different name.
  * We allow the makefiles to update MAKELEVEL and ensure
  * children see a correctly incremented value.
  */
+char tmp[BUFSIZ];
 snprintf(tmp, sizeof(tmp), "%d", makelevel + 1);
 setenv(MAKE_LEVEL_ENV, tmp, 1);
 
@@ -568,7 +566,7 @@ Var_ExportVars(void)
 	return;
 }
 
-val = Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL, VARE_WANTRES);
+char *val = Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL, VARE_WANTRES);
 if (*val) {
 	char **av;
 	char *as;
@@ -591,18 +589,12 @@ Var_ExportVars(void)
 void
 Var_Export(char *str, int isExport)
 {
-char **av;
-char *as;
-VarExportFlags flags;
-int ac;
-int i;
-
 if (isExport && (!str || !str[0])) {
 	var_exportedVars = VAR_EXPORTED_ALL; /* use with caution! */
 	return;
 }
 
-flags = 0;
+VarExportFlags flags = 0;
 if (strncmp(str, "-env", 4) == 0) {
 	str += 4;
 } else if (strncmp(str, "-literal", 8) == 0) {
@@ -614,7 +606,11 @@ Var_Export(char *str, int isExport)
 
 char *val = Var_Subst(str, VAR_GLOBAL, VARE_WANTRES);
 if (*val) {
-	av = brk_string(val, &ac, FALSE, &as);
+	char *as;
+	int ac;
+	char **av = brk_string(val, &ac, FALSE, &as);
+
+	int i;
 	for (i = 0; i < ac; i++) {
 	const char *name = av[i];
 	if (!name[1]) {
@@ -660,13 +656,12 @@ Var_UnExport(char *str)
 char tmp[BUFSIZ];
 char *vlist;
 char *cp;
-Boolean unexport_env;
 int n;
 
 vlist = NULL;
 
 str += strlen("unexport");
-unexport_env = strncmp(str, "-env", 4) == 0;
+Boolean unexport_env = strncmp(str, "-env", 4) == 0;
 if (unexport_env) {
 	char **newenv;
 
@@ -748,7 +743,6 @@ static void
 Var_Set_with_flags(const char *name, const char *val, GNode *ctxt,
 		   VarSet_Flags flags)
 {
-Var *v;
 char *name_freeIt = NULL;
 
 /*
@@ -770,6 +764,7 @@ Var_Set_with_flags(const char *name, con
 	}
 }
 
+Var *v;
 if (ctxt == VAR_GLOBAL) {
 	v = VarFind(name, VAR_CMD, 0);
 	if (v != NULL) {
@@ -895,8 +890,6 @@ Var_Set(const char *name, const char *va
 void
 Var_Append(const char *name, const ch

CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 17:10:54 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): clean up comments in var.c

Some of the effects listed in "Side Effects" were really "Main Effects"
and have been moved to the main description.

VarAdd: There's no "front" in a hash table.

VarHash: A const char * is not a "String to modify".

Var_Subst: Even in r1.1 of var.c, there was no "variable structure to
store in" anywhere nearby.


To generate a diff of this commit:
cvs rdiff -u -r1.399 -r1.400 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.399 src/usr.bin/make/var.c:1.400
--- src/usr.bin/make/var.c:1.399	Sun Aug  2 16:06:49 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 17:10:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.399 2020/08/02 16:06:49 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.400 2020/08/02 17:10:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.399 2020/08/02 16:06:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.400 2020/08/02 17:10:54 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.399 2020/08/02 16:06:49 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.400 2020/08/02 17:10:54 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -393,10 +393,7 @@ VarFind(const char *name, GNode *ctxt, V
  *	destroy		true if the value buffer should be destroyed.
  *
  * Results:
- *	1 if it is an environment variable 0 ow.
- *
- * Side Effects:
- *	The variable is free'ed if it is an environent variable.
+ *	TRUE if it is an environment variable, FALSE otherwise.
  *---
  */
 static Boolean
@@ -410,22 +407,8 @@ VarFreeEnv(Var *v, Boolean destroy)
 return TRUE;
 }
 
-/*-
- *---
- * VarAdd  --
- *	Add a new variable of name name and value val to the given context
- *
- * Input:
- *	name		name of variable to add
- *	val		value to set it to
- *	ctxt		context in which to set it
- *
- * Side Effects:
- *	The new variable is placed at the front of the given context
- *	The name and val arguments are duplicated so they may
- *	safely be freed.
- *---
- */
+/* Add a new variable of the given name and value to the given context.
+ * The name and val arguments are duplicated so they may safely be freed. */
 static void
 VarAdd(const char *name, const char *val, GNode *ctxt)
 {
@@ -445,16 +428,7 @@ VarAdd(const char *name, const char *val
 }
 }
 
-/*-
- *---
- * Var_Delete --
- *	Remove a variable from a context.
- *
- * Side Effects:
- *	The Var structure is removed and freed.
- *
- *---
- */
+/* Remove a variable from a context, freeing the Var structure as well. */
 void
 Var_Delete(const char *name, GNode *ctxt)
 {
@@ -484,7 +458,7 @@ Var_Delete(const char *name, GNode *ctxt
 
 
 /*
- * Export a var.
+ * Export a variable.
  * We ignore make internal variables (those which start with '.')
  * Also we jump through some hoops to avoid calling setenv
  * more than necessary since it can leak.
@@ -611,9 +585,8 @@ Var_ExportVars(void)
 }
 
 /*
- * This is called when .export is seen or
- * .MAKE.EXPORTED is modified.
- * It is also called when any exported var is modified.
+ * This is called when .export is seen or .MAKE.EXPORTED is modified.
+ * It is also called when any exported variable is modified.
  */
 void
 Var_Export(char *str, int isExport)
@@ -770,6 +743,7 @@ Var_UnExport(char *str)
 }
 }
 
+/* See Var_Set for documentation. */
 static void
 Var_Set_with_flags(const char *name, const char *val, GNode *ctxt,
 		   VarSet_Flags flags)
@@ -795,6 +769,7 @@ Var_Set_with_flags(const char *name, con
 	return;
 	}
 }
+
 if (ctxt == VAR_GLOBAL) {
 	v = VarFind(name, VAR_CMD, 0);
 	if (v != NULL) {
@@ -807,6 +782,7 @@ Var_Set_with_flags(const char *name, con
 	VarFreeEnv(v, TRUE);
 	}
 }
+
 v = VarFind(name, ctxt, 0);
 if (v == NULL) {
 	if (ctxt == VAR_CMD && !(flags & VAR_NO_EXPORT)) {
@@ -872,8 +848,8 @@ out:
  *	ctxt		context in which to set it
  *
  * Side Effects:
- *	If the variable doesn't yet exist, a new record is created for it.
- *	Else the old value is freed and the new one stuck in its place
+ *	If the variable doesn't yet exist, it is created.
+ *	Otherwise the new value overwrites and replaces the old value.
  *
  * Notes:
  *	The variable is searched for only in its context before being
@

CVS commit: src/usr.bin/script

2020-08-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug  2 16:23:33 UTC 2020

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

Log Message:
PR/55531: Soumendra Ganguly:
- add more error handling
- handle -p when not a terminal
- call termreset() before printing script done, so that it is printed correctly

Also:
- use ssize_t/size_t instead of int
- use EXIT_SUCCESS/EXIT_FAILURE
- check result of fork() against -1


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/script/script.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/script/script.c
diff -u src/usr.bin/script/script.c:1.22 src/usr.bin/script/script.c:1.23
--- src/usr.bin/script/script.c:1.22	Sat Aug  1 13:31:06 2020
+++ src/usr.bin/script/script.c	Sun Aug  2 12:23:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: script.c,v 1.22 2020/08/01 17:31:06 christos Exp $	*/
+/*	$NetBSD: script.c,v 1.23 2020/08/02 16:23:33 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)script.c	8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: script.c,v 1.22 2020/08/01 17:31:06 christos Exp $");
+__RCSID("$NetBSD: script.c,v 1.23 2020/08/02 16:23:33 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -76,7 +76,7 @@ struct stamp {
 static FILE	*fscript;
 static int	master, slave;
 static int	child, subchild;
-static int	outcc;
+static size_t	outcc;
 static int	usesleep, rawout;
 static int	quiet, flush;
 static const char *fname;
@@ -97,7 +97,8 @@ __dead static void	playback(FILE *);
 int
 main(int argc, char *argv[])
 {
-	int cc;
+	ssize_t scc;
+	size_t cc;
 	struct termios rtt;
 	struct winsize win;
 	int aflg, pflg, ch;
@@ -139,7 +140,7 @@ main(int argc, char *argv[])
 			(void)fprintf(stderr,
 			"Usage: %s [-c ][-adfpqr] [file]\n",
 			getprogname());
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 	argc -= optind;
 	argv += optind;
@@ -150,32 +151,43 @@ main(int argc, char *argv[])
 		fname = "typescript";
 
 	if ((fscript = fopen(fname, pflg ? "r" : aflg ? "a" : "w")) == NULL)
-		err(1, "fopen %s", fname);
+		err(EXIT_FAILURE, "fopen %s", fname);
 
 	if (pflg)
 		playback(fscript);
 
-	(void)tcgetattr(STDIN_FILENO, &tt);
-	(void)ioctl(STDIN_FILENO, TIOCGWINSZ, &win);
-	if (openpty(&master, &slave, NULL, &tt, &win) == -1)
-		err(1, "openpty");
+	isterm = isatty(STDIN_FILENO);
+	if (isterm) {
+		if (tcgetattr(STDIN_FILENO, &tt) == -1)
+			err(EXIT_FAILURE, "tcgetattr");
+		if (ioctl(STDIN_FILENO, TIOCGWINSZ, &win) == -1)
+			err(EXIT_FAILURE, "ioctl");
+		if (openpty(&master, &slave, NULL, &tt, &win) == -1)
+			err(EXIT_FAILURE, "openpty");
+	} else {
+		if (openpty(&master, &slave, NULL, NULL, NULL) == -1)
+			err(EXIT_FAILURE, "openpty");		
+	}
 
 	if (!quiet)
 		(void)printf("Script started, output file is %s\n", fname);
-	rtt = tt;
-	cfmakeraw(&rtt);
-	rtt.c_lflag &= ~ECHO;
-	(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &rtt);
+
+	if (isterm) {
+		rtt = tt;
+		cfmakeraw(&rtt);
+		rtt.c_lflag &= ~ECHO;
+		(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &rtt);
+	}
 
 	(void)signal(SIGCHLD, finish);
 	child = fork();
-	if (child < 0) {
+	if (child == -1) {
 		warn("fork");
 		fail();
 	}
 	if (child == 0) {
 		subchild = child = fork();
-		if (child < 0) {
+		if (child == -1) {
 			warn("fork");
 			fail();
 		}
@@ -187,14 +199,15 @@ main(int argc, char *argv[])
 
 	if (!rawout)
 		(void)fclose(fscript);
-	while ((cc = read(STDIN_FILENO, ibuf, BUFSIZ)) > 0) {
+	while ((scc = read(STDIN_FILENO, ibuf, BUFSIZ)) > 0) {
+		cc = (size_t)scc;	
 		if (rawout)
 			record(fscript, ibuf, cc, 'i');
 		(void)write(master, ibuf, cc);
 	}
 	done();
 	/* NOTREACHED */
-	return (0);
+	return EXIT_SUCCESS;
 }
 
 static void
@@ -215,7 +228,8 @@ static void
 dooutput(void)
 {
 	struct itimerval value;
-	int cc;
+	ssize_t scc;
+	size_t cc;
 	time_t tvec;
 	char obuf[BUFSIZ];
 
@@ -232,9 +246,10 @@ dooutput(void)
 	value.it_value = value.it_interval;
 	(void)setitimer(ITIMER_REAL, &value, NULL);
 	for (;;) {
-		cc = read(master, obuf, sizeof (obuf));
-		if (cc <= 0)
+		scc = read(master, obuf, sizeof(obuf));
+		if (scc <= 0)
 			break;
+		cc = (size_t)scc;
 		(void)write(1, obuf, cc);
 		if (rawout)
 			record(fscript, obuf, cc, 'o');
@@ -301,11 +316,12 @@ done(void)
 		(void)fclose(fscript);
 		(void)close(master);
 	} else {
-		(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &tt);
+		if (isterm)
+			(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &tt);
 		if (!quiet)
 			(void)printf("Script done, output file is %s\n", fname);
 	}
-	exit(0);
+	exit(EXIT_SUCCESS);
 }
 
 static void
@@ -325,7 +341,7 @@ record(FILE *fp, char *buf, size_t cc, i
 	iov[1].iov_len = cc;
 	iov[1].iov_base = buf;
 	if (writev(fileno(fp), &iov[0], 2) == -1)
-		err(1, "writev");
+		err(EXIT_FAILURE, "writev");
 }
 
 static void
@@ -335,13 +351,13 @@ consume(FILE *fp, off_t len, char *buf, 
 
 	i

CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 16:06:50 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): remove visual clutter from VarFind

Having fewer { else } around makes the return statements easier to find.


To generate a diff of this commit:
cvs rdiff -u -r1.398 -r1.399 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.398 src/usr.bin/make/var.c:1.399
--- src/usr.bin/make/var.c:1.398	Sun Aug  2 15:26:49 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 16:06:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.398 2020/08/02 15:26:49 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.399 2020/08/02 16:06:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.398 2020/08/02 15:26:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.399 2020/08/02 16:06:49 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.398 2020/08/02 15:26:49 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.399 2020/08/02 16:06:49 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -336,9 +336,9 @@ VarFind(const char *name, GNode *ctxt, V
  */
 Hash_Entry *var = Hash_FindEntry(&ctxt->context, name);
 
-if (var == NULL && (flags & FIND_CMD) && ctxt != VAR_CMD) {
+if (var == NULL && (flags & FIND_CMD) && ctxt != VAR_CMD)
 	var = Hash_FindEntry(&VAR_CMD->context, name);
-}
+
 if (!checkEnvFirst && var == NULL && (flags & FIND_GLOBAL) &&
 	ctxt != VAR_GLOBAL)
 {
@@ -348,6 +348,7 @@ VarFind(const char *name, GNode *ctxt, V
 	var = Hash_FindEntry(&VAR_INTERNAL->context, name);
 	}
 }
+
 if (var == NULL && (flags & FIND_ENV)) {
 	char *env;
 
@@ -361,26 +362,25 @@ VarFind(const char *name, GNode *ctxt, V
 
 	v->flags = VAR_FROM_ENV;
 	return v;
-	} else if (checkEnvFirst && (flags & FIND_GLOBAL) &&
-		   ctxt != VAR_GLOBAL)
-	{
+	}
+
+	if (checkEnvFirst && (flags & FIND_GLOBAL) && ctxt != VAR_GLOBAL) {
 	var = Hash_FindEntry(&VAR_GLOBAL->context, name);
-	if (var == NULL && ctxt != VAR_INTERNAL) {
+	if (var == NULL && ctxt != VAR_INTERNAL)
 		var = Hash_FindEntry(&VAR_INTERNAL->context, name);
-	}
-	if (var == NULL) {
+	if (var == NULL)
 		return NULL;
-	} else {
+	else
 		return (Var *)Hash_GetValue(var);
-	}
-	} else {
-	return NULL;
 	}
-} else if (var == NULL) {
+
 	return NULL;
-} else {
-	return (Var *)Hash_GetValue(var);
 }
+
+if (var == NULL)
+	return NULL;
+else
+	return (Var *)Hash_GetValue(var);
 }
 
 /*-



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 15:26:49 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): remove unnecessary assignment in Var_Parse

In a variable expression without braces or parentheses, it is not
possible to have modifiers.  Therefore the assigned endc could not have
been used anywhere.


To generate a diff of this commit:
cvs rdiff -u -r1.397 -r1.398 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.397 src/usr.bin/make/var.c:1.398
--- src/usr.bin/make/var.c:1.397	Sun Aug  2 12:43:40 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 15:26:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.397 2020/08/02 12:43:40 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.398 2020/08/02 15:26:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.397 2020/08/02 12:43:40 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.398 2020/08/02 15:26:49 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.397 2020/08/02 12:43:40 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.398 2020/08/02 15:26:49 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3427,7 +3427,6 @@ Var_Parse(const char * const str, GNode 
 	} else {
 	haveModifier = FALSE;
 	tstr = str + 1;
-	endc = str[1];
 	}
 } else {
 	endc = startc == PROPEN ? PRCLOSE : BRCLOSE;



CVS commit: src/usr.bin/make/unit-tests

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 15:22:53 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: counter.exp

Log Message:
make(1): remove debug output from uncommitted code from test

Note to self: don't accept the test results when there are uncommitted
parts in the code.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/counter.exp

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/make/unit-tests/counter.exp
diff -u src/usr.bin/make/unit-tests/counter.exp:1.1 src/usr.bin/make/unit-tests/counter.exp:1.2
--- src/usr.bin/make/unit-tests/counter.exp:1.1	Sun Aug  2 14:53:02 2020
+++ src/usr.bin/make/unit-tests/counter.exp	Sun Aug  2 15:22:53 2020
@@ -4,7 +4,6 @@ Global:NEXT = ${COUNTER::=${COUNTER} a}$
 Global:A = 
 Applying[COUNTER] :: to ""
 Modifier part: " a"
-ApplyModifier_Assign: "COUNTER" = " a"
 Global:COUNTER =  a
 Result[COUNTER] of :: is ""
 Applying[COUNTER] :[ to " a"
@@ -14,7 +13,6 @@ Global:A = ${COUNTER::= a a}1
 Global:B = 
 Applying[COUNTER] :: to " a"
 Modifier part: " a a"
-ApplyModifier_Assign: "COUNTER" = " a a"
 Global:COUNTER =  a a
 Result[COUNTER] of :: is ""
 Applying[COUNTER] :[ to " a a"
@@ -24,7 +22,6 @@ Global:B = ${COUNTER::= a a a}2
 Global:C = 
 Applying[COUNTER] :: to " a a"
 Modifier part: " a a a"
-ApplyModifier_Assign: "COUNTER" = " a a a"
 Global:COUNTER =  a a a
 Result[COUNTER] of :: is ""
 Applying[COUNTER] :[ to " a a a"
@@ -36,7 +33,6 @@ Global:RELEVANT = yes (run-time part)
 Result[RELEVANT] of :: is ""
 Applying[COUNTER] :: to " a a a"
 Modifier part: " a a"
-ApplyModifier_Assign: "COUNTER" = " a a"
 Global:COUNTER =  a a
 Result[COUNTER] of :: is ""
 Applying[A] :Q to "1"
@@ -44,7 +40,6 @@ QuoteMeta: [1]
 Result[A] of :Q is "1"
 Applying[COUNTER] :: to " a a"
 Modifier part: " a a a"
-ApplyModifier_Assign: "COUNTER" = " a a a"
 Global:COUNTER =  a a a
 Result[COUNTER] of :: is ""
 Applying[B] :Q to "2"
@@ -52,7 +47,6 @@ QuoteMeta: [2]
 Result[B] of :Q is "2"
 Applying[COUNTER] :: to " a a a"
 Modifier part: " a a a a"
-ApplyModifier_Assign: "COUNTER" = " a a a a"
 Global:COUNTER =  a a a a
 Result[COUNTER] of :: is ""
 Applying[C] :Q to "3"
@@ -67,6 +61,5 @@ Result[COUNTER] of :Q is "4"
 A=1 B=2 C=3 COUNTER=4
 Applying[RELEVANT] :: to "yes (run-time part)"
 Modifier part: "no"
-ApplyModifier_Assign: "RELEVANT" = "no"
 Global:RELEVANT = no
 exit status 0



CVS commit: src

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 14:53:02 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: counter.exp counter.mk

Log Message:
make(1): add test for nested VAR_SUBST assignments


To generate a diff of this commit:
cvs rdiff -u -r1.882 -r1.883 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/counter.exp \
src/usr.bin/make/unit-tests/counter.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.882 src/distrib/sets/lists/tests/mi:1.883
--- src/distrib/sets/lists/tests/mi:1.882	Fri Jul 31 16:42:51 2020
+++ src/distrib/sets/lists/tests/mi	Sun Aug  2 14:53:01 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.882 2020/07/31 16:42:51 rillig Exp $
+# $NetBSD: mi,v 1.883 2020/08/02 14:53:01 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4536,6 +4536,8 @@
 ./usr/tests/usr.bin/make/unit-tests/cond1.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond2.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond2.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/counter.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/counter.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dir.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dir.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/directives.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.80 src/usr.bin/make/unit-tests/Makefile:1.81
--- src/usr.bin/make/unit-tests/Makefile:1.80	Sat Aug  1 18:14:08 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun Aug  2 14:53:02 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.80 2020/08/01 18:14:08 rillig Exp $
+# $NetBSD: Makefile,v 1.81 2020/08/02 14:53:02 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -40,6 +40,7 @@ TESTS+=		cond-late
 TESTS+=		cond-short
 TESTS+=		cond1
 TESTS+=		cond2
+TESTS+=		counter
 TESTS+=		dir
 TESTS+=		directives
 TESTS+=		dollar
@@ -91,6 +92,7 @@ ENV.varmisc+=		FROM_ENV_BEFORE=env
 ENV.varmisc+=		FROM_ENV_AFTER=env
 
 # Override make flags for some of the tests; default is -k.
+FLAGS.counter=		-dv
 FLAGS.doterror=		# none
 FLAGS.envfirst=		-e
 FLAGS.export=		-r
@@ -105,6 +107,7 @@ SED_CMDS.varshell+=	-e 's,^[a-z]*sh: ,,'
 SED_CMDS.varshell+=	-e '/command/s,No such.*,not found,'
 
 # Some tests need an additional round of postprocessing.
+POSTPROC.counter=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 POSTPROC.vardebug=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 
 # End of the configuration section.

Added files:

Index: src/usr.bin/make/unit-tests/counter.exp
diff -u /dev/null src/usr.bin/make/unit-tests/counter.exp:1.1
--- /dev/null	Sun Aug  2 14:53:02 2020
+++ src/usr.bin/make/unit-tests/counter.exp	Sun Aug  2 14:53:02 2020
@@ -0,0 +1,72 @@
+Global:RELEVANT = yes (load-time part)
+Global:COUNTER = 
+Global:NEXT = ${COUNTER::=${COUNTER} a}${COUNTER:[#]}
+Global:A = 
+Applying[COUNTER] :: to ""
+Modifier part: " a"
+ApplyModifier_Assign: "COUNTER" = " a"
+Global:COUNTER =  a
+Result[COUNTER] of :: is ""
+Applying[COUNTER] :[ to " a"
+Modifier part: "#"
+Result[COUNTER] of :[ is "1"
+Global:A = ${COUNTER::= a a}1
+Global:B = 
+Applying[COUNTER] :: to " a"
+Modifier part: " a a"
+ApplyModifier_Assign: "COUNTER" = " a a"
+Global:COUNTER =  a a
+Result[COUNTER] of :: is ""
+Applying[COUNTER] :[ to " a a"
+Modifier part: "#"
+Result[COUNTER] of :[ is "2"
+Global:B = ${COUNTER::= a a a}2
+Global:C = 
+Applying[COUNTER] :: to " a a"
+Modifier part: " a a a"
+ApplyModifier_Assign: "COUNTER" = " a a a"
+Global:COUNTER =  a a a
+Result[COUNTER] of :: is ""
+Applying[COUNTER] :[ to " a a a"
+Modifier part: "#"
+Result[COUNTER] of :[ is "3"
+Global:C = ${COUNTER::= a a a a}3
+Global:RELEVANT = no
+Global:RELEVANT = yes (run-time part)
+Result[RELEVANT] of :: is ""
+Applying[COUNTER] :: to " a a a"
+Modifier part: " a a"
+ApplyModifier_Assign: "COUNTER" = " a a"
+Global:COUNTER =  a a
+Result[COUNTER] of :: is ""
+Applying[A] :Q to "1"
+QuoteMeta: [1]
+Result[A] of :Q is "1"
+Applying[COUNTER] :: to " a a"
+Modifier part: " a a a"
+ApplyModifier_Assign: "COUNTER" = " a a a"
+Global:COUNTER =  a a a
+Result[COUNTER] of :: is ""
+Applying[B] :Q to "2"
+QuoteMeta: [2]
+Result[B] of :Q is "2"
+Applying[COUNTER] :: to " a a a"
+Modifier part: " a a a a"
+ApplyModifier_Assign: "COUNTER" = " a a a a"
+Global:COUNTER =  a a a a
+Result[COUNTER] of :: is ""
+Applying[C] :

CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 12:43:40 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): eliminate another unnecessary UNCONST in Var_Delete


To generate a diff of this commit:
cvs rdiff -u -r1.396 -r1.397 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.396 src/usr.bin/make/var.c:1.397
--- src/usr.bin/make/var.c:1.396	Sun Aug  2 10:49:53 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 12:43:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.396 2020/08/02 10:49:53 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.397 2020/08/02 12:43:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.396 2020/08/02 10:49:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.397 2020/08/02 12:43:40 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.396 2020/08/02 10:49:53 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.397 2020/08/02 12:43:40 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -458,21 +458,16 @@ VarAdd(const char *name, const char *val
 void
 Var_Delete(const char *name, GNode *ctxt)
 {
-Hash_Entry 	  *ln;
-char *cp;
-
-if (strchr(name, '$') != NULL) {
-	cp = Var_Subst(name, VAR_GLOBAL, VARE_WANTRES);
-} else {
-	cp = UNCONST(name);
-}
-ln = Hash_FindEntry(&ctxt->context, cp);
+char *name_freeIt = NULL;
+if (strchr(name, '$') != NULL)
+	name = name_freeIt = Var_Subst(name, VAR_GLOBAL, VARE_WANTRES);
+Hash_Entry *ln = Hash_FindEntry(&ctxt->context, name);
 if (DEBUG(VAR)) {
 	fprintf(debug_file, "%s:delete %s%s\n",
-	ctxt->name, cp, ln ? "" : " (not found)");
+	ctxt->name, name, ln != NULL ? "" : " (not found)");
 }
-if (cp != name)
-	free(cp);
+free(name_freeIt);
+
 if (ln != NULL) {
 	Var *v = (Var *)Hash_GetValue(ln);
 	if (v->flags & VAR_EXPORTED)



CVS commit: [netbsd-9] src/doc

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 11:20:24 UTC 2020

Modified Files:
src/doc [netbsd-9]: CHANGES-9.1

Log Message:
Ammend ticket #1032


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.86 -r1.1.2.87 src/doc/CHANGES-9.1

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-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.86 src/doc/CHANGES-9.1:1.1.2.87
--- src/doc/CHANGES-9.1:1.1.2.86	Sun Aug  2 09:14:12 2020
+++ src/doc/CHANGES-9.1	Sun Aug  2 11:20:24 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.86 2020/08/02 09:14:12 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.87 2020/08/02 11:20:24 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -3565,7 +3565,7 @@ sys/arch/x86/x86/cpu.c			patch
 
 sys/dev/nvmm/files.nvmm1.3
 sys/dev/nvmm/nvmm.c1.30-1.32
-sys/dev/nvmm/nvmm_internal.h			1.15,1.16
+sys/dev/nvmm/nvmm_internal.h			1.15,1.16 (adjusted)
 sys/dev/nvmm/x86/nvmm_x86_svm.c			1.62,1.63 (patch)
 sys/dev/nvmm/x86/nvmm_x86_vmx.c			1.59-1.61 (patch)
 sys/modules/nvmm/nvmm.ioconf			1.2



CVS commit: [netbsd-9] src/sys/dev/nvmm

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 11:19:09 UTC 2020

Modified Files:
src/sys/dev/nvmm [netbsd-9]: nvmm_internal.h

Log Message:
Open code preempt_needed() which is not available on this branch.
Fixes build fallout from ticket #1032.


To generate a diff of this commit:
cvs rdiff -u -r1.12.2.3 -r1.12.2.4 src/sys/dev/nvmm/nvmm_internal.h

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

Modified files:

Index: src/sys/dev/nvmm/nvmm_internal.h
diff -u src/sys/dev/nvmm/nvmm_internal.h:1.12.2.3 src/sys/dev/nvmm/nvmm_internal.h:1.12.2.4
--- src/sys/dev/nvmm/nvmm_internal.h:1.12.2.3	Sun Aug  2 08:49:08 2020
+++ src/sys/dev/nvmm/nvmm_internal.h	Sun Aug  2 11:19:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_internal.h,v 1.12.2.3 2020/08/02 08:49:08 martin Exp $	*/
+/*	$NetBSD: nvmm_internal.h,v 1.12.2.4 2020/08/02 11:19:09 martin Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -125,7 +125,13 @@ extern const struct nvmm_impl nvmm_x86_v
 static inline bool
 nvmm_return_needed(void)
 {
-	if (preempt_needed()) {
+	lwp_t *l = curlwp;
+	int needed;
+
+	KPREEMPT_DISABLE(l);
+	needed = l->l_cpu->ci_want_resched;
+	KPREEMPT_ENABLE(l);
+	if (needed) {
 		return true;
 	}
 	if (curlwp->l_flag & LW_USERRET) {



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 10:49:53 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): document almost duplicate code

ParseModifierPart and Var_Parse are very similar, but there might be
subtle differences.  Until these differences are documented in the form
of unit tests, merging these code pieces is too dangerous.


To generate a diff of this commit:
cvs rdiff -u -r1.395 -r1.396 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.395 src/usr.bin/make/var.c:1.396
--- src/usr.bin/make/var.c:1.395	Sun Aug  2 10:47:09 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 10:49:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.395 2020/08/02 10:47:09 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.396 2020/08/02 10:49:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.395 2020/08/02 10:47:09 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.396 2020/08/02 10:49:53 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.395 2020/08/02 10:47:09 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.396 2020/08/02 10:49:53 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1746,7 +1746,6 @@ ParseModifierPart(
  * allow ampersands to be escaped and replace
  * unescaped ampersands with subst->lhs. */
 ) {
-char *rstr;
 Buffer buf;
 
 Buf_InitZ(&buf, 0);
@@ -1798,6 +1797,15 @@ ParseModifierPart(
 	continue;
 	}
 
+	/* XXX: This whole block is very similar to Var_Parse without
+	 * VARE_WANTRES.  There may be subtle edge cases though that are
+	 * not yet covered in the unit tests and that are parsed differently,
+	 * depending on whether they are evaluated or not.
+	 *
+	 * This subtle difference is not documented in the manual page,
+	 * neither is the difference between parsing :D and :M documented.
+	 * No code should ever depend on these details, but who knows. */
+
 	const char *varstart = p;	/* Nested variable, only parsed */
 	if (p[1] == PROPEN || p[1] == BROPEN) {
 	/*
@@ -1832,7 +1840,8 @@ ParseModifierPart(
 *pp = ++p;
 if (out_length != NULL)
 	*out_length = Buf_Size(&buf);
-rstr = Buf_Destroy(&buf, FALSE);
+
+char *rstr = Buf_Destroy(&buf, FALSE);
 if (DEBUG(VAR))
 	fprintf(debug_file, "Modifier part: \"%s\"\n", rstr);
 return rstr;



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 10:47:09 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): eliminate local variable in ParseModifierPart

The evaluation flags passed to the nested variables consist of 3 flags.
Therefore, (eflags & VARE_UNDEFERR) | (eflags & VARE_WANTRES) is
equivalent to (eflags & ~VARE_ASSIGN).

The variable name errnum was misleading anyway, just like the other
errnum from a few commits ago that had been renamed to errfmt.


To generate a diff of this commit:
cvs rdiff -u -r1.394 -r1.395 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.394 src/usr.bin/make/var.c:1.395
--- src/usr.bin/make/var.c:1.394	Sun Aug  2 10:01:50 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 10:47:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.394 2020/08/02 10:01:50 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.395 2020/08/02 10:47:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.394 2020/08/02 10:01:50 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.395 2020/08/02 10:47:09 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.394 2020/08/02 10:01:50 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.395 2020/08/02 10:47:09 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1748,7 +1748,6 @@ ParseModifierPart(
 ) {
 char *rstr;
 Buffer buf;
-VarEvalFlags errnum = eflags & VARE_UNDEFERR;
 
 Buf_InitZ(&buf, 0);
 
@@ -1792,8 +1791,7 @@ ParseModifierPart(
 	int len;
 	void   *freeIt;
 
-	cp2 = Var_Parse(p, ctxt, errnum | (eflags & VARE_WANTRES),
-			&len, &freeIt);
+	cp2 = Var_Parse(p, ctxt, eflags & ~VARE_ASSIGN, &len, &freeIt);
 	Buf_AddStr(&buf, cp2);
 	free(freeIt);
 	p += len;



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 10:01:50 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): don't needlessly chain p-- and p++ in ParseModifierPart

At least GCC 5 didn't optimize this, although I wouldn't have been
surprised if it did.


To generate a diff of this commit:
cvs rdiff -u -r1.393 -r1.394 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.393 src/usr.bin/make/var.c:1.394
--- src/usr.bin/make/var.c:1.393	Sun Aug  2 09:54:44 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 10:01:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.393 2020/08/02 09:54:44 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.394 2020/08/02 10:01:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.393 2020/08/02 09:54:44 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.394 2020/08/02 10:01:50 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.393 2020/08/02 09:54:44 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.394 2020/08/02 10:01:50 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1758,14 +1758,14 @@ ParseModifierPart(
  * backslashes to quote the delimiter, $, and \, but don't
  * touch other backslashes.
  */
-const char *p;
-for (p = *pp; *p != '\0' && *p != delim; p++) {
+const char *p = *pp;
+while (*p != '\0' && *p != delim) {
 	Boolean is_escaped = p[0] == '\\' && (
 	p[1] == delim || p[1] == '\\' || p[1] == '$' ||
 	(p[1] == '&' && subst != NULL));
 	if (is_escaped) {
 	Buf_AddByte(&buf, p[1]);
-	p++;
+	p += 2;
 	continue;
 	}
 
@@ -1774,6 +1774,7 @@ ParseModifierPart(
 		Buf_AddBytesZ(&buf, subst->lhs, subst->lhsLen);
 	else
 		Buf_AddByte(&buf, *p);
+	p++;
 	continue;
 	}
 
@@ -1782,6 +1783,7 @@ ParseModifierPart(
 		*out_pflags |= VARP_ANCHOR_END;
 	else
 		Buf_AddByte(&buf, *p);
+	p++;
 	continue;
 	}
 
@@ -1794,7 +1796,7 @@ ParseModifierPart(
 			&len, &freeIt);
 	Buf_AddStr(&buf, cp2);
 	free(freeIt);
-	p += len - 1;
+	p += len;
 	continue;
 	}
 
@@ -1818,9 +1820,10 @@ ParseModifierPart(
 		}
 	}
 	Buf_AddBytesBetween(&buf, varstart, p);
-	p--;
-	} else
+	} else {
 	Buf_AddByte(&buf, *varstart);
+	p++;
+	}
 }
 
 if (*p != delim) {



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 09:54:44 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): reduce the number of moving variables in ParseModifierPart

Having only the p walk through the string is easier to understand than
assigning between p and cp2 (with its unexpressive name).


To generate a diff of this commit:
cvs rdiff -u -r1.392 -r1.393 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.392 src/usr.bin/make/var.c:1.393
--- src/usr.bin/make/var.c:1.392	Sun Aug  2 09:43:22 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 09:54:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.392 2020/08/02 09:43:22 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.393 2020/08/02 09:54:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.392 2020/08/02 09:43:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.393 2020/08/02 09:54:44 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.392 2020/08/02 09:43:22 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.393 2020/08/02 09:54:44 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1798,29 +1798,29 @@ ParseModifierPart(
 	continue;
 	}
 
-	const char *cp2 = &p[1];	/* Nested variable, only parsed */
-	if (*cp2 == PROPEN || *cp2 == BROPEN) {
+	const char *varstart = p;	/* Nested variable, only parsed */
+	if (p[1] == PROPEN || p[1] == BROPEN) {
 	/*
 	 * Find the end of this variable reference
 	 * and suck it in without further ado.
 	 * It will be interpreted later.
 	 */
-	int have = *cp2;
-	int want = *cp2 == PROPEN ? PRCLOSE : BRCLOSE;
+	int have = p[1];
+	int want = have == PROPEN ? PRCLOSE : BRCLOSE;
 	int depth = 1;
 
-	for (++cp2; *cp2 != '\0' && depth > 0; ++cp2) {
-		if (cp2[-1] != '\\') {
-		if (*cp2 == have)
+	for (p += 2; *p != '\0' && depth > 0; ++p) {
+		if (p[-1] != '\\') {
+		if (*p == have)
 			++depth;
-		if (*cp2 == want)
+		if (*p == want)
 			--depth;
 		}
 	}
-	Buf_AddBytesBetween(&buf, p, cp2);
-	p = --cp2;
+	Buf_AddBytesBetween(&buf, varstart, p);
+	p--;
 	} else
-	Buf_AddByte(&buf, *p);
+	Buf_AddByte(&buf, *varstart);
 }
 
 if (*p != delim) {



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 09:43:22 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): use shorter local variable names

The c in cp was redundant since the context makes it obvious that this
is a character pointer. In a tight loop where lots of characters are
compared, every letter counts.


To generate a diff of this commit:
cvs rdiff -u -r1.391 -r1.392 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.391 src/usr.bin/make/var.c:1.392
--- src/usr.bin/make/var.c:1.391	Sun Aug  2 09:36:54 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 09:43:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.391 2020/08/02 09:36:54 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.392 2020/08/02 09:43:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.391 2020/08/02 09:36:54 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.392 2020/08/02 09:43:22 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.391 2020/08/02 09:36:54 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.392 2020/08/02 09:43:22 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1731,7 +1731,7 @@ VarUniq(const char *str)
  */
 static char *
 ParseModifierPart(
-const char **tstr,		/* The parsing position, updated upon return */
+const char **pp,		/* The parsing position, updated upon return */
 int delim,			/* Parsing stops at this delimiter */
 VarEvalFlags eflags,	/* Flags for evaluating nested variables;
  * if VARE_WANTRES is not set, the text is
@@ -1746,7 +1746,6 @@ ParseModifierPart(
  * allow ampersands to be escaped and replace
  * unescaped ampersands with subst->lhs. */
 ) {
-const char *cp;
 char *rstr;
 Buffer buf;
 VarEvalFlags errnum = eflags & VARE_UNDEFERR;
@@ -1759,29 +1758,30 @@ ParseModifierPart(
  * backslashes to quote the delimiter, $, and \, but don't
  * touch other backslashes.
  */
-for (cp = *tstr; *cp != '\0' && *cp != delim; cp++) {
-	Boolean is_escaped = cp[0] == '\\' && (
-	cp[1] == delim || cp[1] == '\\' || cp[1] == '$' ||
-	(cp[1] == '&' && subst != NULL));
+const char *p;
+for (p = *pp; *p != '\0' && *p != delim; p++) {
+	Boolean is_escaped = p[0] == '\\' && (
+	p[1] == delim || p[1] == '\\' || p[1] == '$' ||
+	(p[1] == '&' && subst != NULL));
 	if (is_escaped) {
-	Buf_AddByte(&buf, cp[1]);
-	cp++;
+	Buf_AddByte(&buf, p[1]);
+	p++;
 	continue;
 	}
 
-	if (*cp != '$') {	/* Unescaped, simple text */
-	if (subst != NULL && *cp == '&')
+	if (*p != '$') {	/* Unescaped, simple text */
+	if (subst != NULL && *p == '&')
 		Buf_AddBytesZ(&buf, subst->lhs, subst->lhsLen);
 	else
-		Buf_AddByte(&buf, *cp);
+		Buf_AddByte(&buf, *p);
 	continue;
 	}
 
-	if (cp[1] == delim) {	/* Unescaped $ at end of pattern */
+	if (p[1] == delim) {	/* Unescaped $ at end of pattern */
 	if (out_pflags != NULL)
 		*out_pflags |= VARP_ANCHOR_END;
 	else
-		Buf_AddByte(&buf, *cp);
+		Buf_AddByte(&buf, *p);
 	continue;
 	}
 
@@ -1790,15 +1790,15 @@ ParseModifierPart(
 	int len;
 	void   *freeIt;
 
-	cp2 = Var_Parse(cp, ctxt, errnum | (eflags & VARE_WANTRES),
+	cp2 = Var_Parse(p, ctxt, errnum | (eflags & VARE_WANTRES),
 			&len, &freeIt);
 	Buf_AddStr(&buf, cp2);
 	free(freeIt);
-	cp += len - 1;
+	p += len - 1;
 	continue;
 	}
 
-	const char *cp2 = &cp[1];	/* Nested variable, only parsed */
+	const char *cp2 = &p[1];	/* Nested variable, only parsed */
 	if (*cp2 == PROPEN || *cp2 == BROPEN) {
 	/*
 	 * Find the end of this variable reference
@@ -1817,18 +1817,18 @@ ParseModifierPart(
 			--depth;
 		}
 	}
-	Buf_AddBytesBetween(&buf, cp, cp2);
-	cp = --cp2;
+	Buf_AddBytesBetween(&buf, p, cp2);
+	p = --cp2;
 	} else
-	Buf_AddByte(&buf, *cp);
+	Buf_AddByte(&buf, *p);
 }
 
-if (*cp != delim) {
-	*tstr = cp;
+if (*p != delim) {
+	*pp = p;
 	return NULL;
 }
 
-*tstr = ++cp;
+*pp = ++p;
 if (out_length != NULL)
 	*out_length = Buf_Size(&buf);
 rstr = Buf_Destroy(&buf, FALSE);



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 09:36:54 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): reduce indentation in ParseModifierPart


To generate a diff of this commit:
cvs rdiff -u -r1.390 -r1.391 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.390 src/usr.bin/make/var.c:1.391
--- src/usr.bin/make/var.c:1.390	Sun Aug  2 09:06:32 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 09:36:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.390 2020/08/02 09:06:32 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.391 2020/08/02 09:36:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.390 2020/08/02 09:06:32 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.391 2020/08/02 09:36:54 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.390 2020/08/02 09:06:32 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.391 2020/08/02 09:36:54 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1766,58 +1766,60 @@ ParseModifierPart(
 	if (is_escaped) {
 	Buf_AddByte(&buf, cp[1]);
 	cp++;
-	} else if (*cp == '$') {
-	if (cp[1] == delim) {	/* Unescaped $ at end of pattern */
-		if (out_pflags != NULL)
-		*out_pflags |= VARP_ANCHOR_END;
-		else
-		Buf_AddByte(&buf, *cp);
-	} else {
-		if (eflags & VARE_WANTRES) {
-		const char *cp2;
-		int len;
-		void   *freeIt;
+	continue;
+	}
 
-		/*
-		 * If unescaped dollar sign not before the
-		 * delimiter, assume it's a variable
-		 * substitution and recurse.
-		 */
-		cp2 = Var_Parse(cp, ctxt, errnum | (eflags & VARE_WANTRES),
-&len, &freeIt);
-		Buf_AddStr(&buf, cp2);
-		free(freeIt);
-		cp += len - 1;
-		} else {
-		const char *cp2 = &cp[1];
+	if (*cp != '$') {	/* Unescaped, simple text */
+	if (subst != NULL && *cp == '&')
+		Buf_AddBytesZ(&buf, subst->lhs, subst->lhsLen);
+	else
+		Buf_AddByte(&buf, *cp);
+	continue;
+	}
 
-		if (*cp2 == PROPEN || *cp2 == BROPEN) {
-			/*
-			 * Find the end of this variable reference
-			 * and suck it in without further ado.
-			 * It will be interpreted later.
-			 */
-			int have = *cp2;
-			int want = *cp2 == PROPEN ? PRCLOSE : BRCLOSE;
-			int depth = 1;
-
-			for (++cp2; *cp2 != '\0' && depth > 0; ++cp2) {
-			if (cp2[-1] != '\\') {
-if (*cp2 == have)
-++depth;
-if (*cp2 == want)
---depth;
-			}
-			}
-			Buf_AddBytesBetween(&buf, cp, cp2);
-			cp = --cp2;
-		} else
-			Buf_AddByte(&buf, *cp);
+	if (cp[1] == delim) {	/* Unescaped $ at end of pattern */
+	if (out_pflags != NULL)
+		*out_pflags |= VARP_ANCHOR_END;
+	else
+		Buf_AddByte(&buf, *cp);
+	continue;
+	}
+
+	if (eflags & VARE_WANTRES) {	/* Nested variable, evaluated */
+	const char *cp2;
+	int len;
+	void   *freeIt;
+
+	cp2 = Var_Parse(cp, ctxt, errnum | (eflags & VARE_WANTRES),
+			&len, &freeIt);
+	Buf_AddStr(&buf, cp2);
+	free(freeIt);
+	cp += len - 1;
+	continue;
+	}
+
+	const char *cp2 = &cp[1];	/* Nested variable, only parsed */
+	if (*cp2 == PROPEN || *cp2 == BROPEN) {
+	/*
+	 * Find the end of this variable reference
+	 * and suck it in without further ado.
+	 * It will be interpreted later.
+	 */
+	int have = *cp2;
+	int want = *cp2 == PROPEN ? PRCLOSE : BRCLOSE;
+	int depth = 1;
+
+	for (++cp2; *cp2 != '\0' && depth > 0; ++cp2) {
+		if (cp2[-1] != '\\') {
+		if (*cp2 == have)
+			++depth;
+		if (*cp2 == want)
+			--depth;
 		}
 	}
-	} else if (subst != NULL && *cp == '&')
-	Buf_AddBytesZ(&buf, subst->lhs, subst->lhsLen);
-	else
+	Buf_AddBytesBetween(&buf, cp, cp2);
+	cp = --cp2;
+	} else
 	Buf_AddByte(&buf, *cp);
 }
 



CVS commit: [netbsd-8] src/doc

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 09:15:58 UTC 2020

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Tickets #1582 and #1583


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.23 -r1.1.2.24 src/doc/CHANGES-8.3

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-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.23 src/doc/CHANGES-8.3:1.1.2.24
--- src/doc/CHANGES-8.3:1.1.2.23	Mon Jul 20 19:02:43 2020
+++ src/doc/CHANGES-8.3	Sun Aug  2 09:15:57 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.3,v 1.1.2.23 2020/07/20 19:02:43 martin Exp $
+# $NetBSD: CHANGES-8.3,v 1.1.2.24 2020/08/02 09:15:57 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -357,3 +357,16 @@ sys/arch/x86/x86/procfs_machdep.c		1.37,
 	Add AMD protected processor identification number (ppin).
 	[msaitoh, ticket #1581]
 
+xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c	1.2
+xsrc/external/mit/xorg-server/dist/dix/pixmap.c	1.2
+
+	Fix for ZDI-11426:
+	Avoid leaking un-initalized memory to clients by zeroing the
+	whole pixmap on initial allocation.
+	[maya, ticket #1582]
+
+usr.bin/w/w.c	1.88-1.90
+
+	Handle hostname from DISPLAY="[2001:db8::dead:beef]:0" or similar.
+	[kim, ticket #1583]
+



CVS commit: [netbsd-8] src/usr.bin/w

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 09:15:03 UTC 2020

Modified Files:
src/usr.bin/w [netbsd-8]: w.c

Log Message:
Pull up following revision(s) (requested by kim in ticket #1583):

usr.bin/w/w.c: revision 1.88
usr.bin/w/w.c: revision 1.89
usr.bin/w/w.c: revision 1.90

Handle hostname from DISPLAY="[2001:db8::dead:beef]:0" or similar.

Restore ']' if not using a result from an address lookup.

Skip bracket processing if -n is used.
XXX: This could be improved to skip even more processing.


To generate a diff of this commit:
cvs rdiff -u -r1.83.6.2 -r1.83.6.3 src/usr.bin/w/w.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/w/w.c
diff -u src/usr.bin/w/w.c:1.83.6.2 src/usr.bin/w/w.c:1.83.6.3
--- src/usr.bin/w/w.c:1.83.6.2	Tue Jul  7 10:44:11 2020
+++ src/usr.bin/w/w.c	Sun Aug  2 09:15:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: w.c,v 1.83.6.2 2020/07/07 10:44:11 martin Exp $	*/
+/*	$NetBSD: w.c,v 1.83.6.3 2020/08/02 09:15:03 martin Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)w.c	8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.83.6.2 2020/07/07 10:44:11 martin Exp $");
+__RCSID("$NetBSD: w.c,v 1.83.6.3 2020/08/02 09:15:03 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -621,7 +621,7 @@ static void
 fixhost(struct entry *ep)
 {
 	char host_buf[sizeof(ep->host)];
-	char *p, *r, *x, *m;
+	char *b, *m, *p, *r, *x;
 	struct hostent *hp;
 	union {
 		struct in_addr l4;
@@ -650,13 +650,35 @@ fixhost(struct entry *ep)
 			x = NULL;
 	}
 
+	/*
+	 * Leading '[' indicates an IP address inside brackets.
+	 */
+	b = NULL;
+	if (!nflag && (*p == '[')) {
+		for (b = p++; b < &host_buf[sizeof(host_buf)]; b++)
+			if (*b == '\0' || *b == ']')
+break;
+		if (b < &host_buf[sizeof(host_buf)] && *b == ']') {
+			*b = '\0';
+			for (x = b + 1; x < &host_buf[sizeof(host_buf)]; x++)
+if (*x == '\0' || *x == ':')
+	break;
+			if (x < &host_buf[sizeof(host_buf)] && *x == ':')
+*x++ = '\0';
+		} else
+			b = NULL;
+	}
+
 	int af = m ? AF_INET6 : AF_INET;
 	size_t alen = m ? sizeof(l.l6) : sizeof(l.l4);
 	if (!nflag && inet_pton(af, p, &l) &&
 	(hp = gethostbyaddr((char *)&l, alen, af)))
 		r = hp->h_name;
-	else
+	else {
+		if (b)
+			*b = ']';
 		r = host_buf;
+	}
 
 	if (domain[0] != '\0') {
 		p = r;



CVS commit: [netbsd-9] src/doc

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 09:14:12 UTC 2020

Modified Files:
src/doc [netbsd-9]: CHANGES-9.1

Log Message:
Tickets #1032 - #1034


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.85 -r1.1.2.86 src/doc/CHANGES-9.1

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-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.85 src/doc/CHANGES-9.1:1.1.2.86
--- src/doc/CHANGES-9.1:1.1.2.85	Sun Aug  2 07:49:46 2020
+++ src/doc/CHANGES-9.1	Sun Aug  2 09:14:12 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.85 2020/08/02 07:49:46 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.86 2020/08/02 09:14:12 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -3563,3 +3563,30 @@ sys/arch/x86/x86/cpu.c			patch
 	added in ticket #1015.
 	[msaitoh, ticket #1031]
 
+sys/dev/nvmm/files.nvmm1.3
+sys/dev/nvmm/nvmm.c1.30-1.32
+sys/dev/nvmm/nvmm_internal.h			1.15,1.16
+sys/dev/nvmm/x86/nvmm_x86_svm.c			1.62,1.63 (patch)
+sys/dev/nvmm/x86/nvmm_x86_vmx.c			1.59-1.61 (patch)
+sys/modules/nvmm/nvmm.ioconf			1.2
+
+	Sync nvmm with HEAD:
+	 - some optimizations (especially on startup)
+	 - style improvements
+	 - PR 55406: prevent ACPI suspend if NVMM when running
+	 - print the backend name when attaching.
+	[maxv, ticket #1032]
+
+xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c	1.2
+xsrc/external/mit/xorg-server/dist/dix/pixmap.c	1.2
+
+	Fix for ZDI-11426:
+	Avoid leaking un-initalized memory to clients by zeroing the
+	whole pixmap on initial allocation.
+	[maya, ticket #1033]
+
+usr.bin/w/w.c	1.88-1.90
+
+	Handle hostname from DISPLAY="[2001:db8::dead:beef]:0" or similar.
+	[kim, ticket #1034]
+



CVS commit: [netbsd-9] src/usr.bin/w

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 09:12:55 UTC 2020

Modified Files:
src/usr.bin/w [netbsd-9]: w.c

Log Message:
Pull up following revision(s) (requested by kim in ticket #1034):

usr.bin/w/w.c: revision 1.88
usr.bin/w/w.c: revision 1.89
usr.bin/w/w.c: revision 1.90

Handle hostname from DISPLAY="[2001:db8::dead:beef]:0" or similar.

Restore ']' if not using a result from an address lookup.

Skip bracket processing if -n is used.
XXX: This could be improved to skip even more processing.


To generate a diff of this commit:
cvs rdiff -u -r1.84.2.2 -r1.84.2.3 src/usr.bin/w/w.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/w/w.c
diff -u src/usr.bin/w/w.c:1.84.2.2 src/usr.bin/w/w.c:1.84.2.3
--- src/usr.bin/w/w.c:1.84.2.2	Tue Jul  7 10:43:00 2020
+++ src/usr.bin/w/w.c	Sun Aug  2 09:12:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: w.c,v 1.84.2.2 2020/07/07 10:43:00 martin Exp $	*/
+/*	$NetBSD: w.c,v 1.84.2.3 2020/08/02 09:12:54 martin Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)w.c	8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.84.2.2 2020/07/07 10:43:00 martin Exp $");
+__RCSID("$NetBSD: w.c,v 1.84.2.3 2020/08/02 09:12:54 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -621,7 +621,7 @@ static void
 fixhost(struct entry *ep)
 {
 	char host_buf[sizeof(ep->host)];
-	char *p, *r, *x, *m;
+	char *b, *m, *p, *r, *x;
 	struct hostent *hp;
 	union {
 		struct in_addr l4;
@@ -650,13 +650,35 @@ fixhost(struct entry *ep)
 			x = NULL;
 	}
 
+	/*
+	 * Leading '[' indicates an IP address inside brackets.
+	 */
+	b = NULL;
+	if (!nflag && (*p == '[')) {
+		for (b = p++; b < &host_buf[sizeof(host_buf)]; b++)
+			if (*b == '\0' || *b == ']')
+break;
+		if (b < &host_buf[sizeof(host_buf)] && *b == ']') {
+			*b = '\0';
+			for (x = b + 1; x < &host_buf[sizeof(host_buf)]; x++)
+if (*x == '\0' || *x == ':')
+	break;
+			if (x < &host_buf[sizeof(host_buf)] && *x == ':')
+*x++ = '\0';
+		} else
+			b = NULL;
+	}
+
 	int af = m ? AF_INET6 : AF_INET;
 	size_t alen = m ? sizeof(l.l6) : sizeof(l.l4);
 	if (!nflag && inet_pton(af, p, &l) &&
 	(hp = gethostbyaddr((char *)&l, alen, af)))
 		r = hp->h_name;
-	else
+	else {
+		if (b)
+			*b = ']';
 		r = host_buf;
+	}
 
 	if (domain[0] != '\0') {
 		p = r;



CVS commit: [netbsd-8] xsrc/external/mit

2020-08-02 Thread Martin Husemann
Module Name:xsrc
Committed By:   martin
Date:   Sun Aug  2 09:09:39 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server.old/dist/dix [netbsd-8]: pixmap.c
xsrc/external/mit/xorg-server/dist/dix [netbsd-8]: pixmap.c

Log Message:
Pull up following revision(s) (requested by maya in ticket #1582):

xsrc/external/mit/xorg-server/dist/dix/pixmap.c: revision 1.2
xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c: revision 1.2

Backport the only patch from xorg-server 1.20.9 as I can't find a tarball.

>From aac28e162e5108510065ad4c323affd6deffd816 Mon Sep 17 00:00:00 2001
From: Matthieu Herrb 
Date: Sat, 25 Jul 2020 19:33:50 +0200
Subject: [PATCH] fix for ZDI-11426

Avoid leaking un-initalized memory to clients by zeroing the
whole pixmap on initial allocation.

This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Matthieu Herrb 
Reviewed-by: Alan Coopersmith 


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.2.1 \
xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c
cvs rdiff -u -r1.1.1.4 -r1.1.1.4.2.1 \
xsrc/external/mit/xorg-server/dist/dix/pixmap.c

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

Modified files:

Index: xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c
diff -u xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c:1.1.1.1 xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c:1.1.1.1.2.1
--- xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c:1.1.1.1	Thu Jun  9 09:07:56 2016
+++ xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c	Sun Aug  2 09:09:39 2020
@@ -120,7 +120,7 @@ AllocatePixmap(ScreenPtr pScreen, int pi
 if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
 	return NullPixmap;
 
-pPixmap = malloc(pScreen->totalPixmapSize + pixDataSize);
+pPixmap = calloc(1, pScreen->totalPixmapSize + pixDataSize);
 if (!pPixmap)
 	return NullPixmap;
 

Index: xsrc/external/mit/xorg-server/dist/dix/pixmap.c
diff -u xsrc/external/mit/xorg-server/dist/dix/pixmap.c:1.1.1.4 xsrc/external/mit/xorg-server/dist/dix/pixmap.c:1.1.1.4.2.1
--- xsrc/external/mit/xorg-server/dist/dix/pixmap.c:1.1.1.4	Wed Aug 10 07:44:31 2016
+++ xsrc/external/mit/xorg-server/dist/dix/pixmap.c	Sun Aug  2 09:09:39 2020
@@ -116,7 +116,7 @@ AllocatePixmap(ScreenPtr pScreen, int pi
 if (pScreen->totalPixmapSize > ((size_t) - 1) - pixDataSize)
 return NullPixmap;
 
-pPixmap = malloc(pScreen->totalPixmapSize + pixDataSize);
+pPixmap = calloc(1, pScreen->totalPixmapSize + pixDataSize);
 if (!pPixmap)
 return NullPixmap;
 



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 09:06:32 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): restructure documentation of ParseModifierPart

Before, the long documentation looked too frightening, and it was not
immediately clear which parts of it had to be read and which could be
skipped.


To generate a diff of this commit:
cvs rdiff -u -r1.389 -r1.390 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.389 src/usr.bin/make/var.c:1.390
--- src/usr.bin/make/var.c:1.389	Sun Aug  2 08:49:43 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 09:06:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.389 2020/08/02 08:49:43 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.390 2020/08/02 09:06:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.389 2020/08/02 08:49:43 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.390 2020/08/02 09:06:32 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.389 2020/08/02 08:49:43 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.390 2020/08/02 09:06:32 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1728,25 +1728,24 @@ VarUniq(const char *str)
  *
  * Return the parsed (and possibly expanded) string, or NULL if no delimiter
  * was found.
- *
- * Nested variables in the text are expanded only if VARE_WANTRES is set.
- *
- * If out_length is specified, store the length of the returned string, just
- * to save another strlen call.
- *
- * If out_pflags is specified and the last character of the pattern is a $,
- * set the VARP_ANCHOR_END bit of out_pflags (used for the first part of the
- * :S modifier).
- *
- * If subst is specified, handle escaped ampersands and replace unescaped
- * ampersands with the lhs of the pattern (used for the second part of the :S
- * modifier).
  */
 static char *
-ParseModifierPart(const char **tstr, int delim, VarEvalFlags eflags,
-		  GNode *ctxt, size_t *out_length,
-		  VarPatternFlags *out_pflags, ModifyWord_SubstArgs *subst)
-{
+ParseModifierPart(
+const char **tstr,		/* The parsing position, updated upon return */
+int delim,			/* Parsing stops at this delimiter */
+VarEvalFlags eflags,	/* Flags for evaluating nested variables;
+ * if VARE_WANTRES is not set, the text is
+ * only parsed */
+GNode *ctxt,		/* For looking up nested variables */
+size_t *out_length,		/* Optionally stores the length of the returned
+ * string, just to save another strlen call. */
+VarPatternFlags *out_pflags,/* For the first part of the :S modifier,
+ * sets the VARP_ANCHOR_END flag if the last
+ * character of the pattern is a $. */
+ModifyWord_SubstArgs *subst	/* For the second part of the :S modifier,
+ * allow ampersands to be escaped and replace
+ * unescaped ampersands with subst->lhs. */
+) {
 const char *cp;
 char *rstr;
 Buffer buf;



CVS commit: [netbsd-9] xsrc/external/mit

2020-08-02 Thread Martin Husemann
Module Name:xsrc
Committed By:   martin
Date:   Sun Aug  2 09:01:44 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server.old/dist/dix [netbsd-9]: pixmap.c
xsrc/external/mit/xorg-server/dist/dix [netbsd-9]: pixmap.c

Log Message:
Pull up following revision(s) (requested by maya in ticket #1033):

xsrc/external/mit/xorg-server/dist/dix/pixmap.c: revision 1.2
xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c: revision 1.2

Backport the only patch from xorg-server 1.20.9 as I can't find a tarball.

>From aac28e162e5108510065ad4c323affd6deffd816 Mon Sep 17 00:00:00 2001
From: Matthieu Herrb 
Date: Sat, 25 Jul 2020 19:33:50 +0200
Subject: [PATCH] fix for ZDI-11426

Avoid leaking un-initalized memory to clients by zeroing the
whole pixmap on initial allocation.

This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Matthieu Herrb 
Reviewed-by: Alan Coopersmith 


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.4.1 \
xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c
cvs rdiff -u -r1.1.1.5 -r1.1.1.5.2.1 \
xsrc/external/mit/xorg-server/dist/dix/pixmap.c

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

Modified files:

Index: xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c
diff -u xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c:1.1.1.1 xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c:1.1.1.1.4.1
--- xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c:1.1.1.1	Thu Jun  9 09:07:56 2016
+++ xsrc/external/mit/xorg-server.old/dist/dix/pixmap.c	Sun Aug  2 09:01:44 2020
@@ -120,7 +120,7 @@ AllocatePixmap(ScreenPtr pScreen, int pi
 if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
 	return NullPixmap;
 
-pPixmap = malloc(pScreen->totalPixmapSize + pixDataSize);
+pPixmap = calloc(1, pScreen->totalPixmapSize + pixDataSize);
 if (!pPixmap)
 	return NullPixmap;
 

Index: xsrc/external/mit/xorg-server/dist/dix/pixmap.c
diff -u xsrc/external/mit/xorg-server/dist/dix/pixmap.c:1.1.1.5 xsrc/external/mit/xorg-server/dist/dix/pixmap.c:1.1.1.5.2.1
--- xsrc/external/mit/xorg-server/dist/dix/pixmap.c:1.1.1.5	Mon Dec 31 09:36:08 2018
+++ xsrc/external/mit/xorg-server/dist/dix/pixmap.c	Sun Aug  2 09:01:43 2020
@@ -116,7 +116,7 @@ AllocatePixmap(ScreenPtr pScreen, int pi
 if (pScreen->totalPixmapSize > ((size_t) - 1) - pixDataSize)
 return NullPixmap;
 
-pPixmap = malloc(pScreen->totalPixmapSize + pixDataSize);
+pPixmap = calloc(1, pScreen->totalPixmapSize + pixDataSize);
 if (!pPixmap)
 return NullPixmap;
 



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 08:49:43 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): update implementation documentation


To generate a diff of this commit:
cvs rdiff -u -r1.388 -r1.389 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.388 src/usr.bin/make/var.c:1.389
--- src/usr.bin/make/var.c:1.388	Sat Aug  1 21:40:49 2020
+++ src/usr.bin/make/var.c	Sun Aug  2 08:49:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.388 2020/08/01 21:40:49 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.389 2020/08/02 08:49:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.388 2020/08/01 21:40:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.389 2020/08/02 08:49:43 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.388 2020/08/01 21:40:49 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.389 2020/08/02 08:49:43 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1630,7 +1630,7 @@ VarWordCompareReverse(const void *a, con
  *
  * Input:
  *	str		String whose words should be sorted.
- *	otype		How to order: s - sort, x - random.
+ *	otype		How to order: s - sort, r - reverse, x - random.
  *
  * Results:
  *	A string containing the words ordered.
@@ -1729,17 +1729,17 @@ VarUniq(const char *str)
  * Return the parsed (and possibly expanded) string, or NULL if no delimiter
  * was found.
  *
- * Nested variables in the text are expanded unless VARE_NOSUBST is set.
+ * Nested variables in the text are expanded only if VARE_WANTRES is set.
  *
  * If out_length is specified, store the length of the returned string, just
  * to save another strlen call.
  *
  * If out_pflags is specified and the last character of the pattern is a $,
- * set the VARP_ANCHOR_END bit of mpflags (for the first part of the :S
- * modifier).
+ * set the VARP_ANCHOR_END bit of out_pflags (used for the first part of the
+ * :S modifier).
  *
  * If subst is specified, handle escaped ampersands and replace unescaped
- * ampersands with the lhs of the pattern (for the second part of the :S
+ * ampersands with the lhs of the pattern (used for the second part of the :S
  * modifier).
  */
 static char *



CVS commit: [netbsd-9] src/sys

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 08:49:08 UTC 2020

Modified Files:
src/sys/dev/nvmm [netbsd-9]: files.nvmm nvmm.c nvmm_internal.h
src/sys/dev/nvmm/x86 [netbsd-9]: nvmm_x86_svm.c nvmm_x86_vmx.c
src/sys/modules/nvmm [netbsd-9]: nvmm.ioconf

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1032):

sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.60 (patch)
sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.61 (patch)
sys/dev/nvmm/nvmm.c: revision 1.30
sys/dev/nvmm/nvmm.c: revision 1.31
sys/dev/nvmm/nvmm.c: revision 1.32
sys/dev/nvmm/nvmm_internal.h: revision 1.15
sys/dev/nvmm/nvmm_internal.h: revision 1.16
sys/dev/nvmm/files.nvmm: revision 1.3
sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.62 (patch)
sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.63 (patch)
sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.59 (patch)
sys/modules/nvmm/nvmm.ioconf: revision 1.2

Gather the conditions to return from the VCPU loops in nvmm_return_needed(),
and use it in nvmm_do_vcpu_run() as well. This fixes two undesired behaviors:

 - When a VM initializes, the many nested page faults that need processing
   could cause the calling thread to occupy the CPU too much if we're unlucky
   and are only getting repeated nested page faults thousands of times in a
   row.

 - When the emulator calls nvmm_vcpu_run() and immediately sends a signal to
   stop the VCPU, it's better to check signals earlier and leave right away,
   rather than doing a round of VCPU run that could increase the time spent
   by the emulator waiting for the return.

style

Register NVMM as an actual pseudo-device. Without PMF handler, to
explicitly disallow ACPI suspend if NVMM is running.

Should fix PR/55406.

Print the backend name when attaching.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.6.1 src/sys/dev/nvmm/files.nvmm
cvs rdiff -u -r1.22.2.4 -r1.22.2.5 src/sys/dev/nvmm/nvmm.c
cvs rdiff -u -r1.12.2.2 -r1.12.2.3 src/sys/dev/nvmm/nvmm_internal.h
cvs rdiff -u -r1.46.4.5 -r1.46.4.6 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
cvs rdiff -u -r1.36.2.7 -r1.36.2.8 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
cvs rdiff -u -r1.1 -r1.1.8.1 src/sys/modules/nvmm/nvmm.ioconf

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/nvmm/files.nvmm
diff -u src/sys/dev/nvmm/files.nvmm:1.2 src/sys/dev/nvmm/files.nvmm:1.2.6.1
--- src/sys/dev/nvmm/files.nvmm:1.2	Thu Mar 28 19:00:40 2019
+++ src/sys/dev/nvmm/files.nvmm	Sun Aug  2 08:49:08 2020
@@ -1,6 +1,6 @@
-#	$NetBSD: files.nvmm,v 1.2 2019/03/28 19:00:40 maxv Exp $
+#	$NetBSD: files.nvmm,v 1.2.6.1 2020/08/02 08:49:08 martin Exp $
 
-defpseudo nvmm
+defpseudodev nvmm
 
 file	dev/nvmm/nvmm.c			nvmm
 

Index: src/sys/dev/nvmm/nvmm.c
diff -u src/sys/dev/nvmm/nvmm.c:1.22.2.4 src/sys/dev/nvmm/nvmm.c:1.22.2.5
--- src/sys/dev/nvmm/nvmm.c:1.22.2.4	Thu May 21 10:52:58 2020
+++ src/sys/dev/nvmm/nvmm.c	Sun Aug  2 08:49:08 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: nvmm.c,v 1.22.2.4 2020/05/21 10:52:58 martin Exp $	*/
+/*	$NetBSD: nvmm.c,v 1.22.2.5 2020/08/02 08:49:08 martin Exp $	*/
 
 /*
- * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.22.2.4 2020/05/21 10:52:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.22.2.5 2020/08/02 08:49:08 martin Exp $");
 
 #include 
 #include 
@@ -44,7 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.2
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 
@@ -570,11 +570,19 @@ nvmm_do_vcpu_run(struct nvmm_machine *ma
 	int ret;
 
 	while (1) {
+		/* Got a signal? Or pending resched? Leave. */
+		if (__predict_false(nvmm_return_needed())) {
+			exit->reason = NVMM_VCPU_EXIT_NONE;
+			return 0;
+		}
+
+		/* Run the VCPU. */
 		ret = (*nvmm_impl->vcpu_run)(mach, vcpu, exit);
 		if (__predict_false(ret != 0)) {
 			return ret;
 		}
 
+		/* Process nested page faults. */
 		if (__predict_true(exit->reason != NVMM_VCPU_EXIT_MEMORY)) {
 			break;
 		}
@@ -952,22 +960,27 @@ nvmm_ctl(struct nvmm_owner *owner, struc
 
 /* -- */
 
+static const struct nvmm_impl *
+nvmm_ident(void)
+{
+	size_t i;
+
+	for (i = 0; i < __arraycount(nvmm_impl_list); i++) {
+		if ((*nvmm_impl_list[i]->ident)())
+			return nvmm_impl_list[i];
+	}
+
+	return NULL;
+}
+
 static int
 nvmm_init(void)
 {
 	size_t i, n;
 
-	for (i = 0; i < __arraycount(nvmm_impl_list); i++) {
-		if (!(*nvmm_impl_list[i]->ident)()) {
-			continue;
-		}
-		nvmm_impl = nvmm_impl_list[i];
-		break;
-	}
-	if (nvmm_impl == NULL) {
-		printf("NVMM: CPU not supported\n");
+	nvmm_impl = nvm

CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 08:10:36 UTC 2020

Modified Files:
src/usr.bin/make: for.c

Log Message:
make(1): move and condense comment for For_Run

It was simply wrong that calling For_Run had "Side Effects: None".


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/usr.bin/make/for.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/make/for.c
diff -u src/usr.bin/make/for.c:1.59 src/usr.bin/make/for.c:1.60
--- src/usr.bin/make/for.c:1.59	Sat Aug  1 21:40:49 2020
+++ src/usr.bin/make/for.c	Sun Aug  2 08:10:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.59 2020/08/01 21:40:49 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.60 2020/08/02 08:10:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -30,14 +30,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: for.c,v 1.59 2020/08/01 21:40:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.60 2020/08/02 08:10:36 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)for.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: for.c,v 1.59 2020/08/01 21:40:49 rillig Exp $");
+__RCSID("$NetBSD: for.c,v 1.60 2020/08/02 08:10:36 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -311,19 +311,6 @@ For_Accum(char *line)
 }
 
 
-/*-
- *---
- * For_Run --
- *	Run the for loop, imitating the actions of an include file
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	None.
- *
- *---
- */
 
 static size_t
 for_var_len(const char *var)
@@ -477,6 +464,7 @@ For_Iterate(void *v_arg, size_t *ret_len
 return cp;
 }
 
+/* Run the for loop, imitating the actions of an include file. */
 void
 For_Run(int lineno)
 {



CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 08:06:35 UTC 2020

Modified Files:
src/usr.bin/make: main.c

Log Message:
make(1): replace one instance of strncpy with snprintf

GCC 9 incorrectly claims that the string might not be null-terminated.
Since objdir is a global variable, it is initialized to zero, and the +1
in the size guarantees that this byte is always 0.

Still, using strncpy to initialize a string is a waste of memory access,
since it is enough if only the actual data is copied, without zeroing
out all the remaining bytes.


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/usr.bin/make/main.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/make/main.c
diff -u src/usr.bin/make/main.c:1.294 src/usr.bin/make/main.c:1.295
--- src/usr.bin/make/main.c:1.294	Sat Aug  1 21:40:49 2020
+++ src/usr.bin/make/main.c	Sun Aug  2 08:06:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.294 2020/08/01 21:40:49 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.295 2020/08/02 08:06:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.294 2020/08/01 21:40:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.295 2020/08/02 08:06:35 rillig Exp $";
 #else
 #include 
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.294 2020/08/01 21:40:49 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.295 2020/08/02 08:06:35 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -745,7 +745,7 @@ Main_SetObjdir(const char *fmt, ...)
 			(void)fprintf(stderr, "make warning: %s: %s.\n",
   path, strerror(errno));
 		} else {
-			strncpy(objdir, path, MAXPATHLEN);
+			snprintf(objdir, sizeof objdir, "%s", path);
 			Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
 			setenv("PWD", objdir, 1);
 			Dir_InitDot();



CVS commit: [netbsd-9] src/doc

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 07:49:46 UTC 2020

Modified Files:
src/doc [netbsd-9]: CHANGES-9.1

Log Message:
Ticket #1031


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.84 -r1.1.2.85 src/doc/CHANGES-9.1

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-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.84 src/doc/CHANGES-9.1:1.1.2.85
--- src/doc/CHANGES-9.1:1.1.2.84	Sun Jul 26 11:09:19 2020
+++ src/doc/CHANGES-9.1	Sun Aug  2 07:49:46 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.84 2020/07/26 11:09:19 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.85 2020/08/02 07:49:46 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -3557,3 +3557,9 @@ distrib/notes/evbarm/hardware			1.15
 	Add more supported hardware.
 	[nia, ticket #1030]
 
+sys/arch/x86/x86/cpu.c			patch
+
+	Fix a panic on a CPU which has no rdtsc instruction. This bug was
+	added in ticket #1015.
+	[msaitoh, ticket #1031]
+



CVS commit: [netbsd-9] src/sys/arch/x86/x86

2020-08-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  2 07:33:38 UTC 2020

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: cpu.c

Log Message:
Apply patch, requested by msaitoh in ticket #1031:

sys/arch/x86/x86/cpu.c  patch

Fix a panic on a CPU which has no rdtsc instruction. This bug was
added in ticket #1015.


To generate a diff of this commit:
cvs rdiff -u -r1.171.2.2 -r1.171.2.3 src/sys/arch/x86/x86/cpu.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/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.171.2.2 src/sys/arch/x86/x86/cpu.c:1.171.2.3
--- src/sys/arch/x86/x86/cpu.c:1.171.2.2	Wed Jul 15 17:25:08 2020
+++ src/sys/arch/x86/x86/cpu.c	Sun Aug  2 07:33:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.171.2.2 2020/07/15 17:25:08 martin Exp $	*/
+/*	$NetBSD: cpu.c,v 1.171.2.3 2020/08/02 07:33:38 martin Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.171.2.2 2020/07/15 17:25:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.171.2.3 2020/08/02 07:33:38 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -1267,18 +1267,19 @@ cpu_get_tsc_freq(struct cpu_info *ci)
 {
 	uint64_t freq = 0, last_tsc;
 
-	if (cpu_hascounter())
+	if (cpu_hascounter()) {
 		freq = cpu_tsc_freq_cpuid(ci);
 
-	if (freq != 0) {
-		/* Use TSC frequency taken from CPUID. */
-		ci->ci_data.cpu_cc_freq = freq;
-	} else {
-		/* Calibrate TSC frequency. */
-		last_tsc = cpu_counter_serializing();
-		x86_delay(10);
-		ci->ci_data.cpu_cc_freq =
-		(cpu_counter_serializing() - last_tsc) * 10;
+		if (freq != 0) {
+			/* Use TSC frequency taken from CPUID. */
+			ci->ci_data.cpu_cc_freq = freq;
+		} else {
+			/* Calibrate TSC frequency. */
+			last_tsc = cpu_counter_serializing();
+			x86_delay(10);
+			ci->ci_data.cpu_cc_freq =
+			(cpu_counter_serializing() - last_tsc) * 10;
+		}
 	}
 }
 



CVS commit: src/sys/net

2020-08-02 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Aug  2 07:19:39 UTC 2020

Modified Files:
src/sys/net: bpf.c

Log Message:
Use a more informative panic message.


To generate a diff of this commit:
cvs rdiff -u -r1.237 -r1.238 src/sys/net/bpf.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/net/bpf.c
diff -u src/sys/net/bpf.c:1.237 src/sys/net/bpf.c:1.238
--- src/sys/net/bpf.c:1.237	Thu Jun 11 13:36:20 2020
+++ src/sys/net/bpf.c	Sun Aug  2 07:19:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.237 2020/06/11 13:36:20 roy Exp $	*/
+/*	$NetBSD: bpf.c,v 1.238 2020/08/02 07:19:39 maxv Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.237 2020/06/11 13:36:20 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.238 2020/08/02 07:19:39 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -2118,7 +2118,7 @@ _bpfattach(struct ifnet *ifp, u_int dlt,
 	struct bpf_if *bp;
 	bp = kmem_alloc(sizeof(*bp), KM_NOSLEEP);
 	if (bp == NULL)
-		panic("bpfattach");
+		panic("%s: out of memory", __func__);
 
 	mutex_enter(&bpf_mtx);
 	bp->bif_driverp = driverp;



CVS commit: src/doc

2020-08-02 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Aug  2 07:15:05 UTC 2020

Modified Files:
src/doc: CHANGES

Log Message:
Note PAN.


To generate a diff of this commit:
cvs rdiff -u -r1.2722 -r1.2723 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.2722 src/doc/CHANGES:1.2723
--- src/doc/CHANGES:1.2722	Sat Aug  1 08:22:37 2020
+++ src/doc/CHANGES	Sun Aug  2 07:15:05 2020
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2722 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2723 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -264,3 +264,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	xen: MSI enabled by default [jdolecek 20200728]
 	kernel: remove the BRIDGE_IPF option, build its code by default
 		unconditionally. [maxv 20200801]
+	aarch64: Add support for Privileged Access Never (PAN).
+		[maxv 20200802]