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

2022-01-27 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 27 21:50:50 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-debug-hash.exp

Log Message:
numEntries can vary


To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-debug-hash.exp

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



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

2022-01-27 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 27 21:50:50 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-debug-hash.exp

Log Message:
numEntries can vary


To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-debug-hash.exp

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.301 src/usr.bin/make/unit-tests/Makefile:1.302
--- src/usr.bin/make/unit-tests/Makefile:1.301	Thu Jan 27 02:24:46 2022
+++ src/usr.bin/make/unit-tests/Makefile	Thu Jan 27 21:50:50 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.301 2022/01/27 02:24:46 sjg Exp $
+# $NetBSD: Makefile,v 1.302 2022/01/27 21:50:50 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -503,6 +503,7 @@ SED_CMDS.opt-chdir=		-e 's,\(nonexistent
 SED_CMDS.opt-debug-graph1=	${STD_SED_CMDS.dg1}
 SED_CMDS.opt-debug-graph2=	${STD_SED_CMDS.dg2}
 SED_CMDS.opt-debug-graph3=	${STD_SED_CMDS.dg3}
+SED_CMDS.opt-debug-hash=	-e 's,\(numEntries\)=[1-9][0-9],\1=,'
 SED_CMDS.opt-debug-jobs=	-e 's,([0-9][0-9]*),(),'
 SED_CMDS.opt-debug-jobs+=	-e 's,pid [0-9][0-9]*,pid ,'
 SED_CMDS.opt-debug-jobs+=	-e 's,Process [0-9][0-9]*,Process ,'

Index: src/usr.bin/make/unit-tests/opt-debug-hash.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.3 src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.4
--- src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.3	Sat Jan 22 18:59:24 2022
+++ src/usr.bin/make/unit-tests/opt-debug-hash.exp	Thu Jan 27 21:50:50 2022
@@ -1,6 +1,6 @@
 make: "opt-debug-hash.mk" line 11: Missing argument for ".error"
 make: Fatal errors encountered -- cannot continue
 HashTable targets: size=16 numEntries=0 maxchain=0
-HashTable Global variables: size=16 numEntries=23 maxchain=3
+HashTable Global variables: size=16 numEntries= maxchain=3
 make: stopped in unit-tests
 exit status 1



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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 20:15:14 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
tests/make: add more edge cases for expansion of .for loop body


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.14 -r1.15 \
src/usr.bin/make/unit-tests/directive-for-escape.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/unit-tests/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.15 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.16
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.15	Thu Jan 27 11:26:44 2022
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Thu Jan 27 20:15:14 2022
@@ -125,6 +125,15 @@ For: loop body:
 # ${:U${:U\$\$}}
 For: end for 1
 For: loop body:
+# ${:U${.TARGET}}
+For: loop body:
+# ${:U${.TARGET}}
+For: loop body:
+# ${:U$${.TARGET\}}
+For: loop body:
+# ${:U$${.TARGET\}}
+For: end for 1
+For: loop body:
 # ${:U(((}
 For: loop body:
 # ${:U{{{}

Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.14 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.15
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.14	Thu Jan 27 11:26:44 2022
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Thu Jan 27 20:15:14 2022
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.14 2022/01/27 11:26:44 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.15 2022/01/27 20:15:14 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -65,7 +65,7 @@ ${:U\\}=	backslash
 # FIXME: There was no expression '$\' in the original text of the previous
 # line, that's a surprise in the parser.
 # The modifier ':U' unescapes the '\$' to a simple '$'.
-# expect+4: ${UNDEF:U\$
+# expect+4: ${UNDEF:U\backslash$
 VALUES=		$${UNDEF:U\$$\$$ {{}} end}
 # XXX: Where in the code does the '\$\$' get converted into a single '\$'?
 .for i in ${VALUES}
@@ -178,6 +178,20 @@ ${closing-brace}=		# alte
 # $i
 .endfor
 
+# The expression '${.TARGET}' must be preserved as it is one of the 7 built-in
+# target-local variables.  See for.c 1.45 from 2009-01-14.
+.for i in ${.TARGET} $${.TARGET} $$${.TARGET} {.TARGET}
+# $i
+.endfor
+# expect: # ${:U${.TARGET}}
+# XXX: Why does '$' result in the same text as '$$'?
+# expect: # ${:U${.TARGET}}
+# XXX: Why does the '$$' before the '${.TARGET}' lead to an escaped '}'?
+# expect: # ${:U$${.TARGET\}}
+# XXX: Why does '$' result in the same text as '$$'?
+# XXX: Why does the '$$' before the '${.TARGET}' lead to an escaped '}'?
+# expect: # ${:U$${.TARGET\}}
+
 .for i in ((( {{{ ))) }}}
 # $i
 .endfor



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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 20:15:14 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
tests/make: add more edge cases for expansion of .for loop body


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.14 -r1.15 \
src/usr.bin/make/unit-tests/directive-for-escape.mk

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



CVS commit: src/sys/dev/scsipi

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 18:44:49 UTC 2022

Modified Files:
src/sys/dev/scsipi: sd.c

Log Message:
use powerof2() in sd_validate_blksize()


To generate a diff of this commit:
cvs rdiff -u -r1.332 -r1.333 src/sys/dev/scsipi/sd.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/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.332 src/sys/dev/scsipi/sd.c:1.333
--- src/sys/dev/scsipi/sd.c:1.332	Sun May 30 06:46:46 2021
+++ src/sys/dev/scsipi/sd.c	Thu Jan 27 18:44:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.332 2021/05/30 06:46:46 dholland Exp $	*/
+/*	$NetBSD: sd.c,v 1.333 2022/01/27 18:44:49 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.332 2021/05/30 06:46:46 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.333 2022/01/27 18:44:49 jakllsch Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -1311,19 +1311,14 @@ static int
 sd_validate_blksize(struct scsipi_periph *periph, int len)
 {
 
-	switch (len) {
-	case 256:
-	case 512:
-	case 1024:
-	case 2048:
-	case 4096:
+	if (len >= 256 && powerof2(len) && len <= 4096) {
 		return 1;
 	}
 
 	if (periph) {
 		scsipi_printaddr(periph);
 		printf("%s sector size: 0x%x.  Defaulting to %d bytes.\n",
-		(len ^ (1 << (ffs(len) - 1))) ?
+		!powerof2(len) ?
 		"preposterous" : "unsupported",
 		len, SD_DEFAULT_BLKSIZE);
 	}



CVS commit: src/sys/dev/scsipi

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 18:44:49 UTC 2022

Modified Files:
src/sys/dev/scsipi: sd.c

Log Message:
use powerof2() in sd_validate_blksize()


To generate a diff of this commit:
cvs rdiff -u -r1.332 -r1.333 src/sys/dev/scsipi/sd.c

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



CVS commit: src/sys/dev/pci

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 18:38:07 UTC 2022

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

Log Message:
We no need for PQUIRK_FORCELUNS now that we try REPORT LUNS.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/vioscsi.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/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.28 src/sys/dev/pci/vioscsi.c:1.29
--- src/sys/dev/pci/vioscsi.c:1.28	Fri Nov 12 07:18:53 2021
+++ src/sys/dev/pci/vioscsi.c	Thu Jan 27 18:38:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.28 2021/11/12 07:18:53 skrll Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.29 2022/01/27 18:38:07 jakllsch Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.28 2021/11/12 07:18:53 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.29 2022/01/27 18:38:07 jakllsch Exp $");
 
 #include 
 #include 
@@ -192,25 +192,10 @@ vioscsi_attach(device_t parent, device_t
 	chan->chan_adapter = adapt;
 	chan->chan_bustype = _bustype;
 	chan->chan_channel = 0;
-	chan->chan_ntargets = MIN(max_target, 16);	/* cap reasonably */
-	chan->chan_nluns = MIN(max_lun, 1024);		/* cap reasonably */
-	chan->chan_id = max_target;
+	chan->chan_ntargets = MIN(1 + max_target, 256);	/* cap reasonably */
+	chan->chan_nluns = MIN(1 + max_lun, 16384);	/* cap reasonably */
+	chan->chan_id = max_target + 1;
 	chan->chan_flags = SCSIPI_CHAN_NOSETTLE;
-	/*
-	 * XXX Remove this when scsipi is REPORT LUNS-aware.
-	 * scsipi(4) insists that LUNs must be contiguous starting from 0.
-	 * This is not true on Linode (circa 2020).
-	 *
-	 * Also if explicitly selecting the 'Virtio SCSI Single'
-	 * controller (which is not the default SCSI controller) on
-	 * Proxmox hosts, each disk will be on its own scsi bus at
-	 * target 0 but unexpectedly on a LUN matching the drive number
-	 * on the system (i.e. drive 0 will be bus 0, target 0, lun
-	 * 0; drive 1 will be bus 1, target 0, lun 1, drive 2 will be
-	 * bus 2, target 0, lun 2 -- which is where the gaps start
-	 * happening). https://bugzilla.proxmox.com/show_bug.cgi?id=2985
-	 */
-	chan->chan_defquirks = PQUIRK_FORCELUNS;
 
 	config_found(self, >sc_channel, scsiprint, CFARGS_NONE);
 	return;



CVS commit: src/sys/dev/pci

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 18:38:07 UTC 2022

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

Log Message:
We no need for PQUIRK_FORCELUNS now that we try REPORT LUNS.


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

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



CVS commit: src/sys/dev/scsipi

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 18:37:02 UTC 2022

Modified Files:
src/sys/dev/scsipi: scsi_spc.h scsiconf.c

Log Message:
Try REPORT LUNS command to enumerate logical units.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/scsipi/scsi_spc.h
cvs rdiff -u -r1.293 -r1.294 src/sys/dev/scsipi/scsiconf.c

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



CVS commit: src/sys/dev/scsipi

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 18:37:02 UTC 2022

Modified Files:
src/sys/dev/scsipi: scsi_spc.h scsiconf.c

Log Message:
Try REPORT LUNS command to enumerate logical units.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/scsipi/scsi_spc.h
cvs rdiff -u -r1.293 -r1.294 src/sys/dev/scsipi/scsiconf.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/scsipi/scsi_spc.h
diff -u src/sys/dev/scsipi/scsi_spc.h:1.6 src/sys/dev/scsipi/scsi_spc.h:1.7
--- src/sys/dev/scsipi/scsi_spc.h:1.6	Thu Mar 28 10:44:29 2019
+++ src/sys/dev/scsipi/scsi_spc.h	Thu Jan 27 18:37:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsi_spc.h,v 1.6 2019/03/28 10:44:29 kardel Exp $	*/
+/*	$NetBSD: scsi_spc.h,v 1.7 2022/01/27 18:37:02 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -404,6 +404,30 @@ struct scsi_reserve_release_10_idparam {
 /*
  * REPORT LUNS
  */
+#define SCSI_REPORT_LUNS		0xa0
+
+struct scsi_report_luns {
+	uint8_t opcode;
+	uint8_t reserved1;
+	uint8_t selectreport;
+#define SELECTREPORT_NORMAL		0x00
+#define SELECTREPORT_WELLKNOWN		0x01
+#define SELECTREPORT_ALL		0x02
+	uint8_t reserved3[3];
+	uint8_t alloclen[4];
+	uint8_t reserved10;
+	uint8_t control;
+};
+
+struct scsi_report_luns_header {
+	uint8_t	length[4];		/* in bytes, not including header */
+	uint8_t _res4[4];
+	/* followed by array of: */
+};
+
+struct scsi_report_luns_lun {
+	uint8_t lun[8];
+};
 
 /*
  * MAINTENANCE_IN[REPORT SUPPORTED OPERATION CODES]

Index: src/sys/dev/scsipi/scsiconf.c
diff -u src/sys/dev/scsipi/scsiconf.c:1.293 src/sys/dev/scsipi/scsiconf.c:1.294
--- src/sys/dev/scsipi/scsiconf.c:1.293	Tue Dec 21 22:53:21 2021
+++ src/sys/dev/scsipi/scsiconf.c	Thu Jan 27 18:37:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsiconf.c,v 1.293 2021/12/21 22:53:21 riastradh Exp $	*/
+/*	$NetBSD: scsiconf.c,v 1.294 2022/01/27 18:37:02 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.293 2021/12/21 22:53:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.294 2022/01/27 18:37:02 jakllsch Exp $");
 
 #include 
 #include 
@@ -64,6 +64,7 @@ __KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -370,6 +371,109 @@ scsibusdetach(device_t self, int flags)
 	return 0;
 }
 
+static int
+lun_compar(const void *a, const void *b)
+{
+	const uint16_t * const la = a, * const lb = b;
+
+	if (*la < *lb)
+		return -1;
+	if (*la > *lb)
+		return 1;
+	return 0;
+}
+
+static int
+scsi_report_luns(struct scsibus_softc *sc, int target,
+uint16_t ** const luns, size_t *nluns)
+{
+	struct scsi_report_luns replun;
+	struct scsi_report_luns_header *rlr;
+	struct scsi_report_luns_lun *lunp;
+
+	struct scsipi_channel *chan = sc->sc_channel;
+	struct scsipi_inquiry_data inqbuf;
+	struct scsipi_periph *periph;
+	uint16_t tmp;
+
+	int error;
+	size_t i, rlrlen;
+
+	periph = scsipi_alloc_periph(M_WAITOK);
+	periph->periph_channel = chan;
+	periph->periph_switch = _probe_dev;
+
+	periph->periph_target = target;
+	periph->periph_lun = 0;
+	periph->periph_quirks = chan->chan_defquirks;
+
+	if ((error = scsipi_inquire(periph, ,
+	XS_CTL_DISCOVERY | XS_CTL_SILENT)))
+		goto end2;
+	periph->periph_version = inqbuf.version & SID_ANSII;
+	if (periph->periph_version < 3) {
+		error = ENOTSUP;
+		goto end2;
+	}
+
+	rlrlen = sizeof(*rlr) + sizeof(*lunp) * 1;
+
+again:
+	rlr = kmem_zalloc(rlrlen, KM_SLEEP);
+
+	replun.opcode = SCSI_REPORT_LUNS;
+	replun.selectreport = SELECTREPORT_NORMAL;
+	_lto4b(rlrlen, replun.alloclen);
+
+	error = scsipi_command(periph, (void *), sizeof(replun),
+	(void *)rlr, rlrlen, SCSIPIRETRIES, 1, NULL,
+	XS_CTL_DATA_IN | XS_CTL_DISCOVERY | XS_CTL_SILENT);
+	if (error)
+		goto end;
+
+	if (sizeof(*rlr) + _4btol(rlr->length) > rlrlen &&
+	sizeof(*rlr) + _4btol(rlr->length) <= 32) {
+		const size_t old_rlrlen = rlrlen;
+		rlrlen = sizeof(*rlr) + uimin(_4btol(rlr->length),
+		16383 * sizeof(*lunp));
+		kmem_free(rlr, old_rlrlen);
+		rlr = NULL;
+		goto again;
+	}
+
+	KASSERT(nluns != NULL);
+	*nluns = (rlrlen - sizeof(*rlr)) / sizeof(*lunp);
+
+	KASSERT(luns != NULL);
+	*luns = kmem_alloc(*nluns * sizeof(**luns), KM_SLEEP);
+
+	for (i = 0; i < *nluns; i++) {
+		lunp = &((struct scsi_report_luns_lun *)[1])[i];
+		switch (lunp->lun[0] & 0xC0) {
+		default:
+			scsi_print_addr(periph);
+			printf("LUN %016"PRIx64" ignored\n", _8btol(lunp->lun));
+			(*luns)[i] = 0;
+			break;
+		case 0x40:
+			(*luns)[i] = _2btol(>lun[0]) & 0x3FFF;
+			break;
+		case 0x00:
+			(*luns)[i] = _2btol(>lun[0]) & 0x00FF;
+			break;
+		}
+	}
+
+	kheapsort(*luns, *nluns, sizeof(**luns), lun_compar, );
+
+end:
+	if (rlr)
+		kmem_free(rlr, rlrlen);
+end2:
+	scsipi_free_periph(periph);
+	return error;
+}

CVS commit: src/sys/dev/ic

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 18:07:27 UTC 2022

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

Log Message:
drop poorly phrased and redundant message about unsupported chip revisions


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/dev/ic/rtl8169.c

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

Modified files:

Index: src/sys/dev/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.169 src/sys/dev/ic/rtl8169.c:1.170
--- src/sys/dev/ic/rtl8169.c:1.169	Fri Dec 31 14:25:22 2021
+++ src/sys/dev/ic/rtl8169.c	Thu Jan 27 18:07:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.169 2021/12/31 14:25:22 riastradh Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.170 2022/01/27 18:07:27 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.169 2021/12/31 14:25:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.170 2022/01/27 18:07:27 jakllsch Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -714,7 +714,6 @@ re_attach(struct rtk_softc *sc)
 			RTKQ_CMDSTOP; /* CMDSTOP_WAIT_TXQ */
 			break;
 		default:
-			aprint_normal_dev(sc->sc_dev, "Use default quirks\n");
 			/* assume the latest features */
 			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD;
 			sc->sc_quirk |= RTKQ_NOJUMBO;



CVS commit: src/sys/dev/ic

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 18:07:27 UTC 2022

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

Log Message:
drop poorly phrased and redundant message about unsupported chip revisions


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/dev/ic/rtl8169.c

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



CVS commit: src/sys/arch/evbarm/conf

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 14:39:49 UTC 2022

Modified Files:
src/sys/arch/evbarm/conf: GENERIC GENERIC64

Log Message:
enable WSDISPLAY_CUSTOM_BORDER and WSDISPLAY_CUSTOM_OUTPUT to match i386 GENERIC


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/evbarm/conf/GENERIC
cvs rdiff -u -r1.191 -r1.192 src/sys/arch/evbarm/conf/GENERIC64

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/evbarm/conf/GENERIC
diff -u src/sys/arch/evbarm/conf/GENERIC:1.103 src/sys/arch/evbarm/conf/GENERIC:1.104
--- src/sys/arch/evbarm/conf/GENERIC:1.103	Sat Nov 13 01:29:21 2021
+++ src/sys/arch/evbarm/conf/GENERIC	Thu Jan 27 14:39:49 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC,v 1.103 2021/11/13 01:29:21 jmcneill Exp $
+#	$NetBSD: GENERIC,v 1.104 2022/01/27 14:39:49 jakllsch Exp $
 #
 #	GENERIC ARM (aarch32) kernel
 #
@@ -521,10 +521,12 @@ tifb* 		at tilcdc?
 
 options 	VCONS_DRAW_INTR
 options 	WSEMUL_VT100
+options 	WSDISPLAY_CUSTOM_OUTPUT
 options 	WS_DEFAULT_FG=WSCOL_WHITE
 options 	WS_DEFAULT_BG=WSCOL_BLACK
 options 	WS_KERNEL_FG=WSCOL_GREEN
 options 	WS_KERNEL_BG=WSCOL_BLACK
+options 	WSDISPLAY_CUSTOM_BORDER
 options 	WSDISPLAY_COMPAT_PCVT
 options 	WSDISPLAY_COMPAT_SYSCONS
 options 	WSDISPLAY_COMPAT_USL

Index: src/sys/arch/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.191 src/sys/arch/evbarm/conf/GENERIC64:1.192
--- src/sys/arch/evbarm/conf/GENERIC64:1.191	Sun Jan  9 15:05:16 2022
+++ src/sys/arch/evbarm/conf/GENERIC64	Thu Jan 27 14:39:49 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.191 2022/01/09 15:05:16 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.192 2022/01/27 14:39:49 jakllsch Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -463,10 +463,12 @@ genfb*		at fdt?			# Simple Framebuffer
 wsdisplay*	at wsemuldisplaydev?
 options 	VCONS_DRAW_INTR
 options 	WSEMUL_VT100
+options 	WSDISPLAY_CUSTOM_OUTPUT
 options 	WS_DEFAULT_FG=WSCOL_WHITE
 options 	WS_DEFAULT_BG=WSCOL_BLACK
 options 	WS_KERNEL_FG=WSCOL_GREEN
 options 	WS_KERNEL_BG=WSCOL_BLACK
+options 	WSDISPLAY_CUSTOM_BORDER
 options 	WSDISPLAY_COMPAT_PCVT
 options 	WSDISPLAY_COMPAT_SYSCONS
 options 	WSDISPLAY_COMPAT_USL



CVS commit: src/sys/arch/evbarm/conf

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 14:39:49 UTC 2022

Modified Files:
src/sys/arch/evbarm/conf: GENERIC GENERIC64

Log Message:
enable WSDISPLAY_CUSTOM_BORDER and WSDISPLAY_CUSTOM_OUTPUT to match i386 GENERIC


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/evbarm/conf/GENERIC
cvs rdiff -u -r1.191 -r1.192 src/sys/arch/evbarm/conf/GENERIC64

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



CVS commit: src/sys/modules/if_wg

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 14:18:40 UTC 2022

Modified Files:
src/sys/modules/if_wg: Makefile

Log Message:
Turn off ALTQ in if_wg module, to match default kernel configs


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/if_wg/Makefile

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

Modified files:

Index: src/sys/modules/if_wg/Makefile
diff -u src/sys/modules/if_wg/Makefile:1.1 src/sys/modules/if_wg/Makefile:1.2
--- src/sys/modules/if_wg/Makefile:1.1	Tue Aug 17 17:29:20 2021
+++ src/sys/modules/if_wg/Makefile	Thu Jan 27 14:18:40 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2021/08/17 17:29:20 christos Exp $
+# $NetBSD: Makefile,v 1.2 2022/01/27 14:18:40 jakllsch Exp $
 
 .include "../Makefile.inc"
 
@@ -10,7 +10,7 @@ SRCS=		if_wg.c
 
 CPPFLAGS+=	-DINET
 CPPFLAGS+=	-DINET6
-CPPFLAGS+=	-DALTQ
+#CPPFLAGS+=	-DALTQ
 
 WARNS=		3
 



CVS commit: src/sys/modules/if_wg

2022-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 27 14:18:40 UTC 2022

Modified Files:
src/sys/modules/if_wg: Makefile

Log Message:
Turn off ALTQ in if_wg module, to match default kernel configs


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/if_wg/Makefile

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



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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 11:26:44 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
tests/make: explain escaping in .for loops, add more test cases


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.13 -r1.14 \
src/usr.bin/make/unit-tests/directive-for-escape.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/unit-tests/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.14 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.15
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.14	Sun Jan  9 20:53:53 2022
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Thu Jan 27 11:26:44 2022
@@ -27,29 +27,29 @@ make: "directive-for-escape.mk" line 43:
 For: end for 1
 For: loop body:
 .  info ${:U\${UNDEF\:U\\$\\$}
-make: "directive-for-escape.mk" line 57: ${UNDEF:U\$
+make: "directive-for-escape.mk" line 72: ${UNDEF:U\backslash$
 For: loop body:
 .  info ${:U{{\}\}}
-make: "directive-for-escape.mk" line 57: {{}}
+make: "directive-for-escape.mk" line 72: {{}}
 For: loop body:
 .  info ${:Uend\}}
-make: "directive-for-escape.mk" line 57: end}
+make: "directive-for-escape.mk" line 72: end}
 For: end for 1
 For: loop body:
 .  info ${:Ubegin<${UNDEF:Ufallback:N{{{>end}
-make: "directive-for-escape.mk" line 69: beginend
+make: "directive-for-escape.mk" line 84: beginend
 For: end for 1
 For: loop body:
 .  info ${:U\$}
-make: "directive-for-escape.mk" line 77: $
+make: "directive-for-escape.mk" line 92: $
 For: end for 1
 For: loop body:
 .  info ${NUMBERS} ${:Ureplaced}
-make: "directive-for-escape.mk" line 85: one two three replaced
+make: "directive-for-escape.mk" line 100: one two three replaced
 For: end for 1
 For: loop body:
 .  info ${:Ureplaced}
-make: "directive-for-escape.mk" line 95: replaced
+make: "directive-for-escape.mk" line 110: replaced
 For: end for 1
 For: loop body:
 .  info .$$i: ${:Uinner}
@@ -62,47 +62,76 @@ For: loop body:
 .  info . $${i2}: ${i2}
 .  info . $${i,}: ${i,}
 .  info .  adjacent: ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner}
-make: "directive-for-escape.mk" line 103: .$i: inner
-make: "directive-for-escape.mk" line 104: .  ${i}: inner
-make: "directive-for-escape.mk" line 105: .   ${i:M*}: inner
-make: "directive-for-escape.mk" line 106: .  $(i): inner
-make: "directive-for-escape.mk" line 107: .   $(i:M*): inner
-make: "directive-for-escape.mk" line 108: . ${i${:U}}: outer
-make: "directive-for-escape.mk" line 109: .${i\}}: inner}
-make: "directive-for-escape.mk" line 110: . ${i2}: two
-make: "directive-for-escape.mk" line 111: . ${i,}: comma
-make: "directive-for-escape.mk" line 112: .  adjacent: innerinnerinnerinner
+make: "directive-for-escape.mk" line 118: .$i: inner
+make: "directive-for-escape.mk" line 119: .  ${i}: inner
+make: "directive-for-escape.mk" line 120: .   ${i:M*}: inner
+make: "directive-for-escape.mk" line 121: .  $(i): inner
+make: "directive-for-escape.mk" line 122: .   $(i:M*): inner
+make: "directive-for-escape.mk" line 123: . ${i${:U}}: outer
+make: "directive-for-escape.mk" line 124: .${i\}}: inner}
+make: "directive-for-escape.mk" line 125: . ${i2}: two
+make: "directive-for-escape.mk" line 126: . ${i,}: comma
+make: "directive-for-escape.mk" line 127: .  adjacent: innerinnerinnerinner
 For: end for 1
 For: loop body:
 .  info eight  and no cents.
 .  info eight ${:Udollar}${:Udollar}${:Udollar}${:Udollar} and no cents.
-make: "directive-for-escape.mk" line 120: eight  and no cents.
-make: "directive-for-escape.mk" line 121: eight dollardollardollardollar and no cents.
-make: "directive-for-escape.mk" line 130: eight  and no cents.
+make: "directive-for-escape.mk" line 135: eight  and no cents.
+make: "directive-for-escape.mk" line 136: eight dollardollardollardollar and no cents.
+make: "directive-for-escape.mk" line 145: eight  and no cents.
 For: end for 1
-make: "directive-for-escape.mk" line 137: newline in .for value
-make: "directive-for-escape.mk" line 137: newline in .for value
+make: "directive-for-escape.mk" line 152: newline in .for value
+make: "directive-for-escape.mk" line 152: newline in .for value
 For: loop body:
 .  info short: ${:U" "}
 .  info long: ${:U" "}
-make: "directive-for-escape.mk" line 138: short: " "
-make: "directive-for-escape.mk" line 139: long: " "
+make: "directive-for-escape.mk" line 153: short: " "
+make: "directive-for-escape.mk" line 154: long: " "
 For: end for 1
 For: loop body:
 For: end for 1
-Parse_PushInput: .for loop in directive-for-escape.mk, line 152
-make: "directive-for-escape.mk" line 152: newline in .for value
-	in .for loop from 

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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 11:26:44 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
tests/make: explain escaping in .for loops, add more test cases


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.13 -r1.14 \
src/usr.bin/make/unit-tests/directive-for-escape.mk

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



CVS commit: src/usr.bin/make

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 11:16:44 UTC 2022

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

Log Message:
make: clean up AddEscape for building the body of a .for loop

Adding 1 + len bytes but only incrementing the pointer by len bytes
looked suspicious, so use the same expression in both places.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/usr.bin/make/for.c

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

Modified files:

Index: src/usr.bin/make/for.c
diff -u src/usr.bin/make/for.c:1.165 src/usr.bin/make/for.c:1.166
--- src/usr.bin/make/for.c:1.165	Sun Jan  9 18:59:27 2022
+++ src/usr.bin/make/for.c	Thu Jan 27 11:16:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.165 2022/01/09 18:59:27 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.166 2022/01/27 11:16:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.165 2022/01/09 18:59:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.166 2022/01/27 11:16:44 rillig Exp $");
 
 
 typedef struct ForLoop {
@@ -319,9 +319,8 @@ NeedsEscapes(Substring value, char endc)
 
 /*
  * While expanding the body of a .for loop, write the item in the ${:U...}
- * expression, escaping characters as needed.
- *
- * The result is later unescaped by ApplyModifier_Defined.
+ * expression, escaping characters as needed.  The result is later unescaped
+ * by ApplyModifier_Defined.
  */
 static void
 AddEscaped(Buffer *cmds, Substring item, char endc)
@@ -334,11 +333,7 @@ AddEscaped(Buffer *cmds, Substring item,
 		return;
 	}
 
-	/*
-	 * Escape ':', '$', '\\' and 'endc' - these will be removed later by
-	 * :U processing, see ApplyModifier_Defined.
-	 */
-	for (p = item.start; p != item.end; p++) {
+	for (p = item.start; p != item.end;) {
 		ch = *p;
 		if (ch == '$') {
 			size_t len = ExprLen(p + 1, item.end);
@@ -348,7 +343,7 @@ AddEscaped(Buffer *cmds, Substring item,
  * See directive-for-escape.mk, ExprLen.
  */
 Buf_AddBytes(cmds, p, 1 + len);
-p += len;
+p += 1 + len;
 continue;
 			}
 			Buf_AddByte(cmds, '\\');
@@ -359,6 +354,7 @@ AddEscaped(Buffer *cmds, Substring item,
 			ch = ' ';	/* prevent newline injection */
 		}
 		Buf_AddByte(cmds, ch);
+		p++;
 	}
 }
 



CVS commit: src/usr.bin/make

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 11:16:44 UTC 2022

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

Log Message:
make: clean up AddEscape for building the body of a .for loop

Adding 1 + len bytes but only incrementing the pointer by len bytes
looked suspicious, so use the same expression in both places.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/usr.bin/make/for.c

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



CVS commit: src/usr.bin/make

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 11:00:07 UTC 2022

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

Log Message:
make: merge duplicate code for finding an entry in a hash table

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/make/hash.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/hash.c
diff -u src/usr.bin/make/hash.c:1.70 src/usr.bin/make/hash.c:1.71
--- src/usr.bin/make/hash.c:1.70	Thu Jan 27 10:45:36 2022
+++ src/usr.bin/make/hash.c	Thu Jan 27 11:00:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.70 2022/01/27 10:45:36 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.71 2022/01/27 11:00:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -74,7 +74,7 @@
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.70 2022/01/27 10:45:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.71 2022/01/27 11:00:07 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -84,7 +84,7 @@ MAKE_RCSID("$NetBSD: hash.c,v 1.70 2022/
 
 /* This hash function matches Gosling's Emacs and java.lang.String. */
 static unsigned int
-Hash_String(const char *key, size_t *out_keylen)
+Hash_String(const char *key, const char **out_keyEnd)
 {
 	unsigned int h;
 	const char *p;
@@ -93,8 +93,7 @@ Hash_String(const char *key, size_t *out
 	for (p = key; *p != '\0'; p++)
 		h = 31 * h + (unsigned char)*p;
 
-	if (out_keylen != NULL)
-		*out_keylen = (size_t)(p - key);
+	*out_keyEnd = p;
 	return h;
 }
 
@@ -112,43 +111,22 @@ Hash_Substring(Substring key)
 }
 
 static HashEntry *
-HashTable_Find(HashTable *t, unsigned int h, const char *key)
+HashTable_Find(HashTable *t, Substring key, unsigned int h)
 {
 	HashEntry *e;
 	unsigned int chainlen = 0;
+	size_t keyLen = Substring_Length(key);
 
 #ifdef DEBUG_HASH_LOOKUP
-	DEBUG3(HASH, "HashTable_Find: %p h=%08x key=%s\n", t, h, key);
-#endif
-
-	for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) {
-		chainlen++;
-		if (e->key_hash == h && strcmp(e->key, key) == 0)
-			break;
-	}
-
-	if (chainlen > t->maxchain)
-		t->maxchain = chainlen;
-
-	return e;
-}
-
-static HashEntry *
-HashTable_FindEntryBySubstring(HashTable *t, Substring key, unsigned int h)
-{
-	HashEntry *e;
-	unsigned int chainlen = 0;
-
-#ifdef DEBUG_HASH_LOOKUP
-	DEBUG4(HASH, "HashTable_FindEntryBySubstring: %p h=%08x key=%.*s\n",
-	t, h, (int)Substring_Length(key), key.start);
+	DEBUG4(HASH, "HashTable_Find: %p h=%08x key=%.*s\n",
+	t, h, (int)keyLen, key.start);
 #endif
 
 	for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) {
 		chainlen++;
 		if (e->key_hash == h &&
-		strncmp(e->key, key.start, Substring_Length(key)) == 0 &&
-		e->key[Substring_Length(key)] == '\0')
+		strncmp(e->key, key.start, keyLen) == 0 &&
+		e->key[keyLen] == '\0')
 			break;
 	}
 
@@ -203,8 +181,9 @@ HashTable_Done(HashTable *t)
 HashEntry *
 HashTable_FindEntry(HashTable *t, const char *key)
 {
-	unsigned int h = Hash_String(key, NULL);
-	return HashTable_Find(t, h, key);
+	const char *keyEnd;
+	unsigned int h = Hash_String(key, );
+	return HashTable_Find(t, Substring_Init(key, keyEnd), h);
 }
 
 /* Find the value corresponding to the key, or return NULL. */
@@ -222,7 +201,7 @@ HashTable_FindValue(HashTable *t, const 
 void *
 HashTable_FindValueBySubstringHash(HashTable *t, Substring key, unsigned int h)
 {
-	HashEntry *he = HashTable_FindEntryBySubstring(t, key, h);
+	HashEntry *he = HashTable_Find(t, key, h);
 	return he != NULL ? he->value : NULL;
 }
 
@@ -270,9 +249,9 @@ HashTable_Enlarge(HashTable *t)
 HashEntry *
 HashTable_CreateEntry(HashTable *t, const char *key, bool *out_isNew)
 {
-	size_t keylen;
-	unsigned int h = Hash_String(key, );
-	HashEntry *he = HashTable_Find(t, h, key);
+	const char *keyEnd;
+	unsigned int h = Hash_String(key, );
+	HashEntry *he = HashTable_Find(t, Substring_Init(key, keyEnd), h);
 
 	if (he != NULL) {
 		if (out_isNew != NULL)
@@ -283,10 +262,10 @@ HashTable_CreateEntry(HashTable *t, cons
 	if (t->numEntries >= rebuildLimit * t->bucketsSize)
 		HashTable_Enlarge(t);
 
-	he = bmake_malloc(sizeof *he + keylen);
+	he = bmake_malloc(sizeof *he + (size_t)(keyEnd - key));
 	he->value = NULL;
 	he->key_hash = h;
-	memcpy(he->key, key, keylen + 1);
+	memcpy(he->key, key, (size_t)(keyEnd - key) + 1);
 
 	he->next = t->buckets[h & t->bucketsMask];
 	t->buckets[h & t->bucketsMask] = he;



CVS commit: src/usr.bin/make

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 11:00:07 UTC 2022

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

Log Message:
make: merge duplicate code for finding an entry in a hash table

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/make/hash.c

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



CVS commit: src/usr.bin/make

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 10:45:36 UTC 2022

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

Log Message:
make: replace HashEntry_KeyEquals with strncmp

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/make/hash.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/hash.c
diff -u src/usr.bin/make/hash.c:1.69 src/usr.bin/make/hash.c:1.70
--- src/usr.bin/make/hash.c:1.69	Mon Dec 27 19:06:07 2021
+++ src/usr.bin/make/hash.c	Thu Jan 27 10:45:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.69 2021/12/27 19:06:07 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.70 2022/01/27 10:45:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -74,7 +74,7 @@
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.69 2021/12/27 19:06:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.70 2022/01/27 10:45:36 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -133,18 +133,6 @@ HashTable_Find(HashTable *t, unsigned in
 	return e;
 }
 
-static bool
-HashEntry_KeyEquals(const HashEntry *he, Substring key)
-{
-	const char *heKey, *p;
-
-	heKey = he->key;
-	for (p = key.start; p != key.end; p++, heKey++)
-		if (*p != *heKey || *heKey == '\0')
-			return false;
-	return *heKey == '\0';
-}
-
 static HashEntry *
 HashTable_FindEntryBySubstring(HashTable *t, Substring key, unsigned int h)
 {
@@ -158,7 +146,9 @@ HashTable_FindEntryBySubstring(HashTable
 
 	for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) {
 		chainlen++;
-		if (e->key_hash == h && HashEntry_KeyEquals(e, key))
+		if (e->key_hash == h &&
+		strncmp(e->key, key.start, Substring_Length(key)) == 0 &&
+		e->key[Substring_Length(key)] == '\0')
 			break;
 	}
 



CVS commit: src/usr.bin/make

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 10:45:36 UTC 2022

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

Log Message:
make: replace HashEntry_KeyEquals with strncmp

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/make/hash.c

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



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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 10:42:02 UTC 2022

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

Log Message:
tests/make: test hash code collisions of variable names

In HashEntry_KeyEquals, the line 'return false' was not covered by any
tests before.  Since it is an edge case that two variable names (or
other keys) have the same 32-bit hash code and still differ, better test
for that edge case explicitly since a bug in this place would be rare
and hard to find.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varname.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/unit-tests/varname.mk
diff -u src/usr.bin/make/unit-tests/varname.mk:1.8 src/usr.bin/make/unit-tests/varname.mk:1.9
--- src/usr.bin/make/unit-tests/varname.mk:1.8	Mon Nov  2 22:59:48 2020
+++ src/usr.bin/make/unit-tests/varname.mk	Thu Jan 27 10:42:02 2022
@@ -1,4 +1,4 @@
-# $NetBSD: varname.mk,v 1.8 2020/11/02 22:59:48 rillig Exp $
+# $NetBSD: varname.mk,v 1.9 2022/01/27 10:42:02 rillig Exp $
 #
 # Tests for special variables, such as .MAKE or .PARSEDIR.
 # And for variable names in general.
@@ -41,4 +41,46 @@ ${VARNAME}=	try3
 
 .MAKEFLAGS: -d0
 
+# All variable names of a scope are stored in the same hash table, using a
+# simple hash function.  Ensure that HashEntry_KeyEquals handles collisions
+# correctly and that the correct variable is looked up.  The strings "0x" and
+# "1Y" have the same hash code, as 31 * '0' + 'x' == 31 * '1' + 'Y'.
+V.0x=	0x
+V.1Y=	1Y
+.if ${V.0x} != "0x" || ${V.1Y} != "1Y"
+.  error
+.endif
+
+# The string "ASDZguv", when used as a prefix of a variable name, keeps the
+# hash code unchanged, its own hash code is 0.
+ASDZguvV.0x=	0x
+ASDZguvV.1Y=	1Y
+.if ${ASDZguvV.0x} != "0x"
+.  error
+.elif ${ASDZguvV.1Y} != "1Y"
+.  error
+.endif
+
+# Ensure that variables with the same hash code whose name is a prefix of the
+# other can be accessed.  In this case, the shorter variable name is defined
+# first to make it appear later in the bucket of the hash table.
+ASDZguv=	once
+ASDZguvASDZguv=	twice
+.if ${ASDZguv} != "once"
+.  error
+.elif ${ASDZguvASDZguv} != "twice"
+.  error
+.endif
+
+# Ensure that variables with the same hash code whose name is a prefix of the
+# other can be accessed.  In this case, the longer variable name is defined
+# first to make it appear later in the bucket of the hash table.
+ASDZguvASDZguv.param=	twice
+ASDZguv.param=		once
+.if ${ASDZguv.param} != "once"
+.  error
+.elif ${ASDZguvASDZguv.param} != "twice"
+.  error
+.endif
+
 all:



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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 10:42:02 UTC 2022

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

Log Message:
tests/make: test hash code collisions of variable names

In HashEntry_KeyEquals, the line 'return false' was not covered by any
tests before.  Since it is an edge case that two variable names (or
other keys) have the same 32-bit hash code and still differ, better test
for that edge case explicitly since a bug in this place would be rare
and hard to find.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varname.mk

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



CVS commit: src/usr.bin/make

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 10:34:55 UTC 2022

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

Log Message:
make: remove trailing whitespace, break lines

No binary change, except for assertion line numbers.


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



CVS commit: src/usr.bin/make

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 10:34:55 UTC 2022

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

Log Message:
make: remove trailing whitespace, break lines

No binary change, except for assertion line numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.656 -r1.657 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.656 src/usr.bin/make/parse.c:1.657
--- src/usr.bin/make/parse.c:1.656	Thu Jan 27 06:02:59 2022
+++ src/usr.bin/make/parse.c	Thu Jan 27 10:34:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.656 2022/01/27 06:02:59 sjg Exp $	*/
+/*	$NetBSD: parse.c,v 1.657 2022/01/27 10:34:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.656 2022/01/27 06:02:59 sjg Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.657 2022/01/27 10:34:55 rillig Exp $");
 
 /*
  * A file being read.
@@ -1294,7 +1294,6 @@ LinkVarToTargets(VarAssign *var)
 
 	for (ln = targets->first; ln != NULL; ln = ln->next)
 		LinkSourceVar(ln->datum, var);
-	
 }
 
 static bool
@@ -1314,7 +1313,8 @@ ParseDependencySourcesMundane(char *star
 			 * Check if this makefile has disabled
 			 * setting local variables.
 			 */
-			bool target_vars = GetBooleanExpr("${.MAKE.TARGET_LOCAL_VARIABLES}", true);
+			bool target_vars = GetBooleanExpr(
+			"${.MAKE.TARGET_LOCAL_VARIABLES}", true);
 
 			if (target_vars)
 LinkVarToTargets();
@@ -1322,7 +1322,7 @@ ParseDependencySourcesMundane(char *star
 			if (target_vars)
 return true;
 		}
-			
+
 		/*
 		 * The targets take real sources, so we must beware of archive
 		 * specifications (i.e. things with left parentheses in them)
@@ -1735,7 +1735,7 @@ Parse_Var_Keep(VarAssign *var, GNode *sc
 		FStr_Done();
 	}
 }
-	   
+
 static void
 Parse_Var(VarAssign *var, GNode *scope)
 {



CVS commit: src/usr.sbin/cpuctl/arch

2022-01-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan 27 09:53:43 UTC 2022

Modified Files:
src/usr.sbin/cpuctl/arch: i386.c

Log Message:
Remove debug code and simplify. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/usr.sbin/cpuctl/arch/i386.c

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

Modified files:

Index: src/usr.sbin/cpuctl/arch/i386.c
diff -u src/usr.sbin/cpuctl/arch/i386.c:1.125 src/usr.sbin/cpuctl/arch/i386.c:1.126
--- src/usr.sbin/cpuctl/arch/i386.c:1.125	Thu Jan 13 16:02:44 2022
+++ src/usr.sbin/cpuctl/arch/i386.c	Thu Jan 27 09:53:43 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386.c,v 1.125 2022/01/13 16:02:44 msaitoh Exp $	*/
+/*	$NetBSD: i386.c,v 1.126 2022/01/27 09:53:43 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: i386.c,v 1.125 2022/01/13 16:02:44 msaitoh Exp $");
+__RCSID("$NetBSD: i386.c,v 1.126 2022/01/27 09:53:43 msaitoh Exp $");
 #endif /* not lint */
 
 #include 
@@ -2248,32 +2248,14 @@ identifycpu(int fd, const char *cpuname)
 			CPUID_AMD_ENCMEM_FLAGS, descs[0]);
 		}
 	} else if (cpu_vendor == CPUVENDOR_INTEL) {
-		int32_t bi_index;
-
-		for (bi_index = 1; bi_index <= ci->ci_max_cpuid; bi_index++) {
-			x86_cpuid(bi_index, descs);
-			switch (bi_index) {
-			case 0x0a:
-print_bits(cpuname, "Perfmon-eax",
-CPUID_PERF_FLAGS0, descs[0]);
-print_bits(cpuname, "Perfmon-ebx",
-CPUID_PERF_FLAGS1, descs[1]);
-print_bits(cpuname, "Perfmon-edx",
-CPUID_PERF_FLAGS3, descs[3]);
-break;
-			default:
-#if 0
-aprint_verbose("%s: basic %08x-eax %08x\n",
-cpuname, bi_index, descs[0]);
-aprint_verbose("%s: basic %08x-ebx %08x\n",
-cpuname, bi_index, descs[1]);
-aprint_verbose("%s: basic %08x-ecx %08x\n",
-cpuname, bi_index, descs[2]);
-aprint_verbose("%s: basic %08x-edx %08x\n",
-cpuname, bi_index, descs[3]);
-#endif
-break;
-			}
+		if (ci->ci_max_cpuid >= 0x0a) {
+			x86_cpuid(0x0a, descs);
+			print_bits(cpuname, "Perfmon-eax",
+			CPUID_PERF_FLAGS0, descs[0]);
+			print_bits(cpuname, "Perfmon-ebx",
+			CPUID_PERF_FLAGS1, descs[1]);
+			print_bits(cpuname, "Perfmon-edx",
+			CPUID_PERF_FLAGS3, descs[3]);
 		}
 	}
 



CVS commit: src/usr.sbin/cpuctl/arch

2022-01-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan 27 09:53:43 UTC 2022

Modified Files:
src/usr.sbin/cpuctl/arch: i386.c

Log Message:
Remove debug code and simplify. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/usr.sbin/cpuctl/arch/i386.c

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