CVS commit: src

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 07:58:48 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_bool_strict_syshdr.c
d_c99_bool_strict_syshdr.exp
src/usr.bin/xlint/lint1: lex.c

Log Message:
lint: explain why !finite(x) is not allowed in strict bool mode


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/xlint/lint1/lex.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.6 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.7
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.6	Sat Jan 23 23:11:40 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c	Sun Jan 24 07:58:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.6 2021/01/23 23:11:40 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.7 2021/01/24 07:58:48 rillig Exp $	*/
 # 3 "d_c99_bool_strict_syshdr.c"
 
 /*
@@ -122,17 +122,50 @@ ch_isspace_sys_bool(char c)
 }
 
 /*
- * If a function from a system header has return type int, which has
- * traditionally been used for the missing type bool, it may be used
- * in controlling expressions.
+ * There are several functions from system headers that have return type
+ * int.  For this return type there are many API conventions:
+ *
+ *	* isspace: 0 means no, non-zero means yes
+ *	* open: 0 means success, -1 means failure
+ *	* main: 0 means success, non-zero means failure
+ *	* strcmp: 0 means equal, < 0 means less than, > 0 means greater than
+ *
+ * Without a detailed list of individual functions, it's not possible to
+ * guess what the return value means.  Therefore in strict bool mode, the
+ * return value of these functions cannot be implicitly converted to bool,
+ * not even in a context where the result is compared to 0.  Allowing that
+ * would allow expressions like !strcmp(s1, s2), which is not correct since
+ * strcmp returns an "ordered comparison result", not a bool.
  */
 
 # 1 "math.h" 3 4
 extern int finite(double);
-# 133 "d_c99_bool_strict_syshdr.c"
+# 1 "string.h" 3 4
+extern int strcmp(const char *, const char *);
+# 146 "d_c99_bool_strict_syshdr.c"
+
+/*ARGSUSED*/
+_Bool
+call_finite_bad(double d)
+{
+	return finite(d);	/* expect: 211 */
+}
+
+_Bool
+call_finite_good(double d)
+{
+	return finite(d) != 0;
+}
+
+/*ARGSUSED*/
+_Bool
+str_equal_bad(const char *s1, const char *s2)
+{
+	return !strcmp(s1, s2);	/* expect: 330, 214 */
+}
 
 _Bool
-call_finite(double d)		/*FIXME*//* expect: 231 */
+str_equal_good(const char *s1, const char *s2)
 {
-	return finite(d);	/*FIXME*//* expect: 211 */
+	return strcmp(s1, s2) == 0;
 }
Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.6 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.7
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.6	Sat Jan 23 23:11:40 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp	Sun Jan 24 07:58:48 2021
@@ -1,5 +1,6 @@
 d_c99_bool_strict_syshdr.c(32): controlling expression must be bool, not 'int' [333]
 d_c99_bool_strict_syshdr.c(42): controlling expression must be bool, not 'int' [333]
 d_c99_bool_strict_syshdr.c(76): operands of '=' have incompatible types (_Bool != int) [107]
-d_c99_bool_strict_syshdr.c(137): return value type mismatch (_Bool) and (int) [211]
-d_c99_bool_strict_syshdr.c(135): warning: argument d unused in function call_finite [231]
+d_c99_bool_strict_syshdr.c(151): return value type mismatch (_Bool) and (int) [211]
+d_c99_bool_strict_syshdr.c(164): operand of '!' must be bool, not 'int' [330]
+d_c99_bool_strict_syshdr.c(164): warning: function str_equal_bad expects to return value [214]

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.4 src/usr.bin/xlint/lint1/lex.c:1.5
--- src/usr.bin/xlint/lint1/lex.c:1.4	Sun Jan 24 00:02:38 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sun Jan 24 07:58:48 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.4 2021/01/24 00:02:38 christos Exp $ */
+/* $NetBSD: lex.c,v 1.5 2021/01/24 07:58:48 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.4 2021/01/24 00:02:38 christos Exp $");
+__RCSID("$NetBSD: lex.c,v 1.5 2021/01/24 07:58:48 rillig Exp $");
 #endif
 
 #include 
@@ -770,7 +770,7 @@ lex_fcon(const char *yytext, size_t yyle
 
 	if (typ == FLOAT) {
 		f = (float)d;
-		if (!finite(f)) {
+		if (finite(f) == 0) {
 			/* floating-point constant out of range */
 			warning(248);
 			f = 

CVS commit: src/sys/arch/sparc

2021-01-23 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Jan 24 07:36:54 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: cons.h
src/sys/arch/sparc/include: autoconf.h cpu.h db_machdep.h intr.h pmap.h
trap.h
src/sys/arch/sparc/sparc: autoconf.c cache.c cpu.c db_interface.c
eeprom.c intr.c locore.s machdep.c memecc.c mkclock.c msiiepvar.h
oclock.c pci_fixup.c pmap.c process_machdep.c promlib.c timervar.h
trap.c
Added Files:
src/sys/arch/sparc/include: locore.h

Log Message:
avoid using 'extern ;' inside a .c file, but instead
use header files and ensure definitions are not duplicated or
are technically (if not in codegen) wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc/dev/cons.h
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/sparc/include/autoconf.h
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/sparc/include/cpu.h
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sparc/include/db_machdep.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc/include/intr.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc/include/locore.h
cvs rdiff -u -r1.95 -r1.96 src/sys/arch/sparc/include/pmap.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/include/trap.h
cvs rdiff -u -r1.263 -r1.264 src/sys/arch/sparc/sparc/autoconf.c
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/sparc/sparc/cache.c
cvs rdiff -u -r1.258 -r1.259 src/sys/arch/sparc/sparc/cpu.c
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/sparc/sparc/db_interface.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/sparc/eeprom.c \
src/sys/arch/sparc/sparc/msiiepvar.h
cvs rdiff -u -r1.126 -r1.127 src/sys/arch/sparc/sparc/intr.c
cvs rdiff -u -r1.278 -r1.279 src/sys/arch/sparc/sparc/locore.s
cvs rdiff -u -r1.335 -r1.336 src/sys/arch/sparc/sparc/machdep.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc/sparc/memecc.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/sparc/mkclock.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sparc/sparc/oclock.c \
src/sys/arch/sparc/sparc/process_machdep.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc/sparc/pci_fixup.c
cvs rdiff -u -r1.372 -r1.373 src/sys/arch/sparc/sparc/pmap.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/sparc/sparc/promlib.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc/sparc/timervar.h
cvs rdiff -u -r1.199 -r1.200 src/sys/arch/sparc/sparc/trap.c

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

Modified files:

Index: src/sys/arch/sparc/dev/cons.h
diff -u src/sys/arch/sparc/dev/cons.h:1.5 src/sys/arch/sparc/dev/cons.h:1.6
--- src/sys/arch/sparc/dev/cons.h:1.5	Wed Nov 16 00:49:03 2005
+++ src/sys/arch/sparc/dev/cons.h	Sun Jan 24 07:36:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cons.h,v 1.5 2005/11/16 00:49:03 uwe Exp $	*/
+/*	$NetBSD: cons.h,v 1.6 2021/01/24 07:36:53 mrg Exp $	*/
 
 
 /*
@@ -9,6 +9,7 @@ extern int prom_stdin_node;
 extern int prom_stdout_node;
 extern char prom_stdin_args[];
 extern char prom_stdout_args[];
+extern struct consdev consdev_prom;
 
 #ifdef	KGDB
 struct zs_chanstate;

Index: src/sys/arch/sparc/include/autoconf.h
diff -u src/sys/arch/sparc/include/autoconf.h:1.49 src/sys/arch/sparc/include/autoconf.h:1.50
--- src/sys/arch/sparc/include/autoconf.h:1.49	Sun Jan 17 01:02:28 2021
+++ src/sys/arch/sparc/include/autoconf.h	Sun Jan 24 07:36:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.h,v 1.49 2021/01/17 01:02:28 mrg Exp $ */
+/*	$NetBSD: autoconf.h,v 1.50 2021/01/24 07:36:54 mrg Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -179,5 +179,7 @@ int	romgetcursoraddr(int **, int **);
 
 /* Exported from autoconf.c for other consumers.  */
 extern char	machine_model[100];
+extern struct sparc_bus_dma_tag mainbus_dma_tag;
+extern struct sparc_bus_space_tag mainbus_space_tag;
 
 #endif /* !_MACHINE_AUTOCONF_H_ */

Index: src/sys/arch/sparc/include/cpu.h
diff -u src/sys/arch/sparc/include/cpu.h:1.108 src/sys/arch/sparc/include/cpu.h:1.109
--- src/sys/arch/sparc/include/cpu.h:1.108	Sat May 16 17:52:42 2020
+++ src/sys/arch/sparc/include/cpu.h	Sun Jan 24 07:36:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.108 2020/05/16 17:52:42 ad Exp $ */
+/*	$NetBSD: cpu.h,v 1.109 2021/01/24 07:36:54 mrg Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -490,6 +490,9 @@ extern int sparc_ncpus;
 /* Provide %pc of a lwp */
 #define LWP_PC(l)   ((l)->l_md.md_tf->tf_pc)
 
+/* Hardware cross-call mutex */
+extern kmutex_t xpmsg_mutex;
+
 /*
  * Interrupt handler chains.  Interrupt handlers should return 0 for
  * ``not me'' or 1 (``I took care of it'').  intr_establish() inserts a

Index: src/sys/arch/sparc/include/db_machdep.h
diff -u src/sys/arch/sparc/include/db_machdep.h:1.28 src/sys/arch/sparc/include/db_machdep.h:1.29
--- src/sys/arch/sparc/include/db_machdep.h:1.28	Mon Nov  6 03:47:48 2017
+++ src/sys/arch/sparc/include/db_machdep.h	Sun Jan 24 07:36:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.h,v 1.28 2017/11/06 03:47:48 christos Exp $ */
+/*	$NetBSD: db_machdep.h,v 

CVS commit: src/sys/dev/i2c

2021-01-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Jan 24 05:30:05 UTC 2021

Modified Files:
src/sys/dev/i2c: adm1021.c

Log Message:
Use temperature sensors as rnd(9) sources.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/i2c/adm1021.c

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

Modified files:

Index: src/sys/dev/i2c/adm1021.c
diff -u src/sys/dev/i2c/adm1021.c:1.22 src/sys/dev/i2c/adm1021.c:1.23
--- src/sys/dev/i2c/adm1021.c:1.22	Sun Jan 17 21:42:35 2021
+++ src/sys/dev/i2c/adm1021.c	Sun Jan 24 05:30:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: adm1021.c,v 1.22 2021/01/17 21:42:35 thorpej Exp $ */
+/*	$NetBSD: adm1021.c,v 1.23 2021/01/24 05:30:05 rin Exp $ */
 /*	$OpenBSD: adm1021.c,v 1.27 2007/06/24 05:34:35 dlg Exp $	*/
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.22 2021/01/17 21:42:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.23 2021/01/24 05:30:05 rin Exp $");
 
 #include 
 #include 
@@ -377,8 +377,10 @@ admtemp_attach(device_t parent, device_t
 	sc->sc_sensor[ADMTEMP_INT].units = ENVSYS_STEMP;
 	sc->sc_sensor[ADMTEMP_EXT].state = ENVSYS_SINVALID;
 	sc->sc_sensor[ADMTEMP_EXT].units = ENVSYS_STEMP;
-	sc->sc_sensor[ADMTEMP_INT].flags = ENVSYS_FMONLIMITS;
-	sc->sc_sensor[ADMTEMP_EXT].flags = ENVSYS_FMONLIMITS;
+	sc->sc_sensor[ADMTEMP_INT].flags =
+	ENVSYS_FMONLIMITS | ENVSYS_FHAS_ENTROPY;
+	sc->sc_sensor[ADMTEMP_EXT].flags =
+	ENVSYS_FMONLIMITS | ENVSYS_FHAS_ENTROPY;
 
 	if (prop_dictionary_get_cstring_nocopy(sc->sc_prop, "s00", )) {
 		strncpy(iname, desc, 64);



CVS commit: src/sys/arch/powerpc/ibm4xx/dev

2021-01-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Jan 24 05:22:22 UTC 2021

Modified Files:
src/sys/arch/powerpc/ibm4xx/dev: if_emac.c

Log Message:
Add rnd(9) support.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/powerpc/ibm4xx/dev/if_emac.c

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

Modified files:

Index: src/sys/arch/powerpc/ibm4xx/dev/if_emac.c
diff -u src/sys/arch/powerpc/ibm4xx/dev/if_emac.c:1.53 src/sys/arch/powerpc/ibm4xx/dev/if_emac.c:1.54
--- src/sys/arch/powerpc/ibm4xx/dev/if_emac.c:1.53	Mon Jul  6 09:34:17 2020
+++ src/sys/arch/powerpc/ibm4xx/dev/if_emac.c	Sun Jan 24 05:22:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_emac.c,v 1.53 2020/07/06 09:34:17 rin Exp $	*/
+/*	$NetBSD: if_emac.c,v 1.54 2021/01/24 05:22:21 rin Exp $	*/
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_emac.c,v 1.53 2020/07/06 09:34:17 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_emac.c,v 1.54 2021/01/24 05:22:21 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_emac.h"
@@ -67,6 +67,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_emac.c,v 
 #include 
 #include 
 
+#include 
+
 #include 		/* for PAGE_SIZE */
 
 #include 
@@ -210,6 +212,8 @@ struct emac_softc {
 
 	int sc_rxptr;			/* next ready RX descriptor/descsoft */
 
+	krndsource_t rnd_source;	/* random source */
+
 	void (*sc_rmii_enable)(device_t, int);		/* reduced MII enable */
 	void (*sc_rmii_disable)(device_t, int);		/* reduced MII disable*/
 	void (*sc_rmii_speed)(device_t, int, int);	/* reduced MII speed */
@@ -555,6 +559,9 @@ emac_attach(device_t parent, device_t se
 	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, enaddr);
 
+	rnd_attach_source(>rnd_source, xname, RND_TYPE_NET,
+	RND_FLAG_DEFAULT);
+
 #ifdef EMAC_EVENT_COUNTERS
 	/*
 	 * Attach the event counters.
@@ -1254,13 +1261,14 @@ emac_txreap(struct emac_softc *sc)
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	struct emac_txsoft *txs;
 	int handled, i;
-	uint32_t txstat;
+	uint32_t txstat, count;
 
 	EMAC_EVCNT_INCR(>sc_ev_txreap);
 	handled = 0;
 
 	ifp->if_flags &= ~IFF_OACTIVE;
 
+	count = 0;
 	/*
 	 * Go through our Tx list and free mbufs for those
 	 * frames that have been transmitted.
@@ -1317,6 +1325,8 @@ emac_txreap(struct emac_softc *sc)
 		bus_dmamap_unload(sc->sc_dmat, txs->txs_dmamap);
 		m_freem(txs->txs_mbuf);
 		txs->txs_mbuf = NULL;
+
+		count++;
 	}
 
 	/* Update the dirty transmit buffer pointer. */
@@ -1329,6 +1339,9 @@ emac_txreap(struct emac_softc *sc)
 	if (sc->sc_txsfree == EMAC_TXQUEUELEN)
 		ifp->if_timer = 0;
 
+	if (count != 0)
+		rnd_add_uint32(>rnd_source, count);
+
 	return handled;
 }
 
@@ -1582,11 +1595,12 @@ emac_rxeob_intr(void *arg)
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	struct emac_rxsoft *rxs;
 	struct mbuf *m;
-	uint32_t rxstat;
+	uint32_t rxstat, count;
 	int i, len;
 
 	EMAC_EVCNT_INCR(>sc_ev_rxintr);
 
+	count = 0;
 	for (i = sc->sc_rxptr; ; i = EMAC_NEXTRX(i)) {
 		rxs = >sc_rxsoft[i];
 
@@ -1681,11 +1695,16 @@ emac_rxeob_intr(void *arg)
 
 		/* Pass it on. */
 		if_percpuq_enqueue(ifp->if_percpuq, m);
+
+		count++;
 	}
 
 	/* Update the receive pointer. */
 	sc->sc_rxptr = i;
 
+	if (count != 0)
+		rnd_add_uint32(>rnd_source, count);
+
 	return 1;
 }
 



CVS commit: src/sys/arch/mac68k

2021-01-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Jan 24 05:20:23 UTC 2021

Modified Files:
src/sys/arch/mac68k/dev: if_mc.c if_mcvar.h
src/sys/arch/mac68k/obio: if_mc_obio.c

Log Message:
Add rnd(9) support.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/mac68k/dev/if_mc.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/mac68k/dev/if_mcvar.h
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/mac68k/obio/if_mc_obio.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/mac68k/dev/if_mc.c
diff -u src/sys/arch/mac68k/dev/if_mc.c:1.56 src/sys/arch/mac68k/dev/if_mc.c:1.57
--- src/sys/arch/mac68k/dev/if_mc.c:1.56	Tue Oct 20 18:17:58 2020
+++ src/sys/arch/mac68k/dev/if_mc.c	Sun Jan 24 05:20:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mc.c,v 1.56 2020/10/20 18:17:58 roy Exp $	*/
+/*	$NetBSD: if_mc.c,v 1.57 2021/01/24 05:20:23 rin Exp $	*/
 
 /*-
  * Copyright (c) 1997 David Huang 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.56 2020/10/20 18:17:58 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.57 2021/01/24 05:20:23 rin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -51,6 +51,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.
 #include 
 #include 
 
+#include 
+
 #include 
 
 #include 
@@ -158,6 +160,9 @@ mcsetup(struct mc_softc	*sc, uint8_t *ll
 	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, lladdr);
 
+	rnd_attach_source(>rnd_source, ifp->if_xname, RND_TYPE_NET,
+	RND_FLAG_DEFAULT);
+
 	return 0;
 }
 
@@ -516,6 +521,8 @@ mc_tint(struct mc_softc *sc)
 	sc->sc_if.if_flags &= ~IFF_OACTIVE;
 	sc->sc_if.if_timer = 0;
 	if_schedule_deferred_start(>sc_if);
+
+	rnd_add_uint32(>rnd_source, xmtfs);
 }
 
 void
@@ -559,6 +566,8 @@ mc_rint(struct mc_softc *sc)
 	}
 
 	mace_read(sc, rxf.rx_frame, len);
+
+	rnd_add_uint32(>rnd_source, rxf.rx_rcvsts);
 #undef	rxf
 }
 

Index: src/sys/arch/mac68k/dev/if_mcvar.h
diff -u src/sys/arch/mac68k/dev/if_mcvar.h:1.16 src/sys/arch/mac68k/dev/if_mcvar.h:1.17
--- src/sys/arch/mac68k/dev/if_mcvar.h:1.16	Sat Oct 27 17:17:59 2012
+++ src/sys/arch/mac68k/dev/if_mcvar.h	Sun Jan 24 05:20:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcvar.h,v 1.16 2012/10/27 17:17:59 chs Exp $	*/
+/*	$NetBSD: if_mcvar.h,v 1.17 2021/01/24 05:20:23 rin Exp $	*/
 
 /*-
  * Copyright (c) 1997 David Huang 
@@ -87,6 +87,8 @@ struct mc_softc {
 	int		sc_tail;
 	int		sc_rxset;
 	int		sc_txset, sc_txseti;
+
+	krndsource_t rnd_source;
 };
 
 int	mcsetup(struct mc_softc *, u_int8_t *);

Index: src/sys/arch/mac68k/obio/if_mc_obio.c
diff -u src/sys/arch/mac68k/obio/if_mc_obio.c:1.18 src/sys/arch/mac68k/obio/if_mc_obio.c:1.19
--- src/sys/arch/mac68k/obio/if_mc_obio.c:1.18	Sat Oct 27 17:18:00 2012
+++ src/sys/arch/mac68k/obio/if_mc_obio.c	Sun Jan 24 05:20:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mc_obio.c,v 1.18 2012/10/27 17:18:00 chs Exp $	*/
+/*	$NetBSD: if_mc_obio.c,v 1.19 2021/01/24 05:20:23 rin Exp $	*/
 
 /*-
  * Copyright (c) 1997 David Huang 
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_mc_obio.c,v 1.18 2012/10/27 17:18:00 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc_obio.c,v 1.19 2021/01/24 05:20:23 rin Exp $");
 
 #include "opt_ddb.h"
 
@@ -46,6 +46,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_mc_obio.c
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 



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

2021-01-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Jan 24 05:16:57 UTC 2021

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Add rnd(9) support.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/powerpc/booke/dev/pq3etsec.c

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

Modified files:

Index: src/sys/arch/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.51 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.52
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.51	Sun Jan 24 05:14:55 2021
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Sun Jan 24 05:16:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.51 2021/01/24 05:14:55 rin Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.52 2021/01/24 05:16:56 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.51 2021/01/24 05:14:55 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.52 2021/01/24 05:16:56 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -58,6 +58,8 @@ __KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -237,6 +239,8 @@ struct pq3etsec_softc {
 	int sc_ic_rx_count;
 	int sc_ic_tx_time;
 	int sc_ic_tx_count;
+
+	krndsource_t rnd_source;
 };
 
 #define	ETSEC_IC_RX_ENABLED(sc)		\
@@ -808,6 +812,9 @@ pq3etsec_attach(device_t parent, device_
 	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, enaddr);
 
+	rnd_attach_source(>rnd_source, xname, RND_TYPE_NET,
+	RND_FLAG_DEFAULT);
+
 	pq3etsec_ifstop(ifp, true);
 
 	evcnt_attach_dynamic(>sc_ev_rx_stall, EVCNT_TYPE_MISC,
@@ -1714,6 +1721,9 @@ pq3etsec_rxq_consume(
 		KASSERT(rxq->rxq_mbufs[consumer - rxq->rxq_first] == rxq->rxq_mconsumer);
 #endif
 	}
+
+	if (rxconsumed != 0)
+		rnd_add_uint32(>rnd_source, rxconsumed);
 }
 
 static void
@@ -2261,6 +2271,9 @@ pq3etsec_txq_consume(
 			KASSERT(consumer < txq->txq_last);
 		}
 	}
+
+	if (txfree != 0)
+		rnd_add_uint32(>rnd_source, txfree);
 }
 
 static void



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

2021-01-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Jan 24 05:14:55 UTC 2021

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Switch to if_percpuq_enqueue() from if_input().


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/powerpc/booke/dev/pq3etsec.c

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

Modified files:

Index: src/sys/arch/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.50 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.51
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.50	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Sun Jan 24 05:14:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.50 2020/07/06 09:34:16 rin Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.51 2021/01/24 05:14:55 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.50 2020/07/06 09:34:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.51 2021/01/24 05:14:55 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -804,8 +804,9 @@ pq3etsec_attach(device_t parent, device_
 		goto fail_10;
 	}
 	pq3etsec_sysctl_setup(NULL, sc);
+	if_attach(ifp);
+	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, enaddr);
-	if_register(ifp);
 
 	pq3etsec_ifstop(ifp, true);
 
@@ -1613,9 +1614,7 @@ pq3etsec_rx_input(
 	/*
 	 * Let's give it to the network subsystm to deal with.
 	 */
-	int s = splnet();
-	if_input(ifp, m);
-	splx(s);
+	if_percpuq_enqueue(ifp->if_percpuq, m);
 }
 
 static void



CVS commit: src/sys/dev/pci

2021-01-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 24 01:44:12 UTC 2021

Modified Files:
src/sys/dev/pci: virtio_pci.c

Log Message:
Add a comment explaining why bus_space_write_8 is limited to virtio.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/virtio_pci.c

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

Modified files:

Index: src/sys/dev/pci/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.19 src/sys/dev/pci/virtio_pci.c:1.20
--- src/sys/dev/pci/virtio_pci.c:1.19	Sat Jan 23 15:00:19 2021
+++ src/sys/dev/pci/virtio_pci.c	Sat Jan 23 20:44:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.19 2021/01/23 20:00:19 christos Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.20 2021/01/24 01:44:11 christos Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.19 2021/01/23 20:00:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.20 2021/01/24 01:44:11 christos Exp $");
 
 #include 
 #include 
@@ -733,6 +733,12 @@ virtio_pci_read_queue_size_10(struct vir
  * written as two 4 byters
  */
 #ifndef __HAVE_BUS_SPACE_8
+/*
+ * This is not a general purpose function that can be used in any
+ * driver. Virtio specifically allows the 8 byte bus transaction
+ * to be split into two 4 byte transactions. Do not copy/use it
+ * in other device drivers unless you know that the device accepts it.
+ */
 static __inline void
 bus_space_write_8(bus_space_tag_t iot, bus_space_handle_t ioh,
  bus_size_t offset, uint64_t value)



CVS commit: src/usr.bin/xlint

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 00:15:20 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: decl.c tree.c
src/usr.bin/xlint/lint2: chk.c

Log Message:
lint: update data types in comments from int to bool


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.184 -r1.185 src/usr.bin/xlint/lint1/tree.c
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/xlint/lint2/chk.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/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.130 src/usr.bin/xlint/lint1/decl.c:1.131
--- src/usr.bin/xlint/lint1/decl.c:1.130	Mon Jan 18 19:24:09 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sun Jan 24 00:15:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.130 2021/01/18 19:24:09 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.131 2021/01/24 00:15:20 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.130 2021/01/18 19:24:09 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.131 2021/01/24 00:15:20 rillig Exp $");
 #endif
 
 #include 
@@ -168,7 +168,7 @@ tduptyp(const type_t *tp)
 }
 
 /*
- * Returns 1 if the argument is void or an incomplete array,
+ * Returns whether the argument is void or an incomplete array,
  * struct, union or enum type.
  */
 bool
@@ -2001,8 +2001,8 @@ copy_usage_info(sym_t *sym, sym_t *rdsym
 }
 
 /*
- * Prints an error and returns 1 if a symbol is redeclared/redefined.
- * Otherwise returns 0 and, in some cases of minor problems, prints
+ * Prints an error and returns true if a symbol is redeclared/redefined.
+ * Otherwise returns false and, in some cases of minor problems, prints
  * a warning.
  */
 bool
@@ -2102,12 +2102,12 @@ eqptrtype(const type_t *tp1, const type_
 
 
 /*
- * Checks if two types are compatible. Returns 0 if not, otherwise 1.
+ * Checks if two types are compatible.
  *
  * ignqual	ignore qualifiers of type; used for function params
  * promot	promote left type; used for comparison of params of
  *		old style function definitions with params of prototypes.
- * *dowarn	set to 1 if an old style function declaration is not
+ * *dowarn	set to true if an old style function declaration is not
  *		compatible with a prototype
  */
 bool
@@ -2757,7 +2757,7 @@ declare_external_in_block(sym_t *dsym)
 
 /*
  * Print an error or a warning if the symbol cannot be initialized due
- * to type/storage class. Return 1 if an error has been detected.
+ * to type/storage class. Return whether an error has been detected.
  */
 static bool
 check_init(sym_t *sym)

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.184 src/usr.bin/xlint/lint1/tree.c:1.185
--- src/usr.bin/xlint/lint1/tree.c:1.184	Sat Jan 23 22:34:01 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Jan 24 00:15:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.184 2021/01/23 22:34:01 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.185 2021/01/24 00:15:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.184 2021/01/23 22:34:01 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.185 2021/01/24 00:15:20 rillig Exp $");
 #endif
 
 #include 
@@ -386,8 +386,8 @@ struct_or_union_member(tnode_t *tn, op_t
 	}
 
 	/*
-	 * Set eq to 0 if there are struct/union members with the same name
-	 * and different types and/or offsets.
+	 * Set eq to false if there are struct/union members with the same
+	 * name and different types and/or offsets.
 	 */
 	eq = true;
 	for (csym = msym; csym != NULL; csym = csym->s_link) {
@@ -2614,7 +2614,7 @@ merge_qualifiers(type_t **tpp, type_t *t
 }
 
 /*
- * Returns 1 if the given structure or union has a constant member
+ * Returns true if the given structure or union has a constant member
  * (maybe recursively).
  */
 static bool

Index: src/usr.bin/xlint/lint2/chk.c
diff -u src/usr.bin/xlint/lint2/chk.c:1.36 src/usr.bin/xlint/lint2/chk.c:1.37
--- src/usr.bin/xlint/lint2/chk.c:1.36	Mon Jan 18 20:02:34 2021
+++ src/usr.bin/xlint/lint2/chk.c	Sun Jan 24 00:15:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: chk.c,v 1.36 2021/01/18 20:02:34 rillig Exp $ */
+/* $NetBSD: chk.c,v 1.37 2021/01/24 00:15:20 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: chk.c,v 1.36 2021/01/18 20:02:34 rillig Exp $");
+__RCSID("$NetBSD: chk.c,v 1.37 2021/01/24 00:15:20 rillig Exp $");
 #endif
 
 #include 
@@ -1187,10 +1187,9 @@ chkadecl(hte_t *hte, sym_t *def, sym_t *
 
 
 /*
- * Check compatibility of two types. Returns 1 if types are compatible,
- * otherwise 0.
+ * Check compatibility of two types. Returns whether types are 

CVS commit: src/usr.bin/xlint/xlint

2021-01-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 24 00:11:07 UTC 2021

Modified Files:
src/usr.bin/xlint/xlint: Makefile

Log Message:
fix the build


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/xlint/xlint/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/xlint/xlint/Makefile
diff -u src/usr.bin/xlint/xlint/Makefile:1.19 src/usr.bin/xlint/xlint/Makefile:1.20
--- src/usr.bin/xlint/xlint/Makefile:1.19	Sun Jan 17 14:32:53 2021
+++ src/usr.bin/xlint/xlint/Makefile	Sat Jan 23 19:11:07 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.19 2021/01/17 19:32:53 rillig Exp $
+#	$NetBSD: Makefile,v 1.20 2021/01/24 00:11:07 christos Exp $
 
 .PATH:		${.CURDIR}/../lint1
 .PATH:		${.CURDIR}/../../mkdep
@@ -14,10 +14,10 @@ CPPFLAGS+=	-I${.CURDIR}/../../mkdep
 .if (${HOSTPROG:U} == "")
 DPADD+=		${LIBUTIL}
 LDADD+=		-lutil
-.endif
 
 FILES+=		strict-bool-stdbool.h
 FILESDIR=	/usr/libdata/lint/strict-bool
 FILESNAME_strict-bool-stdbool.h= stdbool.h
+.endif
 
 .include 



CVS commit: src/usr.bin/xlint/lint1

2021-01-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 24 00:02:38 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: lex.c

Log Message:
fix the build


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/xlint/lint1/lex.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/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.3 src/usr.bin/xlint/lint1/lex.c:1.4
--- src/usr.bin/xlint/lint1/lex.c:1.3	Sat Jan 23 18:11:40 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sat Jan 23 19:02:38 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.3 2021/01/23 23:11:40 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.4 2021/01/24 00:02:38 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -32,9 +32,13 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.3 2021/01/23 23:11:40 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.4 2021/01/24 00:02:38 christos Exp $");
 #endif
 
 #include 



CVS commit: src

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 23:11:40 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_bool_strict_syshdr.c
d_c99_bool_strict_syshdr.exp
src/usr.bin/xlint/lint1: externs1.h lex.c

Log Message:
lint: apply strict bool mode to lex.c

There are 2 remaining expressions:

In line 244, !(kw->kw_deco & deco) is a bitwise and.  This is already
allowed for enums, it needs to be allowed for arbitrary integer
expressions as well.  This covers the many places where plain integers
are used for bit fields, together with #define.  This pattern is not as
typesafe as using enums, still it is common practice.

In line 769, the expression !finite(f) is a legitimate use of a function
that has return type int for traditional reasons.  It's the same as for
ferror.

There are several other functions like unlink, open or strcmp that have
return type int as well, but with a different meaning.  It is not yet
clear what the best way is to handle these different meanings.  Having
to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on
the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool
mode wants to avoid.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/xlint/lint1/lex.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.5 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.6
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.5	Sat Jan 23 22:34:01 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c	Sat Jan 23 23:11:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.5 2021/01/23 22:34:01 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.6 2021/01/23 23:11:40 rillig Exp $	*/
 # 3 "d_c99_bool_strict_syshdr.c"
 
 /*
@@ -120,3 +120,19 @@ ch_isspace_sys_bool(char c)
 # 121 "d_c99_bool_strict_syshdr.c"
 	!= 0;
 }
+
+/*
+ * If a function from a system header has return type int, which has
+ * traditionally been used for the missing type bool, it may be used
+ * in controlling expressions.
+ */
+
+# 1 "math.h" 3 4
+extern int finite(double);
+# 133 "d_c99_bool_strict_syshdr.c"
+
+_Bool
+call_finite(double d)		/*FIXME*//* expect: 231 */
+{
+	return finite(d);	/*FIXME*//* expect: 211 */
+}
Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.5 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.6
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.5	Sat Jan 23 22:34:01 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp	Sat Jan 23 23:11:40 2021
@@ -1,3 +1,5 @@
 d_c99_bool_strict_syshdr.c(32): controlling expression must be bool, not 'int' [333]
 d_c99_bool_strict_syshdr.c(42): controlling expression must be bool, not 'int' [333]
 d_c99_bool_strict_syshdr.c(76): operands of '=' have incompatible types (_Bool != int) [107]
+d_c99_bool_strict_syshdr.c(137): return value type mismatch (_Bool) and (int) [211]
+d_c99_bool_strict_syshdr.c(135): warning: argument d unused in function call_finite [231]

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.61 src/usr.bin/xlint/lint1/externs1.h:1.62
--- src/usr.bin/xlint/lint1/externs1.h:1.61	Sat Jan 23 22:20:17 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sat Jan 23 23:11:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.61 2021/01/23 22:20:17 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.62 2021/01/23 23:11:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -77,7 +77,6 @@ extern	FILE	*yyin;
 extern	uint64_t qbmasks[], qlmasks[], qumasks[];
 
 extern	void	initscan(void);
-extern	int	sign(int64_t, tspec_t, int);
 extern	int	msb(int64_t, tspec_t, int);
 extern	int64_t	xsign(int64_t, tspec_t, int);
 extern	void	clear_warn_flags(void);

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.2 src/usr.bin/xlint/lint1/lex.c:1.3
--- src/usr.bin/xlint/lint1/lex.c:1.2	Sat Jan 23 18:30:29 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sat Jan 23 23:11:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.2 2021/01/23 18:30:29 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.3 2021/01/23 23:11:40 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -34,7 +34,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.2 2021/01/23 18:30:29 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.3 2021/01/23 23:11:40 rillig Exp $");
 #endif
 
 #include 
@@ -403,7 +403,7 @@ 

CVS commit: src

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 22:34:01 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_bool_strict_syshdr.c
d_c99_bool_strict_syshdr.exp
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: fix error message for relaxed bool operations in system headers

In strict mode, allowing 1 as bool constant expression is probably not
needed in practice since most comparisons are != 0 instead of == 0.

Furthermore, in the expression (flags & 0x0002) == true, comparing with
true is misleading since the '==' operator can never evaluate to true in
this case.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.4 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.5
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.4	Sat Jan 23 22:20:18 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c	Sat Jan 23 22:34:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.4 2021/01/23 22:20:18 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.5 2021/01/23 22:34:01 rillig Exp $	*/
 # 3 "d_c99_bool_strict_syshdr.c"
 
 /*
@@ -112,11 +112,11 @@ ch_isspace_sys_int(char c)
  * does the comparison itself.
  */
 static inline _Bool
-ch_isspace_sys_bool(char c)	/*FIXME*//* expect: 231 */
+ch_isspace_sys_bool(char c)
 {
 	return
 # 119 "d_c99_bool_strict_syshdr.c" 3 4
 	((ctype_table + 1)[(unsigned char)c] & 0x0040) != 0
 # 121 "d_c99_bool_strict_syshdr.c"
-	!= 0;		/*FIXME*//* expect: 107, 214 */
+	!= 0;
 }
Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.4 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.5
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.4	Sat Jan 23 22:20:18 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp	Sat Jan 23 22:34:01 2021
@@ -1,6 +1,3 @@
 d_c99_bool_strict_syshdr.c(32): controlling expression must be bool, not 'int' [333]
 d_c99_bool_strict_syshdr.c(42): controlling expression must be bool, not 'int' [333]
 d_c99_bool_strict_syshdr.c(76): operands of '=' have incompatible types (_Bool != int) [107]
-d_c99_bool_strict_syshdr.c(121): operands of '!=' have incompatible types (_Bool != int) [107]
-d_c99_bool_strict_syshdr.c(121): warning: function ch_isspace_sys_bool expects to return value [214]
-d_c99_bool_strict_syshdr.c(115): warning: argument c unused in function ch_isspace_sys_bool [231]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.183 src/usr.bin/xlint/lint1/tree.c:1.184
--- src/usr.bin/xlint/lint1/tree.c:1.183	Sat Jan 23 22:20:17 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Jan 23 22:34:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.183 2021/01/23 22:20:17 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.184 2021/01/23 22:34:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.183 2021/01/23 22:20:17 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.184 2021/01/23 22:34:01 rillig Exp $");
 #endif
 
 #include 
@@ -1120,12 +1120,9 @@ is_symmetric_bool_or_other(op_t op)
 }
 
 static bool
-is_bool_int_constant(const tnode_t *tn, tspec_t t)
+is_int_constant_zero(const tnode_t *tn, tspec_t t)
 {
-	return t == INT &&
-	   tn->tn_from_system_header &&
-	   tn->tn_op == CON &&
-	   (tn->tn_val->v_quad == 0 || tn->tn_val->v_quad == 1);
+	return t == INT && tn->tn_op == CON && tn->tn_val->v_quad == 0;
 }
 
 static bool
@@ -1139,7 +1136,8 @@ is_typeok_strict_bool(op_t op,
 	if ((lt == BOOL) == (rt == BOOL))
 		return true;
 
-	if (is_bool_int_constant(ln, lt) || is_bool_int_constant(rn, rt))
+	if ((ln->tn_from_system_header || rn->tn_from_system_header) &&
+	(is_int_constant_zero(ln, lt) || is_int_constant_zero(rn, rt)))
 		return true;
 
 	if (is_assignment_bool_or_other(op)) {



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

2021-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jan 23 22:24:49 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: types.h

Log Message:
Add __HAVE_BUS_SPACE_8


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 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/include/types.h
diff -u src/sys/arch/aarch64/include/types.h:1.16 src/sys/arch/aarch64/include/types.h:1.17
--- src/sys/arch/aarch64/include/types.h:1.16	Mon Sep 14 10:06:35 2020
+++ src/sys/arch/aarch64/include/types.h	Sat Jan 23 22:24:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.16 2020/09/14 10:06:35 ryo Exp $ */
+/* $NetBSD: types.h,v 1.17 2021/01/23 22:24:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -93,6 +93,7 @@ typedef __uint64_t __register_t;
 #define __SIMPLELOCK_UNLOCKED	0
 
 #define __HAVE_ATOMIC64_OPS
+#define __HAVE_BUS_SPACE_8
 #define __HAVE_COMMON___TLS_GET_ADDR
 #define __HAVE_CPU_COUNTER
 #define __HAVE_CPU_DATA_FIRST



CVS commit: src

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 22:20:18 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_bool_strict_syshdr.c
d_c99_bool_strict_syshdr.exp
src/usr.bin/xlint/lint1: externs1.h func.c lint1.h mem1.c tree.c

Log Message:
lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
cvs rdiff -u -r1.60 -r1.61 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.64 -r1.65 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.59 -r1.60 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/lint1/mem1.c
cvs rdiff -u -r1.182 -r1.183 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.3 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.4
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.3	Sat Jan 23 19:03:55 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c	Sat Jan 23 22:20:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.3 2021/01/23 19:03:55 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.4 2021/01/23 22:20:18 rillig Exp $	*/
 # 3 "d_c99_bool_strict_syshdr.c"
 
 /*
@@ -79,13 +79,13 @@ strict_bool_system_header_ctype(int c)
 # 80 "d_c99_bool_strict_syshdr.c" 3 4
 	(int)((ctype_table + 1)[c] & 0x0040) != 0	/* BOOL */
 # 82 "d_c99_bool_strict_syshdr.c"
-	;			/* expect: 107 */
+	;
 
 	if (
 # 86 "d_c99_bool_strict_syshdr.c" 3 4
 	(int)((ctype_table + 1)[c] & 0x0040)	/* INT */
 # 88 "d_c99_bool_strict_syshdr.c"
-	)			/*FIXME*//* expect: 333 */
+	)
 		println("system macro returning INT");
 
 	if (
Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.3 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.4
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.3	Sat Jan 23 19:03:55 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp	Sat Jan 23 22:20:18 2021
@@ -1,8 +1,6 @@
 d_c99_bool_strict_syshdr.c(32): controlling expression must be bool, not 'int' [333]
 d_c99_bool_strict_syshdr.c(42): controlling expression must be bool, not 'int' [333]
 d_c99_bool_strict_syshdr.c(76): operands of '=' have incompatible types (_Bool != int) [107]
-d_c99_bool_strict_syshdr.c(82): operands of '=' have incompatible types (int != _Bool) [107]
-d_c99_bool_strict_syshdr.c(88): controlling expression must be bool, not 'int' [333]
 d_c99_bool_strict_syshdr.c(121): operands of '!=' have incompatible types (_Bool != int) [107]
 d_c99_bool_strict_syshdr.c(121): warning: function ch_isspace_sys_bool expects to return value [214]
 d_c99_bool_strict_syshdr.c(115): warning: argument c unused in function ch_isspace_sys_bool [231]

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.60 src/usr.bin/xlint/lint1/externs1.h:1.61
--- src/usr.bin/xlint/lint1/externs1.h:1.60	Sat Jan 23 17:58:03 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sat Jan 23 22:20:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.60 2021/01/23 17:58:03 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.61 2021/01/23 22:20:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -205,7 +205,7 @@ extern	tnode_t	*new_string_node(strg_t *
 extern	sym_t	*struct_or_union_member(tnode_t *, op_t, sym_t *);
 extern	tnode_t	*build(op_t, tnode_t *, tnode_t *);
 extern	tnode_t	*cconv(tnode_t *);
-extern	bool	is_strict_bool(const tnode_t *);
+extern	bool	is_typeok_bool_operand(const tnode_t *);
 extern	bool	typeok(op_t, int, const tnode_t *, const tnode_t *);
 extern	tnode_t	*promote(op_t, bool, tnode_t *);
 extern	tnode_t	*convert(op_t, int, type_t *, tnode_t *);

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.64 src/usr.bin/xlint/lint1/func.c:1.65
--- src/usr.bin/xlint/lint1/func.c:1.64	Mon Jan 18 20:02:34 2021
+++ src/usr.bin/xlint/lint1/func.c	Sat Jan 23 22:20:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.64 2021/01/18 20:02:34 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.65 2021/01/23 22:20:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.64 2021/01/18 20:02:34 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 

CVS commit: src/sys/dev/pci

2021-01-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 23 20:00:19 UTC 2021

Modified Files:
src/sys/dev/pci: virtio_pci.c

Log Message:
Provide a generic bus_space_write_8 function that is bi-endian.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/pci/virtio_pci.c

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

Modified files:

Index: src/sys/dev/pci/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.18 src/sys/dev/pci/virtio_pci.c:1.19
--- src/sys/dev/pci/virtio_pci.c:1.18	Thu Jan 21 15:48:33 2021
+++ src/sys/dev/pci/virtio_pci.c	Sat Jan 23 15:00:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.18 2021/01/21 20:48:33 reinoud Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.19 2021/01/23 20:00:19 christos Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,12 +28,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.18 2021/01/21 20:48:33 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.19 2021/01/23 20:00:19 christos Exp $");
 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -731,9 +732,20 @@ virtio_pci_read_queue_size_10(struct vir
  * By definition little endian only in v1.0 and 8 byters are allowed to be
  * written as two 4 byters
  */
-#define bus_space_write_le_8(iot, ioh, reg, val) \
-	bus_space_write_4(iot, ioh, reg, ((uint64_t) (val)) & 0x); \
-	bus_space_write_4(iot, ioh, reg + 4, ((uint64_t) (val)) >> 32);
+#ifndef __HAVE_BUS_SPACE_8
+static __inline void
+bus_space_write_8(bus_space_tag_t iot, bus_space_handle_t ioh,
+ bus_size_t offset, uint64_t value)
+{
+#if _QUAD_HIGHWORD
+	bus_space_write_4(iot, ioh, offset, BUS_ADDR_LO32(value));
+	bus_space_write_4(iot, ioh, offset + 4, BUS_ADDR_HI32(value));
+#else
+	bus_space_write_4(iot, ioh, offset, BUS_ADDR_HI32(value));
+	bus_space_write_4(iot, ioh, offset + 4, BUS_ADDR_LO32(value));
+#endif
+}
+#endif
 
 static void
 virtio_pci_setup_queue_10(struct virtio_softc *sc, uint16_t idx, uint64_t addr)
@@ -747,15 +759,15 @@ virtio_pci_setup_queue_10(struct virtio_
 	bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_SELECT, vq->vq_index);
 	if (addr == 0) {
 		bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_ENABLE, 0);
-		bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC,   0);
-		bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL,  0);
-		bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED,   0);
+		bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC,   0);
+		bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL,  0);
+		bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED,   0);
 	} else {
-		bus_space_write_le_8(iot, ioh,
+		bus_space_write_8(iot, ioh,
 			VIRTIO_CONFIG1_QUEUE_DESC, addr);
-		bus_space_write_le_8(iot, ioh,
+		bus_space_write_8(iot, ioh,
 			VIRTIO_CONFIG1_QUEUE_AVAIL, addr + vq->vq_availoffset);
-		bus_space_write_le_8(iot, ioh,
+		bus_space_write_8(iot, ioh,
 			VIRTIO_CONFIG1_QUEUE_USED, addr + vq->vq_usedoffset);
 		bus_space_write_2(iot, ioh,
 			VIRTIO_CONFIG1_QUEUE_ENABLE, 1);
@@ -771,7 +783,6 @@ virtio_pci_setup_queue_10(struct virtio_
 			VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR, vec);
 	}
 }
-#undef bus_space_write_le_8
 
 static void
 virtio_pci_set_status_10(struct virtio_softc *sc, int status)



CVS commit: src/sys/lib/libkern

2021-01-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jan 23 19:41:16 UTC 2021

Modified Files:
src/sys/lib/libkern: strlist.c

Log Message:
Fix building in the _STANDALONE case.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/lib/libkern/strlist.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/lib/libkern/strlist.c
diff -u src/sys/lib/libkern/strlist.c:1.1 src/sys/lib/libkern/strlist.c:1.2
--- src/sys/lib/libkern/strlist.c:1.1	Thu Jan 21 15:43:37 2021
+++ src/sys/lib/libkern/strlist.c	Sat Jan 23 19:41:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: strlist.c,v 1.1 2021/01/21 15:43:37 thorpej Exp $	*/
+/*	$NetBSD: strlist.c,v 1.2 2021/01/23 19:41:16 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -65,12 +65,13 @@ strlist_free(void * const v, size_t cons
 	kmem_free(v, size);
 }
 #elif defined(_STANDALONE)
+#include 
 #include 
 
 static void *
 strlist_alloc(size_t const size)
 {
-	cp = alloc(size);
+	char *cp = alloc(size);
 	if (cp != NULL) {
 		memset(cp, 0, size);
 	}



CVS commit: src/sys/arch

2021-01-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 23 19:38:53 UTC 2021

Modified Files:
src/sys/arch/alpha/include: types.h
src/sys/arch/amd64/include: types.h
src/sys/arch/atari/include: types.h
src/sys/arch/dreamcast/include: types.h
src/sys/arch/evbsh3/include: types.h
src/sys/arch/hp300/include: types.h
src/sys/arch/hpcsh/include: types.h
src/sys/arch/hppa/include: types.h
src/sys/arch/ia64/include: types.h
src/sys/arch/landisk/include: types.h
src/sys/arch/mips/include: types.h
src/sys/arch/ofppc/include: types.h
src/sys/arch/or1k/include: types.h
src/sys/arch/powerpc/include: types.h
src/sys/arch/sparc/include: types.h

Log Message:
Document via __HAVE_BUS_SPACE_8 platforms that implement bus_space_*_8


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/alpha/include/types.h
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/amd64/include/types.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/atari/include/types.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/dreamcast/include/types.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbsh3/include/types.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/hp300/include/types.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hpcsh/include/types.h
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/hppa/include/types.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/ia64/include/types.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/landisk/include/types.h
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/mips/include/types.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/ofppc/include/types.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/or1k/include/types.h
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/powerpc/include/types.h
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/sparc/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/alpha/include/types.h
diff -u src/sys/arch/alpha/include/types.h:1.60 src/sys/arch/alpha/include/types.h:1.61
--- src/sys/arch/alpha/include/types.h:1.60	Thu Sep 24 23:40:11 2020
+++ src/sys/arch/alpha/include/types.h	Sat Jan 23 14:38:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.60 2020/09/25 03:40:11 thorpej Exp $ */
+/* $NetBSD: types.h,v 1.61 2021/01/23 19:38:51 christos Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -86,6 +86,7 @@ typedef __register_t	register_t;
 #define	__HAVE_COMMON___TLS_GET_ADDR
 #define	__HAVE_TLS_VARIANT_I
 #define	__HAVE_UCAS_FULL
+#define	__HAVE_BUS_SPACE_8
 
 #if defined(_KERNEL)
 #define	__HAVE_RAS

Index: src/sys/arch/amd64/include/types.h
diff -u src/sys/arch/amd64/include/types.h:1.69 src/sys/arch/amd64/include/types.h:1.70
--- src/sys/arch/amd64/include/types.h:1.69	Sat Aug  1 08:14:39 2020
+++ src/sys/arch/amd64/include/types.h	Sat Jan 23 14:38:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.69 2020/08/01 12:14:39 jdolecek Exp $	*/
+/*	$NetBSD: types.h,v 1.70 2021/01/23 19:38:52 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -100,6 +100,7 @@ typedef	unsigned char		__cpu_simple_lock
 #define	__HAVE_MM_MD_DIRECT_MAPPED_IO
 #define	__HAVE_MM_MD_DIRECT_MAPPED_PHYS
 #define	__HAVE_UCAS_FULL
+#define	__HAVE_BUS_SPACE_8
 
 #ifdef _KERNEL_OPT
 #define	__HAVE_RAS

Index: src/sys/arch/atari/include/types.h
diff -u src/sys/arch/atari/include/types.h:1.16 src/sys/arch/atari/include/types.h:1.17
--- src/sys/arch/atari/include/types.h:1.16	Sun Dec 18 04:12:18 2011
+++ src/sys/arch/atari/include/types.h	Sat Jan 23 14:38:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.16 2011/12/18 09:12:18 tsutsui Exp $	*/
+/*	$NetBSD: types.h,v 1.17 2021/01/23 19:38:52 christos Exp $	*/
 
 #ifndef _MACHINE_TYPES_H_
 #define	_MACHINE_TYPES_H_
@@ -7,5 +7,6 @@
 
 #define __HAVE_MM_MD_READWRITE
 #define __HAVE_NEW_STYLE_BUS_H
+#define	__HAVE_BUS_SPACE_8
 
 #endif

Index: src/sys/arch/dreamcast/include/types.h
diff -u src/sys/arch/dreamcast/include/types.h:1.4 src/sys/arch/dreamcast/include/types.h:1.5
--- src/sys/arch/dreamcast/include/types.h:1.4	Tue Sep 19 20:41:12 2006
+++ src/sys/arch/dreamcast/include/types.h	Sat Jan 23 14:38:52 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: types.h,v 1.4 2006/09/20 00:41:12 uwe Exp $	*/
+/*	$NetBSD: types.h,v 1.5 2021/01/23 19:38:52 christos Exp $	*/
 #ifndef _DREAMCAST_TYPES_H_
 #define	_DREAMCAST_TYPES_H_
 
 #include 
+#define	__HAVE_BUS_SPACE_8
 
 #endif /* _DREAMCAST_TYPES_H_ */

Index: src/sys/arch/evbsh3/include/types.h
diff -u src/sys/arch/evbsh3/include/types.h:1.2 src/sys/arch/evbsh3/include/types.h:1.3
--- src/sys/arch/evbsh3/include/types.h:1.2	Wed Feb 27 22:17:27 2002
+++ src/sys/arch/evbsh3/include/types.h	Sat Jan 23 14:38:52 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: types.h,v 1.2 2002/02/28 03:17:27 simonb Exp $	*/
+/*	$NetBSD: types.h,v 1.3 2021/01/23 19:38:52 christos Exp $	*/
 #ifndef _EVBSH3_TYPES_H_
 #define	_EVBSH3_TYPES_H_
 
 #include 
+#define	__HAVE_BUS_SPACE_8
 
 #endif /* 

CVS commit: src/sys/arch

2021-01-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 23 19:38:08 UTC 2021

Modified Files:
src/sys/arch/emips/include: bus.h
src/sys/arch/evbcf/include: bus_space.h
src/sys/arch/hp300/include: bus.h
src/sys/arch/luna68k/include: bus.h
src/sys/arch/mac68k/include: bus.h
src/sys/arch/mvme68k/include: bus_space.h
src/sys/arch/news68k/include: bus.h
src/sys/arch/newsmips/include: bus.h
src/sys/arch/next68k/include: bus_space.h
src/sys/arch/vax/include: bus.h

Log Message:
Remove cargo-culted '#if 0' code that was designed to produce a
compile-time error if any of the bus_space_*_8 functions was used,
but was documented that it produces a link-time error.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/emips/include/bus.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbcf/include/bus_space.h
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/hp300/include/bus.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/luna68k/include/bus.h
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/mac68k/include/bus.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/mvme68k/include/bus_space.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/news68k/include/bus.h
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/newsmips/include/bus.h
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/next68k/include/bus_space.h
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/vax/include/bus.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/emips/include/bus.h
diff -u src/sys/arch/emips/include/bus.h:1.4 src/sys/arch/emips/include/bus.h:1.5
--- src/sys/arch/emips/include/bus.h:1.4	Thu Apr  2 11:30:26 2020
+++ src/sys/arch/emips/include/bus.h	Sat Jan 23 14:38:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus.h,v 1.4 2020/04/02 15:30:26 msaitoh Exp $	*/
+/*	$NetBSD: bus.h,v 1.5 2021/01/23 19:38:07 christos Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -143,10 +143,6 @@ void	bus_space_free(bus_space_tag_t t, b
 #define	bus_space_read_4(t, h, o)	\
  ((void) t, (*(volatile u_int32_t *)((h) + (o
 
-#if 0	/* Cause a link error for bus_space_read_8 */
-#define	bus_space_read_8(t, h, o)	!!! bus_space_read_8 unimplemented !!!
-#endif
-
 /*
  *	void bus_space_read_multi_N(bus_space_tag_t tag,
  *	bus_space_handle_t bsh, bus_size_t offset,
@@ -178,10 +174,6 @@ __EMIPS_bus_space_read_multi(1,8)
 __EMIPS_bus_space_read_multi(2,16)
 __EMIPS_bus_space_read_multi(4,32)
 
-#if 0	/* Cause a link error for bus_space_read_multi_8 */
-#define	bus_space_read_multi_8	!!! bus_space_read_multi_8 unimplemented !!!
-#endif
-
 #undef __EMIPS_bus_space_read_multi
 
 /*
@@ -218,10 +210,6 @@ __EMIPS_bus_space_read_region(1,8)
 __EMIPS_bus_space_read_region(2,16)
 __EMIPS_bus_space_read_region(4,32)
 
-#if 0	/* Cause a link error for bus_space_read_region_8 */
-#define	bus_space_read_region_8	!!! bus_space_read_region_8 unimplemented !!!
-#endif
-
 #undef __EMIPS_bus_space_read_region
 
 /*
@@ -254,10 +242,6 @@ do {	\
 	wbflush();	/* XXX */	\
 } while (0)
 
-#if 0	/* Cause a link error for bus_space_write_8 */
-#define	bus_space_write_8	!!! bus_space_write_8 not implemented !!!
-#endif
-
 /*
  *	void bus_space_write_multi_N(bus_space_tag_t tag,
  *	bus_space_handle_t bsh, bus_size_t offset,
@@ -289,11 +273,6 @@ __EMIPS_bus_space_write_multi(1,8)
 __EMIPS_bus_space_write_multi(2,16)
 __EMIPS_bus_space_write_multi(4,32)
 
-#if 0	/* Cause a link error for bus_space_write_8 */
-#define	bus_space_write_multi_8(t, h, o, a, c)\
-			!!! bus_space_write_multi_8 unimplemented !!!
-#endif
-
 #undef __EMIPS_bus_space_write_multi
 
 /*
@@ -329,11 +308,6 @@ __EMIPS_bus_space_write_region(1,8)
 __EMIPS_bus_space_write_region(2,16)
 __EMIPS_bus_space_write_region(4,32)
 
-#if 0	/* Cause a link error for bus_space_write_region_8 */
-#define	bus_space_write_region_8	\
-			!!! bus_space_write_region_8 unimplemented !!!
-#endif
-
 #undef __EMIPS_bus_space_write_region
 
 /*
@@ -367,11 +341,6 @@ __EMIPS_bus_space_set_multi(1,8)
 __EMIPS_bus_space_set_multi(2,16)
 __EMIPS_bus_space_set_multi(4,32)
 
-#if 0	/* Cause a link error for bus_space_set_multi_8 */
-#define	bus_space_set_multi_8		\
-			!!! bus_space_set_multi_8 unimplemented !!!
-#endif
-
 #undef __EMIPS_bus_space_set_multi
 
 /*
@@ -407,11 +376,6 @@ __EMIPS_bus_space_set_region(1,8)
 __EMIPS_bus_space_set_region(2,16)
 __EMIPS_bus_space_set_region(4,32)
 
-#if 0	/* Cause a link error for bus_space_set_region_8 */
-#define	bus_space_set_region_8		\
-			!!! bus_space_set_region_8 unimplemented !!!
-#endif
-
 #undef __EMIPS_bus_space_set_region
 
 /*
@@ -459,11 +423,6 @@ __EMIPS_copy_region(1)
 __EMIPS_copy_region(2)
 __EMIPS_copy_region(4)
 
-#if 0	/* Cause a link error for bus_space_copy_region_8 */
-#define	bus_space_copy_region_8		\
-			!!! bus_space_copy_region_8 unimplemented !!!
-#endif
-
 #undef 

CVS commit: src/tests/usr.bin/xlint/lint1

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 19:03:55 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_bool_strict_syshdr.c
d_c99_bool_strict_syshdr.exp

Log Message:
lint: extend test for strict bool mode and system headers


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.2 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.3
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c:1.2	Sun Jan 17 23:04:09 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c	Sat Jan 23 19:03:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.2 2021/01/17 23:04:09 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict_syshdr.c,v 1.3 2021/01/23 19:03:55 rillig Exp $	*/
 # 3 "d_c99_bool_strict_syshdr.c"
 
 /*
@@ -10,10 +10,18 @@
 
 /* lint1-extra-flags: -T */
 
+extern const unsigned short *ctype_table;
+
+extern void println(const char *);
+
 /*
  * On NetBSD 8,  defines FD_ISSET by enclosing the statements
- * in the well-known 'do { ... } while (constcond 0)' loop.  The 0 in the
- * controlling expression has type INT but should be allowed nevertheless.
+ * in the well-known 'do { ... } while (CONSTCOND 0)' loop.  The 0 in the
+ * controlling expression has type INT but should be allowed nevertheless
+ * since that header does not have a way to distinguish between bool and int.
+ * It just follows the C99 standard, unlike the lint-provided stdbool.h, which
+ * redefines 'false' to '__lint_false'.  Plus,  must not include
+ *  itself.
  */
 void
 strict_bool_system_header_statement_macro(void)
@@ -23,12 +31,12 @@ strict_bool_system_header_statement_macr
 		println("nothing");
 	} while (/*CONSTCOND*/0);	/* expect: 333 */
 
-# 27 "d_c99_bool_strict_syshdr.c" 3 4
+# 35 "d_c99_bool_strict_syshdr.c" 3 4
 	do {
 		println("nothing");
 	} while (/*CONSTCOND*/0);	/* ok */
 
-# 32 "d_c99_bool_strict_syshdr.c"
+# 40 "d_c99_bool_strict_syshdr.c"
 	do {
 		println("nothing");
 	} while (/*CONSTCOND*/0);	/* expect: 333 */
@@ -41,52 +49,74 @@ strict_bool_system_header_statement_macr
  * return type can be INT or BOOL, depending on whether the macros do the
  * comparison against 0 themselves.
  *
- * Since that is more code to write and in exceptional situations more code
- * to execute, they will probably leave out the extra comparison, but both
- * ways are possible.
+ * Since that comparison is more code to write and in exceptional situations
+ * more code to execute, they will probably leave out the extra comparison,
+ * but both ways are possible.
  *
- * In strict mode, there must be a way to call these function-like macros
+ * In strict bool mode, there must be a way to call these function-like macros
  * portably, without triggering type errors, no matter whether they return
  * BOOL or INT.
  *
  * The expressions from this example cross the boundary between system header
  * and application code.  They need to carry the information that they are
- * half-BOOL, half-INT across the enclosing expressions.
+ * half-BOOL, half-INT across to the enclosing expressions.
  */
 void
 strict_bool_system_header_ctype(int c)
 {
-	static const unsigned short *ctype_table;
-
-
 	/*
 	 * The macro returns INT, which may be outside the range of a
 	 * uint8_t variable, therefore it must not be assigned directly.
 	 * All other combinations of type are safe from truncation.
 	 */
 	_Bool system_int_assigned_to_bool =
-# 69 "d_c99_bool_strict_syshdr.c" 3 4
+# 74 "d_c99_bool_strict_syshdr.c" 3 4
 	(int)((ctype_table + 1)[c] & 0x0040)	/* INT */
-# 71 "d_c99_bool_strict_syshdr.c"
-	;			/* expect: 107 */
+# 76 "d_c99_bool_strict_syshdr.c"
+	;			/* expect: 107 */
 
 	int system_bool_assigned_to_int =
-# 75 "d_c99_bool_strict_syshdr.c" 3 4
+# 80 "d_c99_bool_strict_syshdr.c" 3 4
 	(int)((ctype_table + 1)[c] & 0x0040) != 0	/* BOOL */
-# 77 "d_c99_bool_strict_syshdr.c"
-	;			/* expect: 107 */
+# 82 "d_c99_bool_strict_syshdr.c"
+	;			/* expect: 107 */
 
 	if (
-# 81 "d_c99_bool_strict_syshdr.c" 3 4
+# 86 "d_c99_bool_strict_syshdr.c" 3 4
 	(int)((ctype_table + 1)[c] & 0x0040)	/* INT */
-# 83 "d_c99_bool_strict_syshdr.c"
+# 88 "d_c99_bool_strict_syshdr.c"
 	)			/*FIXME*//* expect: 333 */
-	println("system macro returning INT");
+		println("system macro returning INT");
 
 	if (
-# 88 "d_c99_bool_strict_syshdr.c" 3 4
+# 93 "d_c99_bool_strict_syshdr.c" 3 4
 	((ctype_table + 1)[c] & 0x0040) != 0	/* BOOL */
-# 90 "d_c99_bool_strict_syshdr.c"
+# 95 "d_c99_bool_strict_syshdr.c"
 	)
-	println("system macro returning BOOL");
+		println("system macro 

CVS commit: src/usr.bin/xlint/lint1

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 18:30:29 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: lex.c

Log Message:
lint: clean up comments and variable names in lex.c


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/xlint/lint1/lex.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/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.1 src/usr.bin/xlint/lint1/lex.c:1.2
--- src/usr.bin/xlint/lint1/lex.c:1.1	Sat Jan 23 17:58:03 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sat Jan 23 18:30:29 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.1 2021/01/23 17:58:03 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.2 2021/01/23 18:30:29 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -34,7 +34,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.1 2021/01/23 17:58:03 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.2 2021/01/23 18:30:29 rillig Exp $");
 #endif
 
 #include 
@@ -885,14 +885,14 @@ lex_wccon(void)
  * Read a character which is part of a character constant or of a string
  * and handle escapes.
  *
- * The Argument is the character which delimits the character constant or
+ * The argument is the character which delimits the character constant or
  * string.
  *
  * Returns -1 if the end of the character constant or string is reached,
  * -2 if the EOF is reached, and the character otherwise.
  */
 static int
-getescc(int d)
+getescc(int delim)
 {
 	static	int pbc = -1;
 	int	n, c, v;
@@ -903,7 +903,7 @@ getescc(int d)
 		c = pbc;
 		pbc = -1;
 	}
-	if (c == d)
+	if (c == delim)
 		return -1;
 	switch (c) {
 	case '\n':
@@ -918,7 +918,7 @@ getescc(int d)
 	case '\\':
 		switch (c = inpc()) {
 		case '"':
-			if (tflag && d == '\'')
+			if (tflag && delim == '\'')
 /* \" inside character constants undef... */
 warning(262);
 			return '"';
@@ -1002,7 +1002,7 @@ getescc(int d)
 			}
 			return v;
 		case '\n':
-			return getescc(d);
+			return getescc(delim);
 		case EOF:
 			return -2;
 		default:
@@ -1045,6 +1045,7 @@ parse_line_directive_flags(const char *p
  * Called for preprocessor directives. Currently implemented are:
  *	# lineno
  *	# lineno "filename"
+ *	# lineno "filename" GCC-flag...
  */
 void
 lex_directive(const char *yytext)
@@ -1113,19 +1114,8 @@ lex_directive(const char *yytext)
 }
 
 /*
- * Handle lint comments. Following comments are currently understood:
- *	ARGSUSEDn
- *	BITFIELDTYPE
- *	CONSTCOND CONSTANTCOND CONSTANTCONDITION
- *	FALLTHRU FALLTHROUGH
- *	LINTLIBRARY
- *	LINTEDn NOSTRICTn
- *	LONGLONG
- *	NOTREACHED
- *	PRINTFLIKEn
- *	PROTOLIB
- *	SCANFLIKEn
- *	VARARGSn
+ * Handle lint comments such as ARGSUSED.
+ *
  * If one of these comments is recognized, the argument, if any, is
  * parsed and a function which handles this comment is called.
  */
@@ -1367,7 +1357,7 @@ lex_wcstrg(void)
  * declared due to syntax errors. To avoid too many problems in this
  * case, symbols get type int in getsym().
  *
- * XXX calls to getsym() should be delayed until decl1*() is called
+ * XXX calls to getsym() should be delayed until decl1*() is called.
  */
 sym_t *
 getsym(sbuf_t *sb)
@@ -1504,7 +1494,7 @@ rmsyms(sym_t *syms)
 }
 
 /*
- * Put a symbol into the symbol table
+ * Put a symbol into the symbol table.
  */
 void
 inssym(int bl, sym_t *sym)
@@ -1522,7 +1512,8 @@ inssym(int bl, sym_t *sym)
 }
 
 /*
- * Called at level 0 after syntax errors
+ * Called at level 0 after syntax errors.
+ *
  * Removes all symbols which are not declared at level 0 from the
  * symbol table. Also frees all memory which is not associated with
  * level 0.



CVS commit: src/usr.bin/xlint/lint1

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 17:58:03 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: Makefile externs1.h scan.l
Added Files:
src/usr.bin/xlint/lint1: lex.c

Log Message:
lint: move lexer code from scan.l to lex.c

Previously, the generated scan.c was not included when running "make
lint".  Similarly, cgram.c is still not included.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.59 -r1.60 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r0 -r1.1 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.129 -r1.130 src/usr.bin/xlint/lint1/scan.l

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/xlint/lint1/Makefile
diff -u src/usr.bin/xlint/lint1/Makefile:1.58 src/usr.bin/xlint/lint1/Makefile:1.59
--- src/usr.bin/xlint/lint1/Makefile:1.58	Sun Jan 10 12:05:07 2021
+++ src/usr.bin/xlint/lint1/Makefile	Sat Jan 23 17:58:03 2021
@@ -1,9 +1,10 @@
-#	$NetBSD: Makefile,v 1.58 2021/01/10 12:05:07 rillig Exp $
+#	$NetBSD: Makefile,v 1.59 2021/01/23 17:58:03 rillig Exp $
 
 .include 
 
 PROG=		lint1
 SRCS=		cgram.y decl.c emit.c emit1.c err.c func.c init.c inittyp.c \
+		lex.c \
 		main1.c mem.c mem1.c oper.c print.c scan.l tree.c tyname.c
 
 MAN=		lint.7

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.59 src/usr.bin/xlint/lint1/externs1.h:1.60
--- src/usr.bin/xlint/lint1/externs1.h:1.59	Mon Jan 18 16:41:57 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sat Jan 23 17:58:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.59 2021/01/18 16:41:57 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.60 2021/01/23 17:58:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -308,6 +308,24 @@ extern	void	outcall(const tnode_t *, boo
 extern	void	outusg(const sym_t *);
 
 /*
+ * lex.c
+ */
+extern	int	lex_name(const char *, size_t);
+extern	int	lex_icon(const char *, size_t, int);
+extern	int	lex_fcon(const char *, size_t);
+extern	int	lex_operator(int, op_t);
+extern	int	lex_string(void);
+extern	int	lex_wcstrg(void);
+extern	int	lex_ccon(void);
+extern	int	lex_wccon(void);
+extern	void	lex_directive(const char *);
+extern	void	lex_incline(void);
+extern	void	lex_comment(void);
+extern	void	lex_slashslashcomment(void);
+extern	void	lex_badchar(int);
+extern	int	lex_input(void);
+
+/*
  * print.c
  */
 extern	char	*print_tnode(char *, size_t, const tnode_t *);

Index: src/usr.bin/xlint/lint1/scan.l
diff -u src/usr.bin/xlint/lint1/scan.l:1.129 src/usr.bin/xlint/lint1/scan.l:1.130
--- src/usr.bin/xlint/lint1/scan.l:1.129	Mon Jan 18 20:02:34 2021
+++ src/usr.bin/xlint/lint1/scan.l	Sat Jan 23 17:58:03 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.129 2021/01/18 20:02:34 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.130 2021/01/23 17:58:03 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,57 +35,12 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.129 2021/01/18 20:02:34 rillig Exp $");
+__RCSID("$NetBSD: scan.l,v 1.130 2021/01/23 17:58:03 rillig Exp $");
 #endif
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
 #include "lint1.h"
 #include "cgram.h"
 
-#define CHAR_MASK	((int)(~(~0U << CHAR_SIZE)))
-
-/* Current position (it's also updated when an included file is parsed) */
-pos_t	curr_pos = { 1, "", 0 };
-
-/*
- * Current position in C source (not updated when an included file is
- * parsed).
- */
-pos_t	csrc_pos = { 1, "", 0 };
-
-/* Are we parsing a gcc attribute? */
-bool attron;
-
-bool in_system_header = false;
-
-static	void	incline(void);
-static	void	badchar(int);
-static	sbuf_t	*allocsb(void);
-static	void	freesb(sbuf_t *);
-static	int	inpc(void);
-static	int	hash(const char *);
-static	sym_t	*search(sbuf_t *);
-static	int	name(void);
-static	int	keyw(sym_t *);
-static	int	icon(int);
-static	int	fcon(void);
-static	int	operator(int, op_t);
-static	int	ccon(void);
-static	int	wccon(void);
-static	int	getescc(int);
-static	void	directive(void);
-static	void	comment(void);
-static	void	slashslashcomment(void);
-static	int	string(void);
-static	int	wcstrg(void);
-
 %}
 
 
@@ -103,53 +58,53 @@ TL	([fFlL]?[i]?)
 
 %%
 
-{L}({L}|{D})*			return name();
-0[bB]{BD}+[lLuU]*		return icon(2);
-0{OD}*[lLuU]*			return icon(8);
-{NZD}{D}*[lLuU]*		return icon(10);
-0[xX]{HD}+[lLuU]*		return icon(16);
+{L}({L}|{D})*			return lex_name(yytext, yyleng);
+0[bB]{BD}+[lLuU]*		return lex_icon(yytext, yyleng, 2);
+0{OD}*[lLuU]*			return lex_icon(yytext, yyleng, 8);
+{NZD}{D}*[lLuU]*		return lex_icon(yytext, yyleng, 10);
+0[xX]{HD}+[lLuU]*		return lex_icon(yytext, yyleng, 16);
 {D}+\.{D}*{EX}?{TL}		|
 {D}+{EX}{TL}			|
 0[xX]{HD}+\.{HD}*{HX}{TL}	|
 0[xX]{HD}+{HX}{TL}		|
-\.{D}+{EX}?{TL}			return fcon();
-"="return operator(T_ASSIGN, NOOP);
-"*="return operator(T_OPASSIGN, 

CVS commit: src/sys/kern

2021-01-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jan 23 16:33:49 UTC 2021

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

Log Message:
threadpool(9): Fix synchronization between cancel and dispatch.

- threadpool_cancel_job_async tried to prevent
  threadpool_dispatcher_thread from taking the job by setting
  job->job_thread = NULL and then removing the job from the queue.

- But threadpool_cancel_job_async didn't notice job->job_thread is
  null until after it also removes the job from the queue =>
  double-remove, *boom*.

The solution is to teach threadpool_dispatcher_thread to wait until
it has acquired the job lock to test whether job->job_thread is still
valid before it decides to remove the job from the queue.

Fixes PR kern/55948.

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/kern/kern_threadpool.c

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

Modified files:

Index: src/sys/kern/kern_threadpool.c
diff -u src/sys/kern/kern_threadpool.c:1.22 src/sys/kern/kern_threadpool.c:1.23
--- src/sys/kern/kern_threadpool.c:1.22	Wed Jan 13 07:34:37 2021
+++ src/sys/kern/kern_threadpool.c	Sat Jan 23 16:33:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_threadpool.c,v 1.22 2021/01/13 07:34:37 skrll Exp $	*/
+/*	$NetBSD: kern_threadpool.c,v 1.23 2021/01/23 16:33:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014, 2018 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_threadpool.c,v 1.22 2021/01/13 07:34:37 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_threadpool.c,v 1.23 2021/01/23 16:33:49 riastradh Exp $");
 
 #include 
 #include 
@@ -1041,7 +1041,7 @@ threadpool_dispatcher_thread(void *arg)
 
 		/* There are idle threads, so try giving one a job.  */
 		struct threadpool_job *const job = TAILQ_FIRST(>tp_jobs);
-		TAILQ_REMOVE(>tp_jobs, job, job_entry);
+
 		/*
 		 * Take an extra reference on the job temporarily so that
 		 * it won't disappear on us while we have both locks dropped.
@@ -1053,6 +1053,7 @@ threadpool_dispatcher_thread(void *arg)
 		/* If the job was cancelled, we'll no longer be its thread.  */
 		if (__predict_true(job->job_thread == dispatcher)) {
 			mutex_spin_enter(>tp_lock);
+			TAILQ_REMOVE(>tp_jobs, job, job_entry);
 			if (__predict_false(
 TAILQ_EMPTY(>tp_idle_threads))) {
 /*



CVS commit: src/sys/arch/news68k/news68k

2021-01-23 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Jan 23 15:00:33 UTC 2021

Modified Files:
src/sys/arch/news68k/news68k: locore.s

Log Message:
Remove leftover of #undef statements.

These should have been removed in rev 1.55 back in 2010:
 https://mail-index.netbsd.org/source-changes/2010/12/20/msg016105.html
 
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/news68k/news68k/locore.s.diff?r1=1.54=1.55


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/news68k/news68k/locore.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/news68k/news68k/locore.s
diff -u src/sys/arch/news68k/news68k/locore.s:1.66 src/sys/arch/news68k/news68k/locore.s:1.67
--- src/sys/arch/news68k/news68k/locore.s:1.66	Wed Dec 19 13:57:49 2018
+++ src/sys/arch/news68k/news68k/locore.s	Sat Jan 23 15:00:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.66 2018/12/19 13:57:49 maxv Exp $	*/
+/*	$NetBSD: locore.s,v 1.67 2021/01/23 15:00:33 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -808,9 +808,6 @@ ENTRY_NOPROFILE(intrhand_vectored)
 	subql	#1,_C_LABEL(idepth)
 	rte
 
-#undef INTERRUPT_SAVEREG
-#undef INTERRUPT_RESTOREREG
-
 /*
  * Emulation of VAX REI instruction.
  *



CVS commit: xsrc/external/mit/libXxf86dga/dist/src

2021-01-23 Thread Izumi Tsutsui
Module Name:xsrc
Committed By:   tsutsui
Date:   Sat Jan 23 14:41:04 UTC 2021

Modified Files:
xsrc/external/mit/libXxf86dga/dist/src: XF86DGA.c

Log Message:
Fix "no output of xdpyinfo(1) on redirect or pipe" problem.

XF86cleanup() in libXxf86dga invoked via atexit(3)
(or __attribute__((__destructor__)) in NetBSD xsrc)
calls _exit(2) directly so fflush(3) via normal exit(3)
is not called.  Analyzed by rin@, ryo@, and soda@:
 https://mail-index.netbsd.org/tech-x11/2021/01/20/msg002192.html

Should be pulled up to netbsd-9.

XXX1: The original XF86cleanup() is not async-signale-safe.
XXX2: XF86DGAGetVideo() implicitly overrides signal handlers.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/libXxf86dga/dist/src/XF86DGA.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/libXxf86dga/dist/src/XF86DGA.c
diff -u xsrc/external/mit/libXxf86dga/dist/src/XF86DGA.c:1.2 xsrc/external/mit/libXxf86dga/dist/src/XF86DGA.c:1.3
--- xsrc/external/mit/libXxf86dga/dist/src/XF86DGA.c:1.2	Fri Jan  4 18:59:45 2019
+++ xsrc/external/mit/libXxf86dga/dist/src/XF86DGA.c	Sat Jan 23 14:41:04 2021
@@ -650,14 +650,14 @@ static void
 #ifdef __NetBSD__
 __attribute__ ((__destructor__))
 #endif
-XF86cleanup(int sig)
+XF86cleanup_atexit(void)
 {
 ScrPtr sp;
 int i;
 static char beenhere = 0;
 
 if (beenhere)
-	_exit(3);
+	return;
 beenhere = 1;
 
 for (i = 0; i < numScrs; i++) {
@@ -665,6 +665,14 @@ XF86cleanup(int sig)
 	XF86DGADirectVideo(sp->display, sp->screen, 0);
 	XSync(sp->display, False);
 }
+}
+
+static void
+XF86cleanup(int sig)
+{
+/* XXX FIXME XF86cleanup_atexit() is not async-signal-safe */
+XF86cleanup_atexit();
+
 _exit(3);
 }
 
@@ -707,7 +715,7 @@ XF86DGAGetVideo(
 if (!beenHere) {
 	beenHere = 1;
 #ifndef __NetBSD__
-	atexit((void(*)(void))XF86cleanup);
+	atexit((void(*)(void))XF86cleanup_atexit);
 #endif
 	/* one shot XF86cleanup attempts */
 	signal(SIGSEGV, XF86cleanup);



CVS commit: [netbsd-9] src/doc

2021-01-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jan 23 13:02:00 UTC 2021

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

Log Message:
Ticket #1186


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.35 -r1.1.2.36 src/doc/CHANGES-9.2

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.2
diff -u src/doc/CHANGES-9.2:1.1.2.35 src/doc/CHANGES-9.2:1.1.2.36
--- src/doc/CHANGES-9.2:1.1.2.35	Fri Jan 15 17:47:48 2021
+++ src/doc/CHANGES-9.2	Sat Jan 23 13:01:59 2021
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.2,v 1.1.2.35 2021/01/15 17:47:48 martin Exp $
+# $NetBSD: CHANGES-9.2,v 1.1.2.36 2021/01/23 13:01:59 martin Exp $
 
 A complete list of changes from the NetBSD 9.1 release to the NetBSD 9.2
 release:
@@ -1411,3 +1411,8 @@ share/man/man9/pci_msi.9			1.18
 	PR 55920: add documentation for pci_msi_count() and pci_msix_count().
 	[knakahara, ticket #1185]
 
+sys/dev/pci/if_ena.c1.27
+
+	PR 55942: destroyed ena(4) evcnts cause panic.
+	[jmcneill, ticket #1186]
+



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

2021-01-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jan 23 13:01:10 UTC 2021

Modified Files:
src/sys/dev/pci [netbsd-9]: if_ena.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #1186):

sys/dev/pci/if_ena.c: revision 1.27

PR kern/55942: destroyed ena(4) evcnts cause panic

Fix event counter teardown code. From KUSABA Takeshi


To generate a diff of this commit:
cvs rdiff -u -r1.15.2.3 -r1.15.2.4 src/sys/dev/pci/if_ena.c

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

Modified files:

Index: src/sys/dev/pci/if_ena.c
diff -u src/sys/dev/pci/if_ena.c:1.15.2.3 src/sys/dev/pci/if_ena.c:1.15.2.4
--- src/sys/dev/pci/if_ena.c:1.15.2.3	Wed Aug  5 14:59:41 2020
+++ src/sys/dev/pci/if_ena.c	Sat Jan 23 13:01:10 2021
@@ -36,7 +36,7 @@
 #if 0
 __FBSDID("$FreeBSD: head/sys/dev/ena/ena.c 333456 2018-05-10 09:37:54Z mw $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.15.2.3 2020/08/05 14:59:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.15.2.4 2021/01/23 13:01:10 martin Exp $");
 
 #include 
 #include 
@@ -470,18 +470,20 @@ ena_alloc_counters_hwstats(struct ena_hw
 	+ sizeof(st->rx_drops) == sizeof(*st));
 }
 static inline void
-ena_free_counters(struct evcnt *begin, int size)
+ena_free_counters(struct evcnt *begin, int size, int offset)
 {
 	struct evcnt *end = (struct evcnt *)((char *)begin + size);
+	begin = (struct evcnt *)((char *)begin + offset);
 
 	for (; begin < end; ++begin)
 		counter_u64_free(*begin);
 }
 
 static inline void
-ena_reset_counters(struct evcnt *begin, int size)
+ena_reset_counters(struct evcnt *begin, int size, int offset)
 {
 	struct evcnt *end = (struct evcnt *)((char *)begin + size);
+	begin = (struct evcnt *)((char *)begin + offset);
 
 	for (; begin < end; ++begin)
 		counter_u64_zero(*begin);
@@ -566,9 +568,9 @@ ena_free_io_ring_resources(struct ena_ad
 	struct ena_ring *rxr = >rx_ring[qid];
 
 	ena_free_counters((struct evcnt *)>tx_stats,
-	sizeof(txr->tx_stats));
+	sizeof(txr->tx_stats), offsetof(struct ena_stats_tx, cnt));
 	ena_free_counters((struct evcnt *)>rx_stats,
-	sizeof(rxr->rx_stats));
+	sizeof(rxr->rx_stats), offsetof(struct ena_stats_rx, cnt));
 
 	ENA_RING_MTX_LOCK(txr);
 	drbr_free(txr->br, M_DEVBUF);
@@ -670,7 +672,8 @@ ena_setup_tx_resources(struct ena_adapte
 
 	/* Reset TX statistics. */
 	ena_reset_counters((struct evcnt *)_ring->tx_stats,
-	sizeof(tx_ring->tx_stats));
+	sizeof(tx_ring->tx_stats),
+	offsetof(struct ena_stats_tx, cnt));
 
 	tx_ring->next_to_use = 0;
 	tx_ring->next_to_clean = 0;
@@ -867,7 +870,8 @@ ena_setup_rx_resources(struct ena_adapte
 
 	/* Reset RX statistics. */
 	ena_reset_counters((struct evcnt *)_ring->rx_stats,
-	sizeof(rx_ring->rx_stats));
+	sizeof(rx_ring->rx_stats),
+	offsetof(struct ena_stats_rx, cnt));
 
 	rx_ring->next_to_clean = 0;
 	rx_ring->next_to_use = 0;
@@ -2210,7 +2214,8 @@ ena_up_complete(struct ena_adapter *adap
 
 	ena_refill_all_rx_bufs(adapter);
 	ena_reset_counters((struct evcnt *)>hw_stats,
-	sizeof(adapter->hw_stats));
+	sizeof(adapter->hw_stats),
+	offsetof(struct ena_hw_stats, rx_packets));
 
 	return (0);
 }
@@ -3905,9 +3910,11 @@ ena_detach(device_t pdev, int flags)
 	ena_free_all_io_rings_resources(adapter);
 
 	ena_free_counters((struct evcnt *)>hw_stats,
-	sizeof(struct ena_hw_stats));
+	sizeof(struct ena_hw_stats),
+	offsetof(struct ena_hw_stats, rx_packets));
 	ena_free_counters((struct evcnt *)>dev_stats,
-	sizeof(struct ena_stats_dev));
+	sizeof(struct ena_stats_dev),
+offsetof(struct ena_stats_dev, wd_expired));
 
 	if (likely(adapter->rss_support))
 		ena_com_rss_destroy(ena_dev);



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

2021-01-23 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Jan 23 12:53:46 UTC 2021

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_vcaudio.c

Log Message:
vcaudio: don't advertise CAPTURE when all functions return EINVAL


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/broadcom/bcm2835_vcaudio.c

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

Modified files:

Index: src/sys/arch/arm/broadcom/bcm2835_vcaudio.c
diff -u src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.15 src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.16
--- src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.15	Wed Jan 22 21:21:24 2020
+++ src/sys/arch/arm/broadcom/bcm2835_vcaudio.c	Sat Jan 23 12:53:46 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_vcaudio.c,v 1.15 2020/01/22 21:21:24 mlelstv Exp $ */
+/* $NetBSD: bcm2835_vcaudio.c,v 1.16 2021/01/23 12:53:46 nia Exp $ */
 
 /*-
  * Copyright (c) 2013 Jared D. McNeill 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_vcaudio.c,v 1.15 2020/01/22 21:21:24 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_vcaudio.c,v 1.16 2021/01/23 12:53:46 nia Exp $");
 
 #include 
 #include 
@@ -159,7 +159,6 @@ static int	vcaudio_set_format(void *, in
 const audio_params_t *, const audio_params_t *,
 audio_filter_reg_t *, audio_filter_reg_t *);
 static int	vcaudio_halt_output(void *);
-static int	vcaudio_halt_input(void *);
 static int	vcaudio_set_port(void *, mixer_ctrl_t *);
 static int	vcaudio_get_port(void *, mixer_ctrl_t *);
 static int	vcaudio_query_devinfo(void *, mixer_devinfo_t *);
@@ -171,8 +170,6 @@ static int	vcaudio_round_blocksize(void 
 
 static int	vcaudio_trigger_output(void *, void *, void *, int,
 void (*)(void *), void *, const audio_params_t *);
-static int	vcaudio_trigger_input(void *, void *, void *, int,
-void (*)(void *), void *, const audio_params_t *);
 
 static void	vcaudio_get_locks(void *, kmutex_t **, kmutex_t **);
 
@@ -182,7 +179,6 @@ static const struct audio_hw_if vcaudio_
 	.query_format = vcaudio_query_format,
 	.set_format = vcaudio_set_format,
 	.halt_output = vcaudio_halt_output,
-	.halt_input = vcaudio_halt_input,
 	.getdev = vcaudio_getdev,
 	.set_port = vcaudio_set_port,
 	.get_port = vcaudio_get_port,
@@ -190,7 +186,6 @@ static const struct audio_hw_if vcaudio_
 	.get_props = vcaudio_get_props,
 	.round_blocksize = vcaudio_round_blocksize,
 	.trigger_output = vcaudio_trigger_output,
-	.trigger_input = vcaudio_trigger_input,
 	.get_locks = vcaudio_get_locks,
 };
 
@@ -612,12 +607,6 @@ vcaudio_halt_output(void *priv)
 }
 
 static int
-vcaudio_halt_input(void *priv)
-{
-	return EINVAL;
-}
-
-static int
 vcaudio_set_volume(struct vcaudio_softc *sc, enum vcaudio_dest dest,
 int hwvol)
 {
@@ -802,7 +791,7 @@ vcaudio_getdev(void *priv, struct audio_
 static int
 vcaudio_get_props(void *priv)
 {
-	return AUDIO_PROP_PLAYBACK|AUDIO_PROP_CAPTURE|AUDIO_PROP_INDEPENDENT;
+	return AUDIO_PROP_PLAYBACK;
 }
 
 static int
@@ -837,13 +826,6 @@ vcaudio_trigger_output(void *priv, void 
 	return 0;
 }
 
-static int
-vcaudio_trigger_input(void *priv, void *start, void *end, int blksize,
-void (*intr)(void *), void *intrarg, const audio_params_t *params)
-{
-	return EINVAL;
-}
-
 static void
 vcaudio_get_locks(void *priv, kmutex_t **intr, kmutex_t **thread)
 {



CVS commit: src/usr.bin/make

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 12:36:02 UTC 2021

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

Log Message:
make(1): split Dir_FindFile into separate functions


To generate a diff of this commit:
cvs rdiff -u -r1.262 -r1.263 src/usr.bin/make/dir.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/dir.c
diff -u src/usr.bin/make/dir.c:1.262 src/usr.bin/make/dir.c:1.263
--- src/usr.bin/make/dir.c:1.262	Sat Jan 23 12:25:35 2021
+++ src/usr.bin/make/dir.c	Sat Jan 23 12:36:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.262 2021/01/23 12:25:35 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.263 2021/01/23 12:36:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -138,7 +138,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.262 2021/01/23 12:25:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.263 2021/01/23 12:36:02 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -1064,6 +1064,115 @@ DirFindDot(const char *name, const char 
 	return NULL;
 }
 
+static Boolean
+FindFileRelative(SearchPath *path, Boolean seenDotLast,
+		 const char *name, char **out_file)
+{
+	SearchPathNode *ln;
+	Boolean checkedDot = FALSE;
+	char *file;
+
+	DEBUG0(DIR, "   Trying subdirectories...\n");
+
+	if (!seenDotLast) {
+		if (dot != NULL) {
+			checkedDot = TRUE;
+			if ((file = DirLookupSubdir(dot, name)) != NULL)
+goto found;
+		}
+		if (cur != NULL &&
+		(file = DirLookupSubdir(cur, name)) != NULL)
+			goto found;
+	}
+
+	for (ln = path->first; ln != NULL; ln = ln->next) {
+		CachedDir *dir = ln->datum;
+		if (dir == dotLast)
+			continue;
+		if (dir == dot) {
+			if (checkedDot)
+continue;
+			checkedDot = TRUE;
+		}
+		if ((file = DirLookupSubdir(dir, name)) != NULL)
+			goto found;
+	}
+
+	if (seenDotLast) {
+		if (dot != NULL && !checkedDot) {
+			checkedDot = TRUE;
+			if ((file = DirLookupSubdir(dot, name)) != NULL)
+goto found;
+		}
+		if (cur != NULL &&
+		(file = DirLookupSubdir(cur, name)) != NULL)
+			goto found;
+	}
+
+	if (checkedDot) {
+		/*
+		 * Already checked by the given name, since . was in
+		 * the path, so no point in proceeding.
+		 */
+		DEBUG0(DIR, "   Checked . already, returning NULL\n");
+		file = NULL;
+		goto found;
+	}
+
+	return FALSE;
+
+found:
+	*out_file = file;
+	return TRUE;
+}
+
+static Boolean
+FindFileAbsolute(SearchPath *path, Boolean const seenDotLast,
+		 const char *const name, const char *const base,
+		 char **out_file)
+{
+	char *file;
+	SearchPathNode *ln;
+
+	/*
+	 * For absolute names, compare directory path prefix against
+	 * the the directory path of each member on the search path
+	 * for an exact match. If we have an exact match on any member
+	 * of the search path, use the cached contents of that member
+	 * to lookup the final file component. If that lookup fails we
+	 * can safely assume that the file does not exist at all.
+	 * This is signified by DirLookupAbs() returning an empty
+	 * string.
+	 */
+	DEBUG0(DIR, "   Trying exact path matches...\n");
+
+	if (!seenDotLast && cur != NULL &&
+	((file = DirLookupAbs(cur, name, base)) != NULL))
+		goto found;
+
+	for (ln = path->first; ln != NULL; ln = ln->next) {
+		CachedDir *dir = ln->datum;
+		if (dir == dotLast)
+			continue;
+		if ((file = DirLookupAbs(dir, name, base)) != NULL)
+			goto found;
+	}
+
+	if (seenDotLast && cur != NULL &&
+	((file = DirLookupAbs(cur, name, base)) != NULL))
+		goto found;
+
+	return FALSE;
+
+found:
+	if (file[0] == '\0') {
+		free(file);
+		file = NULL;
+	}
+	*out_file = file;
+	return TRUE;
+}
+
 /*
  * Find the file with the given name along the given search path.
  *
@@ -1170,100 +1279,11 @@ Dir_FindFile(const char *name, SearchPat
 	}
 
 	if (name[0] != '/') {
-		SearchPathNode *ln;
-		Boolean checkedDot = FALSE;
-
-		DEBUG0(DIR, "   Trying subdirectories...\n");
-
-		if (!seenDotLast) {
-			if (dot != NULL) {
-checkedDot = TRUE;
-if ((file = DirLookupSubdir(dot, name)) != NULL)
-	return file;
-			}
-			if (cur != NULL &&
-			(file = DirLookupSubdir(cur, name)) != NULL)
-return file;
-		}
-
-		for (ln = path->first; ln != NULL; ln = ln->next) {
-			CachedDir *dir = ln->datum;
-			if (dir == dotLast)
-continue;
-			if (dir == dot) {
-if (checkedDot)
-	continue;
-checkedDot = TRUE;
-			}
-			if ((file = DirLookupSubdir(dir, name)) != NULL)
-return file;
-		}
-
-		if (seenDotLast) {
-			if (dot != NULL && !checkedDot) {
-checkedDot = TRUE;
-if ((file = DirLookupSubdir(dot, name)) != NULL)
-	return file;
-			}
-			if (cur != NULL &&
-			(file = DirLookupSubdir(cur, name)) != NULL)
-return file;
-		}
-
-		if (checkedDot) {
-			/*
-			 * Already checked by the given name, since . was in
-			 * the path, so no 

CVS commit: src/usr.bin/make

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 12:35:22 UTC 2021

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

Log Message:
make(1): rename local variable in FindCmds


To generate a diff of this commit:
cvs rdiff -u -r1.338 -r1.339 src/usr.bin/make/suff.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/suff.c
diff -u src/usr.bin/make/suff.c:1.338 src/usr.bin/make/suff.c:1.339
--- src/usr.bin/make/suff.c:1.338	Sat Jan 23 12:25:35 2021
+++ src/usr.bin/make/suff.c	Sat Jan 23 12:35:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.338 2021/01/23 12:25:35 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.339 2021/01/23 12:35:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.338 2021/01/23 12:25:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.339 2021/01/23 12:35:22 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -1183,7 +1183,7 @@ FindCmds(Candidate *targ, CandidateSearc
 	prefLen = strlen(targ->prefix);
 
 	for (gln = tgn->children.first; gln != NULL; gln = gln->next) {
-		const char *cp;
+		const char *base;
 
 		sgn = gln->datum;
 
@@ -1198,11 +1198,11 @@ FindCmds(Candidate *targ, CandidateSearc
 			continue;
 		}
 
-		cp = str_basename(sgn->name);
-		if (strncmp(cp, targ->prefix, prefLen) != 0)
+		base = str_basename(sgn->name);
+		if (strncmp(base, targ->prefix, prefLen) != 0)
 			continue;
 		/* The node matches the prefix, see if it has a known suffix. */
-		suff = FindSuffixByName(cp + prefLen);
+		suff = FindSuffixByName(base + prefLen);
 		if (suff == NULL)
 			continue;
 



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

2021-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jan 23 12:34:19 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: cpu_acpi.c

Log Message:
fit in 80 columns


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/acpi/cpu_acpi.c

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

Modified files:

Index: src/sys/arch/arm/acpi/cpu_acpi.c
diff -u src/sys/arch/arm/acpi/cpu_acpi.c:1.9 src/sys/arch/arm/acpi/cpu_acpi.c:1.10
--- src/sys/arch/arm/acpi/cpu_acpi.c:1.9	Thu Dec  3 07:45:51 2020
+++ src/sys/arch/arm/acpi/cpu_acpi.c	Sat Jan 23 12:34:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_acpi.c,v 1.9 2020/12/03 07:45:51 skrll Exp $ */
+/* $NetBSD: cpu_acpi.c,v 1.10 2021/01/23 12:34:19 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.9 2020/12/03 07:45:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.10 2021/01/23 12:34:19 jmcneill Exp $");
 
 #include 
 #include 
@@ -104,7 +104,8 @@ cpu_acpi_attach(device_t parent, device_
 		int error;
 
 		cpu_mpidr[cpuindex] = mpidr;
-		cpu_dcache_wb_range((vaddr_t)_mpidr[cpuindex], sizeof(cpu_mpidr[cpuindex]));
+		cpu_dcache_wb_range((vaddr_t)_mpidr[cpuindex],
+		sizeof(cpu_mpidr[cpuindex]));
 
 		/* XXX support spin table */
 		error = psci_cpu_on(mpidr, cpu_acpi_mpstart_pa(), 0);
@@ -169,14 +170,16 @@ cpu_acpi_tprof_intr_establish(ACPI_SUBTA
 
 	const bool cpu_primary_p = cpu_mpidr_aff_read() == gicc->ArmMpidr;
 	const bool intr_ppi_p = gicc->PerformanceInterrupt < 32;
-	const int type = (gicc->Flags & ACPI_MADT_PERFORMANCE_IRQ_MODE) ? IST_EDGE : IST_LEVEL;
+	const int type = (gicc->Flags & ACPI_MADT_PERFORMANCE_IRQ_MODE) ?
+	IST_EDGE : IST_LEVEL;
 
 	if (intr_ppi_p && !cpu_primary_p)
 		return AE_OK;
 
 	ci = cpu_acpi_find_processor(gicc->Uid);
 	if (ci == NULL) {
-		aprint_error_dev(dev, "couldn't find processor %#x\n", gicc->Uid);
+		aprint_error_dev(dev, "couldn't find processor %#x\n",
+		gicc->Uid);
 		return AE_OK;
 	}
 
@@ -186,10 +189,11 @@ cpu_acpi_tprof_intr_establish(ACPI_SUBTA
 		snprintf(xname, sizeof(xname), "pmu %s", cpu_name(ci));
 	}
 
-	ih = intr_establish_xname(gicc->PerformanceInterrupt, IPL_HIGH, type | IST_MPSAFE,
-	armv8_pmu_intr, NULL, xname);
+	ih = intr_establish_xname(gicc->PerformanceInterrupt, IPL_HIGH,
+	type | IST_MPSAFE, armv8_pmu_intr, NULL, xname);
 	if (ih == NULL) {
-		aprint_error_dev(dev, "couldn't establish %s interrupt\n", xname);
+		aprint_error_dev(dev, "couldn't establish %s interrupt\n",
+		xname);
 		return AE_OK;
 	}
 
@@ -200,13 +204,15 @@ cpu_acpi_tprof_intr_establish(ACPI_SUBTA
 		kcpuset_destroy(set);
 
 		if (error) {
-			aprint_error_dev(dev, "failed to distribute %s interrupt: %d\n",
+			aprint_error_dev(dev,
+			"failed to distribute %s interrupt: %d\n",
 			xname, error);
 			return AE_OK;
 		}
 	}
 
-	aprint_normal("%s: PMU interrupting on irq %d\n", cpu_name(ci), gicc->PerformanceInterrupt);
+	aprint_normal("%s: PMU interrupting on irq %d\n", cpu_name(ci),
+	gicc->PerformanceInterrupt);
 
 	return AE_OK;
 }
@@ -217,7 +223,8 @@ cpu_acpi_tprof_init(device_t self)
 	armv8_pmu_init();
 
 	if (acpi_madt_map() != AE_OK) {
-		aprint_error_dev(self, "failed to map MADT, performance counters not available\n");
+		aprint_error_dev(self,
+		"failed to map MADT, performance counters not available\n");
 		return;
 	}
 	acpi_madt_walk(cpu_acpi_tprof_intr_establish, self);



CVS commit: src/usr.bin/make

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 12:25:35 UTC 2021

Modified Files:
src/usr.bin/make: dir.c suff.c

Log Message:
make(1): remove the remaining beasts from the comments


To generate a diff of this commit:
cvs rdiff -u -r1.261 -r1.262 src/usr.bin/make/dir.c
cvs rdiff -u -r1.337 -r1.338 src/usr.bin/make/suff.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/dir.c
diff -u src/usr.bin/make/dir.c:1.261 src/usr.bin/make/dir.c:1.262
--- src/usr.bin/make/dir.c:1.261	Sat Jan 23 11:44:10 2021
+++ src/usr.bin/make/dir.c	Sat Jan 23 12:25:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.261 2021/01/23 11:44:10 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.262 2021/01/23 12:25:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -138,7 +138,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.261 2021/01/23 11:44:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.262 2021/01/23 12:25:35 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -1118,7 +1118,7 @@ Dir_FindFile(const char *name, SearchPat
 		/*
 		 * We look through all the directories on the path seeking one
 		 * which contains the final component of the given name.  If
-		 * such a beast is found, we concatenate the directory name
+		 * such a file is found, we concatenate the directory name
 		 * and the final component and return the resulting string.
 		 * If we don't find any such thing, we go on to phase two.
 		 *
@@ -1152,7 +1152,7 @@ Dir_FindFile(const char *name, SearchPat
 	 * path. (eg. /usr/include and sys/types.h. The above search would
 	 * fail to turn up types.h in /usr/include, but it *is* in
 	 * /usr/include/sys/types.h).
-	 * [ This no longer applies: If we find such a beast, we assume there
+	 * [ This no longer applies: If we find such a file, we assume there
 	 * will be more (what else can we assume?) and add all but the last
 	 * component of the resulting name onto the search path (at the
 	 * end).]

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.337 src/usr.bin/make/suff.c:1.338
--- src/usr.bin/make/suff.c:1.337	Sat Jan 23 11:34:41 2021
+++ src/usr.bin/make/suff.c	Sat Jan 23 12:25:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.337 2021/01/23 11:34:41 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.338 2021/01/23 12:25:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.337 2021/01/23 11:34:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.338 2021/01/23 12:25:35 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -1176,7 +1176,7 @@ FindCmds(Candidate *targ, CandidateSearc
 	GNode *tgn;		/* Target GNode */
 	GNode *sgn;		/* Source GNode */
 	size_t prefLen;		/* The length of the defined prefix */
-	Suffix *suff;		/* Suffix on matching beastie */
+	Suffix *suff;		/* Suffix of the matching candidate */
 	Candidate *ret;		/* Return value */
 
 	tgn = targ->node;



CVS commit: src/usr.bin/make

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 12:03:25 UTC 2021

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

Log Message:
make(1): improve variable names when parsing directives


To generate a diff of this commit:
cvs rdiff -u -r1.529 -r1.530 src/usr.bin/make/parse.c

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

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.529 src/usr.bin/make/parse.c:1.530
--- src/usr.bin/make/parse.c:1.529	Sat Jan 23 11:34:41 2021
+++ src/usr.bin/make/parse.c	Sat Jan 23 12:03:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.529 2021/01/23 11:34:41 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.530 2021/01/23 12:03:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.529 2021/01/23 11:34:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.530 2021/01/23 12:03:25 rillig Exp $");
 
 /* types and constants */
 
@@ -1040,7 +1040,7 @@ ParseDependencyTargetWord(const char **p
 /* Handle special targets like .PATH, .DEFAULT, .BEGIN, .ORDER. */
 static void
 ParseDoDependencyTargetSpecial(ParseSpecial *inout_specType,
-			   const char *line, /* XXX: bad name */
+			   const char *targetName,
 			   SearchPathList **inout_paths)
 {
 	switch (*inout_specType) {
@@ -1062,7 +1062,7 @@ ParseDoDependencyTargetSpecial(ParseSpec
 	case SP_STALE:
 	case SP_ERROR:
 	case SP_INTERRUPT: {
-		GNode *gn = Targ_GetNode(line);
+		GNode *gn = Targ_GetNode(targetName);
 		if (doing_depend)
 			ParseMark(gn);
 		gn->type |= OP_NOTMAIN | OP_SPECIAL;
@@ -1105,15 +1105,15 @@ ParseDoDependencyTargetSpecial(ParseSpec
  * Call on the suffix module to give us a path to modify.
  */
 static Boolean
-ParseDoDependencyTargetPath(const char *line, /* XXX: bad name */
+ParseDoDependencyTargetPath(const char *suffixName,
 			SearchPathList **inout_paths)
 {
 	SearchPath *path;
 
-	path = Suff_GetPath([5]);
+	path = Suff_GetPath(suffixName);
 	if (path == NULL) {
 		Parse_Error(PARSE_FATAL,
-		"Suffix '%s' not defined (yet)", [5]);
+		"Suffix '%s' not defined (yet)", suffixName);
 		return FALSE;
 	}
 
@@ -1128,20 +1128,20 @@ ParseDoDependencyTargetPath(const char *
  * See if it's a special target and if so set specType to match it.
  */
 static Boolean
-ParseDoDependencyTarget(const char *line, /* XXX: bad name */
+ParseDoDependencyTarget(const char *targetName,
 			ParseSpecial *inout_specType,
 			GNodeType *out_tOp, SearchPathList **inout_paths)
 {
 	int keywd;
 
-	if (!(line[0] == '.' && ch_isupper(line[1])))
+	if (!(targetName[0] == '.' && ch_isupper(targetName[1])))
 		return TRUE;
 
 	/*
 	 * See if the target is a special target that must have it
 	 * or its sources handled specially.
 	 */
-	keywd = ParseFindKeyword(line);
+	keywd = ParseFindKeyword(targetName);
 	if (keywd != -1) {
 		if (*inout_specType == SP_PATH &&
 		parseKeywords[keywd].spec != SP_PATH) {
@@ -1152,22 +1152,21 @@ ParseDoDependencyTarget(const char *line
 		*inout_specType = parseKeywords[keywd].spec;
 		*out_tOp = parseKeywords[keywd].op;
 
-		ParseDoDependencyTargetSpecial(inout_specType, line,
+		ParseDoDependencyTargetSpecial(inout_specType, targetName,
 		inout_paths);
 
-	} else if (strncmp(line, ".PATH", 5) == 0) {
+	} else if (strncmp(targetName, ".PATH", 5) == 0) {
 		*inout_specType = SP_PATH;
-		if (!ParseDoDependencyTargetPath(line, inout_paths))
+		if (!ParseDoDependencyTargetPath(targetName + 5, inout_paths))
 			return FALSE;
 	}
 	return TRUE;
 }
 
 static void
-ParseDoDependencyTargetMundane(char *line, /* XXX: bad name */
-			   StringList *curTargs)
+ParseDoDependencyTargetMundane(char *targetName, StringList *curTargs)
 {
-	if (Dir_HasWildcards(line)) {
+	if (Dir_HasWildcards(targetName)) {
 		/*
 		 * Targets are to be sought only in the current directory,
 		 * so create an empty path for the thing. Note we need to
@@ -1176,7 +1175,7 @@ ParseDoDependencyTargetMundane(char *lin
 		 */
 		SearchPath *emptyPath = SearchPath_New();
 
-		SearchPath_Expand(emptyPath, line, curTargs);
+		SearchPath_Expand(emptyPath, targetName, curTargs);
 
 		SearchPath_Free(emptyPath);
 	} else {
@@ -1184,7 +1183,7 @@ ParseDoDependencyTargetMundane(char *lin
 		 * No wildcards, but we want to avoid code duplication,
 		 * so create a list with the word on it.
 		 */
-		Lst_Append(curTargs, line);
+		Lst_Append(curTargs, targetName);
 	}
 
 	/* Apply the targets. */
@@ -2191,12 +2190,12 @@ Parse_include_file(char *file, Boolean i
 }
 
 static void
-ParseDoInclude(char *line /* XXX: bad name */)
+ParseDoInclude(char *directive)
 {
 	char endc;		/* the character which ends the file spec */
 	char *cp;		/* current position in file spec */
-	Boolean silent = line[0] != 'i';
-	char *file = line + (silent ? 8 : 7);
+	Boolean silent = directive[0] != 

CVS commit: src/sys/dev/pci

2021-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jan 23 11:50:30 UTC 2021

Modified Files:
src/sys/dev/pci: if_ena.c

Log Message:
kern/55942: destroyed ena(4) evcnts cause panic

Fix event counter teardown code. From KUSABA Takeshi 


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/if_ena.c

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

Modified files:

Index: src/sys/dev/pci/if_ena.c
diff -u src/sys/dev/pci/if_ena.c:1.26 src/sys/dev/pci/if_ena.c:1.27
--- src/sys/dev/pci/if_ena.c:1.26	Mon Jan 18 08:29:32 2021
+++ src/sys/dev/pci/if_ena.c	Sat Jan 23 11:50:30 2021
@@ -36,7 +36,7 @@
 #if 0
 __FBSDID("$FreeBSD: head/sys/dev/ena/ena.c 333456 2018-05-10 09:37:54Z mw $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.26 2021/01/18 08:29:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.27 2021/01/23 11:50:30 jmcneill Exp $");
 
 #include 
 #include 
@@ -470,18 +470,20 @@ ena_alloc_counters_hwstats(struct ena_hw
 	+ sizeof(st->rx_drops) == sizeof(*st));
 }
 static inline void
-ena_free_counters(struct evcnt *begin, int size)
+ena_free_counters(struct evcnt *begin, int size, int offset)
 {
 	struct evcnt *end = (struct evcnt *)((char *)begin + size);
+	begin = (struct evcnt *)((char *)begin + offset);
 
 	for (; begin < end; ++begin)
 		counter_u64_free(*begin);
 }
 
 static inline void
-ena_reset_counters(struct evcnt *begin, int size)
+ena_reset_counters(struct evcnt *begin, int size, int offset)
 {
 	struct evcnt *end = (struct evcnt *)((char *)begin + size);
+	begin = (struct evcnt *)((char *)begin + offset);
 
 	for (; begin < end; ++begin)
 		counter_u64_zero(*begin);
@@ -566,9 +568,9 @@ ena_free_io_ring_resources(struct ena_ad
 	struct ena_ring *rxr = >rx_ring[qid];
 
 	ena_free_counters((struct evcnt *)>tx_stats,
-	sizeof(txr->tx_stats));
+	sizeof(txr->tx_stats), offsetof(struct ena_stats_tx, cnt));
 	ena_free_counters((struct evcnt *)>rx_stats,
-	sizeof(rxr->rx_stats));
+	sizeof(rxr->rx_stats), offsetof(struct ena_stats_rx, cnt));
 
 	ENA_RING_MTX_LOCK(txr);
 	drbr_free(txr->br, M_DEVBUF);
@@ -665,7 +667,8 @@ ena_setup_tx_resources(struct ena_adapte
 
 	/* Reset TX statistics. */
 	ena_reset_counters((struct evcnt *)_ring->tx_stats,
-	sizeof(tx_ring->tx_stats));
+	sizeof(tx_ring->tx_stats),
+	offsetof(struct ena_stats_tx, cnt));
 
 	tx_ring->next_to_use = 0;
 	tx_ring->next_to_clean = 0;
@@ -861,7 +864,8 @@ ena_setup_rx_resources(struct ena_adapte
 
 	/* Reset RX statistics. */
 	ena_reset_counters((struct evcnt *)_ring->rx_stats,
-	sizeof(rx_ring->rx_stats));
+	sizeof(rx_ring->rx_stats),
+	offsetof(struct ena_stats_rx, cnt));
 
 	rx_ring->next_to_clean = 0;
 	rx_ring->next_to_use = 0;
@@ -2204,7 +2208,8 @@ ena_up_complete(struct ena_adapter *adap
 
 	ena_refill_all_rx_bufs(adapter);
 	ena_reset_counters((struct evcnt *)>hw_stats,
-	sizeof(adapter->hw_stats));
+	sizeof(adapter->hw_stats),
+	offsetof(struct ena_hw_stats, rx_packets));
 
 	return (0);
 }
@@ -3895,9 +3900,11 @@ ena_detach(device_t pdev, int flags)
 	ena_free_all_io_rings_resources(adapter);
 
 	ena_free_counters((struct evcnt *)>hw_stats,
-	sizeof(struct ena_hw_stats));
+	sizeof(struct ena_hw_stats),
+	offsetof(struct ena_hw_stats, rx_packets));
 	ena_free_counters((struct evcnt *)>dev_stats,
-	sizeof(struct ena_stats_dev));
+	sizeof(struct ena_stats_dev),
+offsetof(struct ena_stats_dev, wd_expired));
 
 	if (likely(adapter->rss_support))
 		ena_com_rss_destroy(ena_dev);



CVS commit: src/usr.bin/make

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 11:44:10 UTC 2021

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

Log Message:
make(1): extend comments in dir.c


To generate a diff of this commit:
cvs rdiff -u -r1.260 -r1.261 src/usr.bin/make/dir.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/dir.c
diff -u src/usr.bin/make/dir.c:1.260 src/usr.bin/make/dir.c:1.261
--- src/usr.bin/make/dir.c:1.260	Sat Jan 23 11:34:41 2021
+++ src/usr.bin/make/dir.c	Sat Jan 23 11:44:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.260 2021/01/23 11:34:41 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.261 2021/01/23 11:44:10 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -138,7 +138,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.260 2021/01/23 11:34:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.261 2021/01/23 11:44:10 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -634,7 +634,9 @@ Dir_HasWildcards(const char *name)
  * This is incomplete -- wildcards are only expanded in the final path
  * component, but not in directories like src/lib*c/file*.c, but it
  * will do for now (now being 1993 until at least 2020). To expand these,
- * use the ':sh' variable modifier such as in ${:!echo src/lib*c/file*.c!}.
+ * delegate the work to the shell, using the '!=' variable assignment
+ * operator, the ':sh' variable modifier or the ':!...!' variable modifier,
+ * such as in ${:!echo src/lib*c/file*.c!}.
  *
  * Input:
  *	pattern		Pattern to look for
@@ -668,7 +670,8 @@ DirMatchFiles(const char *pattern, Cache
 		 * directory cache.
 		 *
 		 * This means that the pattern '[a-z.]*' does not find
-		 * '.file', which is consistent with bash, NetBSD sh and csh.
+		 * '.file', which is consistent with NetBSD sh, NetBSD ksh,
+		 * bash, dash, csh and probably many other shells as well.
 		 */
 		if (base[0] == '.' && pattern[0] != '.')
 			continue;



CVS commit: src/usr.bin/make

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 11:34:42 UTC 2021

Modified Files:
src/usr.bin/make: dir.c dir.h main.c parse.c suff.c

Log Message:
make(1): rename Dir_AddDir, reorder parameters of SearchPath_ToFlags


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/usr.bin/make/dir.c
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/make/dir.h
cvs rdiff -u -r1.515 -r1.516 src/usr.bin/make/main.c
cvs rdiff -u -r1.528 -r1.529 src/usr.bin/make/parse.c
cvs rdiff -u -r1.336 -r1.337 src/usr.bin/make/suff.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/dir.c
diff -u src/usr.bin/make/dir.c:1.259 src/usr.bin/make/dir.c:1.260
--- src/usr.bin/make/dir.c:1.259	Sat Jan 23 11:14:59 2021
+++ src/usr.bin/make/dir.c	Sat Jan 23 11:34:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.259 2021/01/23 11:14:59 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.260 2021/01/23 11:34:41 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -106,7 +106,7 @@
  *			Update the modification time and path of a node with
  *			data from the file corresponding to the node.
  *
- *	Dir_AddDir	Add a directory to a search path.
+ *	SearchPath_Add	Add a directory to a search path.
  *
  *	SearchPath_ToFlags
  *			Given a search path and a command flag, create
@@ -138,7 +138,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.259 2021/01/23 11:14:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.260 2021/01/23 11:34:41 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -485,18 +485,18 @@ Dir_Init(void)
  * Called by Dir_InitDir and whenever .CURDIR is assigned to.
  */
 void
-Dir_InitCur(const char *cdname)
+Dir_InitCur(const char *newCurdir)
 {
 	CachedDir *dir;
 
-	if (cdname == NULL)
+	if (newCurdir == NULL)
 		return;
 
 	/*
 	 * Our build directory is not the same as our source directory.
 	 * Keep this one around too.
 	 */
-	dir = Dir_AddDir(NULL, cdname);
+	dir = SearchPath_Add(NULL, newCurdir);
 	if (dir == NULL)
 		return;
 
@@ -512,7 +512,7 @@ Dir_InitDot(void)
 {
 	CachedDir *dir;
 
-	dir = Dir_AddDir(NULL, ".");
+	dir = SearchPath_Add(NULL, ".");
 	if (dir == NULL) {
 		Error("Cannot open `.' (%s)", strerror(errno));
 		exit(2);	/* Not 1 so -q can distinguish error */
@@ -877,7 +877,7 @@ SearchPath_ExpandMiddle(SearchPath *path
 		*end = '\0';
 
 	partPath = SearchPath_New();
-	(void)Dir_AddDir(partPath, dirpath);
+	(void)SearchPath_Add(partPath, dirpath);
 	DirExpandPath(wildcardComponent + 1, partPath, expansions);
 	SearchPath_Free(partPath);
 }
@@ -1291,7 +1291,7 @@ Dir_FindFile(const char *name, SearchPat
 			base++;
 		}
 		prefix = bmake_strsedup(name, base - 1);
-		(void)Dir_AddDir(path, prefix);
+		(void)SearchPath_Add(path, prefix);
 		free(prefix);
 
 		bigmisses++;
@@ -1546,7 +1546,7 @@ CacheNewDir(const char *name, SearchPath
  *			Lst_Append and CachedDir_Ref.
  */
 CachedDir *
-Dir_AddDir(SearchPath *path, const char *name)
+SearchPath_Add(SearchPath *path, const char *name)
 {
 
 	if (path != NULL && strcmp(name, ".DOTLAST") == 0) {
@@ -1606,7 +1606,7 @@ Dir_CopyDirSearchPath(void)
  *	don't go well.
  */
 char *
-SearchPath_ToFlags(const char *flag, SearchPath *path)
+SearchPath_ToFlags(SearchPath *path, const char *flag)
 {
 	Buffer buf;
 	SearchPathNode *ln;

Index: src/usr.bin/make/dir.h
diff -u src/usr.bin/make/dir.h:1.41 src/usr.bin/make/dir.h:1.42
--- src/usr.bin/make/dir.h:1.41	Sat Jan 23 10:48:49 2021
+++ src/usr.bin/make/dir.h	Sat Jan 23 11:34:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.41 2021/01/23 10:48:49 rillig Exp $	*/
+/*	$NetBSD: dir.h,v 1.42 2021/01/23 11:34:41 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -87,8 +87,8 @@ void SearchPath_Expand(SearchPath *, con
 char *Dir_FindFile(const char *, SearchPath *);
 char *Dir_FindHereOrAbove(const char *, const char *);
 void Dir_UpdateMTime(GNode *, Boolean);
-CachedDir *Dir_AddDir(SearchPath *, const char *);
-char *SearchPath_ToFlags(const char *, SearchPath *);
+CachedDir *SearchPath_Add(SearchPath *, const char *);
+char *SearchPath_ToFlags(SearchPath *, const char *);
 void SearchPath_Clear(SearchPath *);
 void SearchPath_AddAll(SearchPath *, SearchPath *);
 void Dir_PrintDirectories(void);

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.515 src/usr.bin/make/main.c:1.516
--- src/usr.bin/make/main.c:1.515	Sat Jan 23 10:48:49 2021
+++ src/usr.bin/make/main.c	Sat Jan 23 11:34:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.515 2021/01/23 10:48:49 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.516 2021/01/23 11:34:41 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -110,7 +110,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.515 

CVS commit: src/usr.bin/make

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 11:14:59 UTC 2021

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

Log Message:
make(1): extract SearchPath_ExpandMiddle from SearchPath_Expand


To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/usr.bin/make/dir.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/dir.c
diff -u src/usr.bin/make/dir.c:1.258 src/usr.bin/make/dir.c:1.259
--- src/usr.bin/make/dir.c:1.258	Sat Jan 23 11:06:04 2021
+++ src/usr.bin/make/dir.c	Sat Jan 23 11:14:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.258 2021/01/23 11:06:04 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.259 2021/01/23 11:14:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -138,7 +138,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.258 2021/01/23 11:06:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.259 2021/01/23 11:14:59 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -835,6 +835,54 @@ PrintExpansions(StringList *expansions)
 }
 
 /*
+ * The wildcard isn't in the first component.
+ * Find all the components up to the one with the wildcard.
+ */
+static void
+SearchPath_ExpandMiddle(SearchPath *path, const char *pattern,
+			const char *wildcardComponent, StringList *expansions)
+{
+	char *prefix, *dirpath, *end;
+	SearchPath *partPath;
+
+	prefix = bmake_strsedup(pattern, wildcardComponent + 1);
+	/*
+	 * XXX: Check the "the directory is added to the path" part.
+	 * It is probably surprising that the directory before a
+	 * wildcard gets added to the path.
+	 */
+	/*
+	 * XXX: Only the first match of the prefix in the path is
+	 * taken, any others are ignored.  The expectation may be
+	 * that the pattern is expanded in the whole path.
+	 */
+	dirpath = Dir_FindFile(prefix, path);
+	free(prefix);
+
+	/*
+	 * dirpath is null if can't find the leading component
+	 *
+	 * XXX: Dir_FindFile won't find internal components.  i.e. if the
+	 * path contains ../Etc/Object and we're looking for Etc, it won't
+	 * be found.  Ah well.  Probably not important.
+	 *
+	 * XXX: Check whether the above comment is still true.
+	 */
+	if (dirpath == NULL)
+		return;
+
+	end = [strlen(dirpath) - 1];
+	/* XXX: What about multiple trailing slashes? */
+	if (*end == '/')
+		*end = '\0';
+
+	partPath = SearchPath_New();
+	(void)Dir_AddDir(partPath, dirpath);
+	DirExpandPath(wildcardComponent + 1, partPath, expansions);
+	SearchPath_Free(partPath);
+}
+
+/*
  * Expand the given pattern into a list of existing filenames by globbing it,
  * looking in each directory from the search path.
  *
@@ -899,49 +947,9 @@ SearchPath_Expand(SearchPath *path, cons
 		/* The first component contains the wildcard. */
 		/* Start the search from the local directory */
 		DirExpandPath(pattern, path, expansions);
-		goto done;
-	}
-
-	{
-		char *prefix = bmake_strsedup(pattern, wildcardComponent + 1);
-		/*
-		 * The wildcard isn't in the first component.
-		 * Find all the components up to the one with the wildcard.
-		 */
-		/*
-		 * XXX: Check the "the directory is added to the path" part.
-		 * It is probably surprising that the directory before a
-		 * wildcard gets added to the path.
-		 */
-		/*
-		 * XXX: Only the first match of the prefix in the path is
-		 * taken, any others are ignored.  The expectation may be
-		 * that the pattern is expanded in the whole path.
-		 */
-		char *dirpath = Dir_FindFile(prefix, path);
-		free(prefix);
-
-		/*
-		 * dirpath is null if can't find the leading component
-		 * XXX: Dir_FindFile won't find internal components.
-		 * i.e. if the path contains ../Etc/Object and we're
-		 * looking for Etc, it won't be found. Ah well.
-		 * Probably not important.
-		 * XXX: Check whether the above comment is still true.
-		 */
-		if (dirpath != NULL) {
-			SearchPath *partPath;
-
-			char *end = [strlen(dirpath) - 1];
-			/* XXX: What about multiple trailing slashes? */
-			if (*end == '/')
-*end = '\0';
-
-			partPath = SearchPath_New();
-			(void)Dir_AddDir(partPath, dirpath);
-			DirExpandPath(wildcardComponent + 1, partPath, expansions);
-			SearchPath_Free(partPath);
-		}
+	} else {
+		SearchPath_ExpandMiddle(path, pattern, wildcardComponent,
+		expansions);
 	}
 
 done:



CVS commit: src/usr.bin/make

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 11:06:04 UTC 2021

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

Log Message:
make(1): split local variable in SearchPath_Expand


To generate a diff of this commit:
cvs rdiff -u -r1.257 -r1.258 src/usr.bin/make/dir.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/dir.c
diff -u src/usr.bin/make/dir.c:1.257 src/usr.bin/make/dir.c:1.258
--- src/usr.bin/make/dir.c:1.257	Sat Jan 23 10:52:03 2021
+++ src/usr.bin/make/dir.c	Sat Jan 23 11:06:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.257 2021/01/23 10:52:03 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.258 2021/01/23 11:06:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -138,7 +138,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.257 2021/01/23 10:52:03 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.258 2021/01/23 11:06:04 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -846,23 +846,23 @@ PrintExpansions(StringList *expansions)
 void
 SearchPath_Expand(SearchPath *path, const char *pattern, StringList *expansions)
 {
-	const char *cp;
+	const char *brace, *slash, *wildcard, *wildcardComponent;
 
 	assert(path != NULL);
 	assert(expansions != NULL);
 
 	DEBUG1(DIR, "Expanding \"%s\"... ", pattern);
 
-	cp = strchr(pattern, '{');
-	if (cp != NULL) {
-		DirExpandCurly(pattern, cp, path, expansions);
+	brace = strchr(pattern, '{');
+	if (brace != NULL) {
+		DirExpandCurly(pattern, brace, path, expansions);
 		goto done;
 	}
 
 	/* At this point, the pattern does not contain '{'. */
 
-	cp = strchr(pattern, '/');
-	if (cp == NULL) {
+	slash = strchr(pattern, '/');
+	if (slash == NULL) {
 		/* The pattern has no directory component. */
 
 		/* First the files in dot. */
@@ -875,11 +875,11 @@ SearchPath_Expand(SearchPath *path, cons
 	/* At this point, the pattern has a directory component. */
 
 	/* Find the first wildcard in the pattern. */
-	for (cp = pattern; *cp != '\0'; cp++)
-		if (*cp == '?' || *cp == '[' || *cp == '*')
+	for (wildcard = pattern; *wildcard != '\0'; wildcard++)
+		if (*wildcard == '?' || *wildcard == '[' || *wildcard == '*')
 			break;
 
-	if (*cp == '\0') {
+	if (*wildcard == '\0') {
 		/*
 		 * No directory component and no wildcard at all -- this
 		 * should never happen as in such a simple case there is no
@@ -891,10 +891,11 @@ SearchPath_Expand(SearchPath *path, cons
 
 	/* Back up to the start of the component containing the wildcard. */
 	/* XXX: This handles '///' and '/' differently. */
-	while (cp > pattern && *cp != '/')
-		cp--;
+	wildcardComponent = wildcard;
+	while (wildcardComponent > pattern && *wildcardComponent != '/')
+		wildcardComponent--;
 
-	if (cp == pattern) {
+	if (wildcardComponent == pattern) {
 		/* The first component contains the wildcard. */
 		/* Start the search from the local directory */
 		DirExpandPath(pattern, path, expansions);
@@ -902,7 +903,7 @@ SearchPath_Expand(SearchPath *path, cons
 	}
 
 	{
-		char *prefix = bmake_strsedup(pattern, cp + 1);
+		char *prefix = bmake_strsedup(pattern, wildcardComponent + 1);
 		/*
 		 * The wildcard isn't in the first component.
 		 * Find all the components up to the one with the wildcard.
@@ -938,7 +939,7 @@ SearchPath_Expand(SearchPath *path, cons
 
 			partPath = SearchPath_New();
 			(void)Dir_AddDir(partPath, dirpath);
-			DirExpandPath(cp + 1, partPath, expansions);
+			DirExpandPath(wildcardComponent + 1, partPath, expansions);
 			SearchPath_Free(partPath);
 		}
 	}



CVS commit: src/usr.bin/make

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 10:52:03 UTC 2021

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

Log Message:
make(1): rename parameter of SearchPath_Expand


To generate a diff of this commit:
cvs rdiff -u -r1.256 -r1.257 src/usr.bin/make/dir.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/dir.c
diff -u src/usr.bin/make/dir.c:1.256 src/usr.bin/make/dir.c:1.257
--- src/usr.bin/make/dir.c:1.256	Sat Jan 23 10:48:49 2021
+++ src/usr.bin/make/dir.c	Sat Jan 23 10:52:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.256 2021/01/23 10:48:49 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.257 2021/01/23 10:52:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -138,7 +138,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.256 2021/01/23 10:48:49 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.257 2021/01/23 10:52:03 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -835,47 +835,47 @@ PrintExpansions(StringList *expansions)
 }
 
 /*
- * Expand the given word into a list of words by globbing it, looking in the
- * directories on the given search path.
+ * Expand the given pattern into a list of existing filenames by globbing it,
+ * looking in each directory from the search path.
  *
  * Input:
- *	word		the word to expand
  *	path		the directories in which to find the files
+ *	pattern		the pattern to expand
  *	expansions	the list on which to place the results
  */
 void
-SearchPath_Expand(SearchPath *path, const char *word, StringList *expansions)
+SearchPath_Expand(SearchPath *path, const char *pattern, StringList *expansions)
 {
 	const char *cp;
 
 	assert(path != NULL);
 	assert(expansions != NULL);
 
-	DEBUG1(DIR, "Expanding \"%s\"... ", word);
+	DEBUG1(DIR, "Expanding \"%s\"... ", pattern);
 
-	cp = strchr(word, '{');
+	cp = strchr(pattern, '{');
 	if (cp != NULL) {
-		DirExpandCurly(word, cp, path, expansions);
+		DirExpandCurly(pattern, cp, path, expansions);
 		goto done;
 	}
 
-	/* At this point, the word does not contain '{'. */
+	/* At this point, the pattern does not contain '{'. */
 
-	cp = strchr(word, '/');
+	cp = strchr(pattern, '/');
 	if (cp == NULL) {
-		/* The word has no directory component. */
-		/* First the files in dot. */
-		DirMatchFiles(word, dot, expansions);
+		/* The pattern has no directory component. */
 
+		/* First the files in dot. */
+		DirMatchFiles(pattern, dot, expansions);
 		/* Then the files in every other directory on the path. */
-		DirExpandPath(word, path, expansions);
+		DirExpandPath(pattern, path, expansions);
 		goto done;
 	}
 
-	/* At this point, the word has a directory component. */
+	/* At this point, the pattern has a directory component. */
 
-	/* Find the first wildcard in the word. */
-	for (cp = word; *cp != '\0'; cp++)
+	/* Find the first wildcard in the pattern. */
+	for (cp = pattern; *cp != '\0'; cp++)
 		if (*cp == '?' || *cp == '[' || *cp == '*')
 			break;
 
@@ -885,24 +885,24 @@ SearchPath_Expand(SearchPath *path, cons
 		 * should never happen as in such a simple case there is no
 		 * need to expand anything.
 		 */
-		DirExpandPath(word, path, expansions);
+		DirExpandPath(pattern, path, expansions);
 		goto done;
 	}
 
 	/* Back up to the start of the component containing the wildcard. */
 	/* XXX: This handles '///' and '/' differently. */
-	while (cp > word && *cp != '/')
+	while (cp > pattern && *cp != '/')
 		cp--;
 
-	if (cp == word) {
+	if (cp == pattern) {
 		/* The first component contains the wildcard. */
 		/* Start the search from the local directory */
-		DirExpandPath(word, path, expansions);
+		DirExpandPath(pattern, path, expansions);
 		goto done;
 	}
 
 	{
-		char *prefix = bmake_strsedup(word, cp + 1);
+		char *prefix = bmake_strsedup(pattern, cp + 1);
 		/*
 		 * The wildcard isn't in the first component.
 		 * Find all the components up to the one with the wildcard.



CVS commit: src/usr.bin/make

2021-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 10:48:49 UTC 2021

Modified Files:
src/usr.bin/make: arch.c dir.c dir.h main.c parse.c suff.c
src/usr.bin/make/unit-tests: dir.mk

Log Message:
make(1): rename Dir_Expand to SearchPath_Expand

The main subject of this function is the search path.  In this search
path the pattern is expanded.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/usr.bin/make/arch.c
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/make/dir.c
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/make/dir.h
cvs rdiff -u -r1.514 -r1.515 src/usr.bin/make/main.c
cvs rdiff -u -r1.527 -r1.528 src/usr.bin/make/parse.c
cvs rdiff -u -r1.335 -r1.336 src/usr.bin/make/suff.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/dir.mk

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/arch.c
diff -u src/usr.bin/make/arch.c:1.193 src/usr.bin/make/arch.c:1.194
--- src/usr.bin/make/arch.c:1.193	Sat Jan  9 16:06:09 2021
+++ src/usr.bin/make/arch.c	Sat Jan 23 10:48:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.193 2021/01/09 16:06:09 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.194 2021/01/23 10:48:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.193 2021/01/09 16:06:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.194 2021/01/23 10:48:49 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -341,7 +341,7 @@ Arch_ParseArchive(char **pp, GNodeList *
 
 		} else if (Dir_HasWildcards(memName)) {
 			StringList members = LST_INIT;
-			Dir_Expand(memName, , );
+			SearchPath_Expand(, memName, );
 
 			while (!Lst_IsEmpty()) {
 char *member = Lst_Dequeue();

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.255 src/usr.bin/make/dir.c:1.256
--- src/usr.bin/make/dir.c:1.255	Sun Jan 10 21:20:46 2021
+++ src/usr.bin/make/dir.c	Sat Jan 23 10:48:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.255 2021/01/10 21:20:46 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.256 2021/01/23 10:48:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -89,8 +89,9 @@
  *			Returns TRUE if the name given it needs to
  *			be wildcard-expanded.
  *
- *	Dir_Expand	Given a pattern and a path, return a Lst of names
- *			which match the pattern on the search path.
+ *	SearchPath_Expand
+ *			Expand a filename pattern to find all matching files
+ *			from the search path.
  *
  *	Dir_FindFile	Searches for a file on a given search path.
  *			If it exists, the entire path is returned.
@@ -137,7 +138,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.255 2021/01/10 21:20:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.256 2021/01/23 10:48:49 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -797,7 +798,7 @@ DirExpandCurly(const char *word, const c
  suffix, suffix_len);
 
 		if (contains_wildcard(file)) {
-			Dir_Expand(file, path, expansions);
+			SearchPath_Expand(path, file, expansions);
 			free(file);
 		} else {
 			Lst_Append(expansions, file);
@@ -843,7 +844,7 @@ PrintExpansions(StringList *expansions)
  *	expansions	the list on which to place the results
  */
 void
-Dir_Expand(const char *word, SearchPath *path, StringList *expansions)
+SearchPath_Expand(SearchPath *path, const char *word, StringList *expansions)
 {
 	const char *cp;
 

Index: src/usr.bin/make/dir.h
diff -u src/usr.bin/make/dir.h:1.40 src/usr.bin/make/dir.h:1.41
--- src/usr.bin/make/dir.h:1.40	Tue Dec  1 19:28:32 2020
+++ src/usr.bin/make/dir.h	Sat Jan 23 10:48:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.40 2020/12/01 19:28:32 rillig Exp $	*/
+/*	$NetBSD: dir.h,v 1.41 2021/01/23 10:48:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -83,7 +83,7 @@ void Dir_InitDot(void);
 void Dir_End(void);
 void Dir_SetPATH(void);
 Boolean Dir_HasWildcards(const char *);
-void Dir_Expand(const char *, SearchPath *, StringList *);
+void SearchPath_Expand(SearchPath *, const char *, StringList *);
 char *Dir_FindFile(const char *, SearchPath *);
 char *Dir_FindHereOrAbove(const char *, const char *);
 void Dir_UpdateMTime(GNode *, Boolean);

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.514 src/usr.bin/make/main.c:1.515
--- src/usr.bin/make/main.c:1.514	Tue Jan 19 20:51:46 2021
+++ src/usr.bin/make/main.c	Sat Jan 23 10:48:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.514 2021/01/19 20:51:46 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.515 2021/01/23 10:48:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -110,7 +110,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: