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

2020-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 28 01:40:43 UTC 2020

Modified Files:
src/sys/arch/sh3/include: cputypes.h

Log Message:
_LKM -> _MODULE


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sh3/include/cputypes.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/sh3/include/cputypes.h
diff -u src/sys/arch/sh3/include/cputypes.h:1.13 src/sys/arch/sh3/include/cputypes.h:1.14
--- src/sys/arch/sh3/include/cputypes.h:1.13	Sat Jul 25 22:59:55 2020
+++ src/sys/arch/sh3/include/cputypes.h	Tue Jul 28 01:40:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cputypes.h,v 1.13 2020/07/25 22:59:55 uwe Exp $	*/
+/*	$NetBSD: cputypes.h,v 1.14 2020/07/28 01:40:43 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -33,8 +33,8 @@
 
 #if defined(_KERNEL_OPT)
 #include "opt_cputype.h"
-#elif defined(_LKM)
-/* If building an LKM, include both SH3 and SH4 support. */
+#elif defined(_MODULE)
+/* If building a module, include both SH3 and SH4 support. */
 #define	SH3
 #define	SH4
 #endif



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

2020-07-27 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Jul 28 00:48:00 UTC 2020

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

Log Message:
Use -r for export.mk to minimize interference


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

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.70 src/usr.bin/make/unit-tests/Makefile:1.71
--- src/usr.bin/make/unit-tests/Makefile:1.70	Mon Jul 27 20:46:17 2020
+++ src/usr.bin/make/unit-tests/Makefile	Tue Jul 28 00:48:00 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.70 2020/07/27 20:46:17 rillig Exp $
+# $NetBSD: Makefile,v 1.71 2020/07/28 00:48:00 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -88,6 +88,7 @@ ENV.varmisc+=		FROM_ENV_AFTER=env
 # Override make flags for some of the tests; default is -k.
 FLAGS.doterror=		# none
 FLAGS.envfirst=		-e
+FLAGS.export=		-r
 FLAGS.order=		-j1
 FLAGS.vardebug=		-k -dv FROM_CMDLINE=
 



CVS commit: src/sys/arch

2020-07-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Jul 28 00:35:38 UTC 2020

Modified Files:
src/sys/arch/evbmips/cavium: machdep.c
src/sys/arch/mips/cavium: octeon_cpunode.c octeonvar.h
src/sys/arch/mips/mips: locore_octeon.S

Log Message:
Change cpus_booted back to a simple variable instead of a kcpuset.
octeon_cpu_spinup() was trying to set CPU status immediately on kernel
startup _well_ before the kcpuset was initialised.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/evbmips/cavium/machdep.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/mips/cavium/octeon_cpunode.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/mips/cavium/octeonvar.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/mips/locore_octeon.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/evbmips/cavium/machdep.c
diff -u src/sys/arch/evbmips/cavium/machdep.c:1.21 src/sys/arch/evbmips/cavium/machdep.c:1.22
--- src/sys/arch/evbmips/cavium/machdep.c:1.21	Wed Jul 22 13:24:17 2020
+++ src/sys/arch/evbmips/cavium/machdep.c	Tue Jul 28 00:35:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.21 2020/07/22 13:24:17 simonb Exp $	*/
+/*	$NetBSD: machdep.c,v 1.22 2020/07/28 00:35:38 simonb Exp $	*/
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -114,7 +114,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.21 2020/07/22 13:24:17 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.22 2020/07/28 00:35:38 simonb Exp $");
 
 #include 
 #include 
@@ -457,10 +457,6 @@ int	waittime = -1;
 void
 cpu_startup(void)
 {
-#ifdef MULTIPROCESSOR
-	// Create a kcpuset so we can see on which CPUs the kernel was started.
-	kcpuset_create(_booted, true);
-#endif
 
 	/*
 	 * Do the common startup items.

Index: src/sys/arch/mips/cavium/octeon_cpunode.c
diff -u src/sys/arch/mips/cavium/octeon_cpunode.c:1.17 src/sys/arch/mips/cavium/octeon_cpunode.c:1.18
--- src/sys/arch/mips/cavium/octeon_cpunode.c:1.17	Wed Jul 22 15:01:18 2020
+++ src/sys/arch/mips/cavium/octeon_cpunode.c	Tue Jul 28 00:35:38 2020
@@ -29,7 +29,7 @@
 #define __INTR_PRIVATE
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.17 2020/07/22 15:01:18 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.18 2020/07/28 00:35:38 simonb Exp $");
 
 #include "locators.h"
 #include "cpunode.h"
@@ -81,7 +81,10 @@ CFATTACH_DECL_NEW(cpunode, sizeof(struct
 CFATTACH_DECL_NEW(cpu_cpunode, 0,
 cpu_cpunode_match, cpu_cpunode_attach, NULL, NULL);
 
-kcpuset_t *cpus_booted;
+#ifdef MULTIPROCESSOR
+CTASSERT(MAXCPUS <= sizeof(uint64_t) * NBBY);
+volatile uint64_t cpus_booted = __BIT(0);	/* cpu0 is always booted */
+#endif
 
 static void wdog_cpunode_poke(void *arg);
 
@@ -125,9 +128,7 @@ cpunode_mainbus_attach(device_t parent, 
 	if (cvmctl & CP0_CVMCTL_REPUN)
 		aprint_normal(", unaligned-access ok");
 #ifdef MULTIPROCESSOR
-	uint32_t booted[1];
-	kcpuset_export_u32(cpus_booted, booted, sizeof(booted));
-	aprint_normal(", booted %#" PRIx32, booted[0]);
+	aprint_normal(", booted %#" PRIx64, cpus_booted);
 #endif
 	aprint_normal("\n");
 
@@ -308,7 +309,7 @@ cpu_cpunode_attach(device_t parent, devi
 		return;
 	}
 
-	if (!kcpuset_isset(cpus_booted, cpunum)) {
+	if (!(cpus_booted & __BIT(cpunum))) {
 		aprint_naive(" disabled\n");
 		aprint_normal(" disabled (unresponsive)\n");
 		return;

Index: src/sys/arch/mips/cavium/octeonvar.h
diff -u src/sys/arch/mips/cavium/octeonvar.h:1.16 src/sys/arch/mips/cavium/octeonvar.h:1.17
--- src/sys/arch/mips/cavium/octeonvar.h:1.16	Fri Jul 17 21:59:30 2020
+++ src/sys/arch/mips/cavium/octeonvar.h	Tue Jul 28 00:35:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeonvar.h,v 1.16 2020/07/17 21:59:30 jmcneill Exp $	*/
+/*	$NetBSD: octeonvar.h,v 1.17 2020/07/28 00:35:38 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -201,9 +201,6 @@ struct octfau_map {
 
 #ifdef _KERNEL
 extern struct octeon_config	octeon_configuration;
-#ifdef MULTIPROCESSOR
-extern kcpuset_t		*cpus_booted;
-#endif
 
 const char	*octeon_cpu_model(mips_prid_t);
 

Index: src/sys/arch/mips/mips/locore_octeon.S
diff -u src/sys/arch/mips/mips/locore_octeon.S:1.12 src/sys/arch/mips/mips/locore_octeon.S:1.13
--- src/sys/arch/mips/mips/locore_octeon.S:1.12	Sun Jul 26 07:47:27 2020
+++ src/sys/arch/mips/mips/locore_octeon.S	Tue Jul 28 00:35:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore_octeon.S,v 1.12 2020/07/26 07:47:27 simonb Exp $	*/
+/*	$NetBSD: locore_octeon.S,v 1.13 2020/07/28 00:35:38 simonb Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-RCSID("$NetBSD: locore_octeon.S,v 1.12 2020/07/26 07:47:27 simonb Exp $")
+RCSID("$NetBSD: locore_octeon.S,v 1.13 2020/07/28 00:35:38 simonb Exp $")
 
 #include "cpunode.h"			/* for NWDOG */
 #include "opt_cputype.h"
@@ -37,7 +37,7 @@ RCSID("$NetBSD: locore_octeon.S,v 1.12 2
 #include 
 

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

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jul 28 00:13:29 UTC 2020

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

Log Message:
make(1): add test for modifier part with unbalanced braces


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/moderrs.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/moderrs.exp
diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.5 src/usr.bin/make/unit-tests/moderrs.exp:1.6
--- src/usr.bin/make/unit-tests/moderrs.exp:1.5	Sun Jul 26 14:39:46 2020
+++ src/usr.bin/make/unit-tests/moderrs.exp	Tue Jul 28 00:13:29 2020
@@ -19,6 +19,10 @@ make: Unclosed substitution for UNDEF (@
 make: Unclosed substitution for UNDEF (@ missing)
 
 1 2 3
+modloop-close:
+make: Unclosed variable specification (expecting '}') for "UNDEF" (value "1}... 2}... 3}...") modifier @
+1}... 2}... 3}...
+1}... 2}... 3}...
 Expect: 2 errors about missing ] delimiter
 make: Unclosed substitution for UNDEF (] missing)
 

Index: src/usr.bin/make/unit-tests/moderrs.mk
diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.4 src/usr.bin/make/unit-tests/moderrs.mk:1.5
--- src/usr.bin/make/unit-tests/moderrs.mk:1.4	Sun Jul 26 14:39:46 2020
+++ src/usr.bin/make/unit-tests/moderrs.mk	Tue Jul 28 00:13:29 2020
@@ -1,4 +1,4 @@
-# $Id: moderrs.mk,v 1.4 2020/07/26 14:39:46 rillig Exp $
+# $Id: moderrs.mk,v 1.5 2020/07/28 00:13:29 rillig Exp $
 #
 # various modifier error tests
 
@@ -9,6 +9,7 @@ MOD_TERM=S,V,v
 MOD_S:= ${MOD_TERM},
 
 all:	modunkn modunknV varterm vartermV modtermV modloop
+all:	modloop-close
 all:	modwords
 all:	modexclam
 
@@ -38,6 +39,17 @@ modloop:
 	@echo ${UNDEF:U1 2 3:@var@...}
 	@echo ${UNDEF:U1 2 3:@var@${var}@}
 
+# The closing brace after the ${var} is part of the replacement string.
+# In ParseModifierPart, braces and parentheses don't have to be balanced.
+# This is contrary to the :M, :N modifiers, where both parentheses and
+# braces must be balanced.
+# This is also contrary to the SysV modifier, where only the actually
+# used delimiter (either braces or parentheses) must be balanced.
+modloop-close:
+	@echo $@:
+	@echo ${UNDEF:U1 2 3:@var@${var}}...@
+	@echo ${UNDEF:U1 2 3:@var@${var}}...@}
+
 modwords:
 	@echo "Expect: 2 errors about missing ] delimiter"
 	@echo ${UNDEF:U1 2 3:[}



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jul 28 00:01:13 UTC 2020

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

Log Message:
make(1): remove redundant ApplyModifiersState.termc


To generate a diff of this commit:
cvs rdiff -u -r1.350 -r1.351 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.350 src/usr.bin/make/var.c:1.351
--- src/usr.bin/make/var.c:1.350	Mon Jul 27 23:56:15 2020
+++ src/usr.bin/make/var.c	Tue Jul 28 00:01:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.350 2020/07/27 23:56:15 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.351 2020/07/28 00:01:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.350 2020/07/27 23:56:15 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.351 2020/07/28 00:01:13 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.350 2020/07/27 23:56:15 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.351 2020/07/28 00:01:13 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2040,7 +2040,6 @@ VarStrftime(const char *fmt, int zulu, t
  * They parse the modifier (often until the next colon) and store the
  * updated position for the parser into st->next.
  * They take the st->val and generate st->newVal from it.
- * On success, they set st->termc to *st->next, redundantly.
  * On failure, many of them update st->missing_delim.
  */
 typedef struct {
@@ -2056,7 +2055,6 @@ typedef struct {
  * to the expression */
 const char *next;		/* The position where parsing continues
  * after the current modifier. */
-char termc;			/* Character which terminated scan */
 char missing_delim;		/* For error reporting */
 
 Byte	sep;		/* Word separator in expansions */
@@ -2107,8 +2105,6 @@ ApplyModifier_Loop(const char *mod, Appl
 	return FALSE;
 }
 
-st->termc = *st->next;
-
 args.eflags = st->eflags & (VARE_UNDEFERR | VARE_WANTRES);
 int prev_sep = st->sep;
 st->sep = ' ';		/* XXX: this is inconsistent */
@@ -2174,7 +2170,6 @@ ApplyModifier_Defined(const char *mod, A
 }
 
 st->next = p;
-st->termc = *st->next;
 
 if (st->v->flags & VAR_JUNK)
 	st->v->flags |= VAR_KEEP;
@@ -2205,7 +2200,6 @@ ApplyModifier_Gmtime(const char *mod, Ap
 	st->next = mod + 6;
 }
 st->newVal = VarStrftime(st->val, 1, utc);
-st->termc = *st->next;
 return TRUE;
 }
 
@@ -2228,7 +,6 @@ ApplyModifier_Localtime(const char *mod,
 	st->next = mod + 9;
 }
 st->newVal = VarStrftime(st->val, 0, utc);
-st->termc = *st->next;
 return TRUE;
 }
 
@@ -2243,7 +2236,6 @@ ApplyModifier_Hash(const char *mod, Appl
 
 st->newVal = VarHash(st->val);
 st->next = mod + 4;
-st->termc = *st->next;
 return TRUE;
 }
 
@@ -2264,7 +2256,6 @@ ApplyModifier_Path(const char *mod, Appl
 if (!st->newVal)
 	st->newVal = bmake_strdup(st->v->name);
 st->next = mod + 1;
-st->termc = *st->next;
 }
 
 /* :!cmd! */
@@ -2290,7 +2281,6 @@ ApplyModifier_Exclam(const char *mod, Ap
 if (emsg)
 	Error(emsg, st->val);
 
-st->termc = *st->next;
 if (st->v->flags & VAR_JUNK)
 	st->v->flags |= VAR_KEEP;
 return TRUE;
@@ -2315,7 +2305,6 @@ ApplyModifier_Range(const char *mod, App
 	st->next = mod + 5;
 }
 st->newVal = VarRange(st->val, n);
-st->termc = *st->next;
 return TRUE;
 }
 
@@ -2351,7 +2340,6 @@ ApplyModifier_Match(const char *mod, App
 	}
 }
 st->next = p;
-st->termc = *st->next;
 const char *endpat = st->next;
 
 char *pattern;
@@ -2451,7 +2439,6 @@ ApplyModifier_Subst(const char * const m
 	break;
 }
 
-st->termc = *st->next;
 st->newVal = ModifyWords(st->ctxt, st->sep, oneBigWord, st->val,
 			 ModifyWord_Subst, );
 
@@ -2504,8 +2491,6 @@ ApplyModifier_Regex(const char *mod, App
 	break;
 }
 
-st->termc = *st->next;
-
 int error = regcomp(, re, REG_EXTENDED);
 free(re);
 if (error) {
@@ -2581,7 +2566,6 @@ ApplyModifier_ToSep(const char *sep, App
 	return FALSE;		/* Found ":ts". */
 }
 
-st->termc = *st->next;
 st->newVal = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->val,
 			 ModifyWord_Copy, NULL);
 return TRUE;
@@ -2606,24 +2590,20 @@ ApplyModifier_To(const char *mod, ApplyM
 	st->newVal = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->val,
  ModifyWord_Realpath, NULL);
 	st->next = mod + 2;
-	st->termc = *st->next;
 } else if (mod[1] == 'u') {
 	char *dp = bmake_strdup(st->val);
 	for (st->newVal = dp; *dp; dp++)
 	*dp = toupper((unsigned char)*dp);
 	st->next = mod + 2;
-	st->termc = *st->next;
 } else if (mod[1] == 'l') {
 	char *dp = bmake_strdup(st->val);
 	for (st->newVal = dp; *dp; dp++)
 	*dp = 

CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 23:56:15 UTC 2020

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

Log Message:
make(1): document and reorder ApplyModifiersState


To generate a diff of this commit:
cvs rdiff -u -r1.349 -r1.350 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.349 src/usr.bin/make/var.c:1.350
--- src/usr.bin/make/var.c:1.349	Mon Jul 27 23:37:37 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 23:56:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.349 2020/07/27 23:37:37 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.350 2020/07/27 23:56:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.349 2020/07/27 23:37:37 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.350 2020/07/27 23:56:15 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.349 2020/07/27 23:37:37 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.350 2020/07/27 23:56:15 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2036,16 +2036,24 @@ VarStrftime(const char *fmt, int zulu, t
 return bmake_strdup(buf);
 }
 
+/* The ApplyModifier functions all work in the same way.
+ * They parse the modifier (often until the next colon) and store the
+ * updated position for the parser into st->next.
+ * They take the st->val and generate st->newVal from it.
+ * On success, they set st->termc to *st->next, redundantly.
+ * On failure, many of them update st->missing_delim.
+ */
 typedef struct {
-/* const parameters */
 int startc;			/* '\0' or '{' or '(' */
 int endc;
 Var *v;
 GNode *ctxt;
 VarEvalFlags eflags;
 
-/* read-write */
-char *val;
+char *val;			/* The value of the expression before the
+ * modifier is applied */
+char *newVal;		/* The new value after applying the modifier
+ * to the expression */
 const char *next;		/* The position where parsing continues
  * after the current modifier. */
 char termc;			/* Character which terminated scan */
@@ -2058,8 +2066,6 @@ typedef struct {
  * usual behaviour of treating it as
  * several space-separated words). */
 
-/* result */
-char *newVal;		/* New value to return */
 } ApplyModifiersState;
 
 /* we now have some modifiers with long names */
@@ -3070,7 +3076,7 @@ ApplyModifiers(char *val, const char * c
 {
 ApplyModifiersState st = {
 	startc, endc, v, ctxt, eflags,
-	val, tstr, '\0', '\0', ' ', FALSE, NULL
+	val, NULL, NULL, '\0', '\0', ' ', FALSE
 };
 
 const char *p = tstr;



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 23:37:38 UTC 2020

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

Log Message:
make(1): rename ApplyModifiersState.nstr and newStr

The old names were too easy to confuse.  In Var_Parse, nstr is indeed
used for the "new string", but that was misleading in ApplyModifiers,
especially since there was another variable called newStr.

The new variable names focus on the purpose of the variables, not on
their data types.


To generate a diff of this commit:
cvs rdiff -u -r1.348 -r1.349 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.348 src/usr.bin/make/var.c:1.349
--- src/usr.bin/make/var.c:1.348	Mon Jul 27 23:24:55 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 23:37:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.348 2020/07/27 23:24:55 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.349 2020/07/27 23:37:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.348 2020/07/27 23:24:55 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.349 2020/07/27 23:37:37 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.348 2020/07/27 23:24:55 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.349 2020/07/27 23:37:37 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2045,7 +2045,7 @@ typedef struct {
 VarEvalFlags eflags;
 
 /* read-write */
-char *nstr;
+char *val;
 const char *next;		/* The position where parsing continues
  * after the current modifier. */
 char termc;			/* Character which terminated scan */
@@ -2059,7 +2059,7 @@ typedef struct {
  * several space-separated words). */
 
 /* result */
-char *newStr;		/* New value to return */
+char *newVal;		/* New value to return */
 } ApplyModifiersState;
 
 /* we now have some modifiers with long names */
@@ -2106,7 +2106,7 @@ ApplyModifier_Loop(const char *mod, Appl
 args.eflags = st->eflags & (VARE_UNDEFERR | VARE_WANTRES);
 int prev_sep = st->sep;
 st->sep = ' ';		/* XXX: this is inconsistent */
-st->newStr = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->nstr,
+st->newVal = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->val,
 			 ModifyWord_Loop, );
 st->sep = prev_sep;
 Var_Delete(args.tvar, st->ctxt);
@@ -2173,9 +2173,9 @@ ApplyModifier_Defined(const char *mod, A
 if (st->v->flags & VAR_JUNK)
 	st->v->flags |= VAR_KEEP;
 if (neflags & VARE_WANTRES) {
-	st->newStr = Buf_Destroy(, FALSE);
+	st->newVal = Buf_Destroy(, FALSE);
 } else {
-	st->newStr = st->nstr;
+	st->newVal = st->val;
 	Buf_Destroy(, TRUE);
 }
 }
@@ -2198,7 +2198,7 @@ ApplyModifier_Gmtime(const char *mod, Ap
 	utc = 0;
 	st->next = mod + 6;
 }
-st->newStr = VarStrftime(st->nstr, 1, utc);
+st->newVal = VarStrftime(st->val, 1, utc);
 st->termc = *st->next;
 return TRUE;
 }
@@ -2221,7 +2221,7 @@ ApplyModifier_Localtime(const char *mod,
 	utc = 0;
 	st->next = mod + 9;
 }
-st->newStr = VarStrftime(st->nstr, 0, utc);
+st->newVal = VarStrftime(st->val, 0, utc);
 st->termc = *st->next;
 return TRUE;
 }
@@ -2235,7 +2235,7 @@ ApplyModifier_Hash(const char *mod, Appl
 	return FALSE;
 }
 
-st->newStr = VarHash(st->nstr);
+st->newVal = VarHash(st->val);
 st->next = mod + 4;
 st->termc = *st->next;
 return TRUE;
@@ -2249,14 +2249,14 @@ ApplyModifier_Path(const char *mod, Appl
 	st->v->flags |= VAR_KEEP;
 GNode *gn = Targ_FindNode(st->v->name, TARG_NOCREATE);
 if (gn == NULL || gn->type & OP_NOPATH) {
-	st->newStr = NULL;
+	st->newVal = NULL;
 } else if (gn->path) {
-	st->newStr = bmake_strdup(gn->path);
+	st->newVal = bmake_strdup(gn->path);
 } else {
-	st->newStr = Dir_FindFile(st->v->name, Suff_FindPath(gn));
+	st->newVal = Dir_FindFile(st->v->name, Suff_FindPath(gn));
 }
-if (!st->newStr)
-	st->newStr = bmake_strdup(st->v->name);
+if (!st->newVal)
+	st->newVal = bmake_strdup(st->v->name);
 st->next = mod + 1;
 st->termc = *st->next;
 }
@@ -2276,13 +2276,13 @@ ApplyModifier_Exclam(const char *mod, Ap
 
 const char *emsg = NULL;
 if (st->eflags & VARE_WANTRES)
-	st->newStr = Cmd_Exec(cmd, );
+	st->newVal = Cmd_Exec(cmd, );
 else
-	st->newStr = varNoError;
+	st->newVal = varNoError;
 free(cmd);
 
 if (emsg)
-	Error(emsg, st->nstr);
+	Error(emsg, st->val);
 
 st->termc = *st->next;
 if (st->v->flags & VAR_JUNK)
@@ -2308,7 +2308,7 @@ ApplyModifier_Range(const char *mod, App
 	n = 0;
 	st->next = mod + 5;
 }
-st->newStr = VarRange(st->nstr, n);
+st->newVal = VarRange(st->val, n);
 st->termc = *st->next;
 return TRUE;
 }
@@ -2380,11 +2380,11 @@ 

CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 23:24:55 UTC 2020

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

Log Message:
make(1): rename ApplyModifiersState.cp to next

The name "next" is more descriptive than a mere "cp".  It's easy to look
up the type of the variable, but not so easy to guess the purpose of the
variable, therefore the new name concentrates on the purpose.


To generate a diff of this commit:
cvs rdiff -u -r1.347 -r1.348 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.347 src/usr.bin/make/var.c:1.348
--- src/usr.bin/make/var.c:1.347	Mon Jul 27 23:04:18 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 23:24:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.347 2020/07/27 23:04:18 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.348 2020/07/27 23:24:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.347 2020/07/27 23:04:18 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.348 2020/07/27 23:24:55 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.347 2020/07/27 23:04:18 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.348 2020/07/27 23:24:55 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2046,7 +2046,7 @@ typedef struct {
 
 /* read-write */
 char *nstr;
-const char *cp;		/* The position where parsing continues
+const char *next;		/* The position where parsing continues
  * after the current modifier. */
 char termc;			/* Character which terminated scan */
 char missing_delim;		/* For error reporting */
@@ -2085,23 +2085,23 @@ ApplyModifier_Loop(const char *mod, Appl
 ModifyWord_LoopArgs args;
 
 args.ctx = st->ctxt;
-st->cp = mod + 1;
+st->next = mod + 1;
 char delim = '@';
-args.tvar = ParseModifierPart(>cp, delim, st->eflags & ~VARE_WANTRES,
+args.tvar = ParseModifierPart(>next, delim, st->eflags & ~VARE_WANTRES,
   st->ctxt, NULL, NULL, NULL);
 if (args.tvar == NULL) {
 	st->missing_delim = delim;
 	return FALSE;
 }
 
-args.str = ParseModifierPart(>cp, delim, st->eflags & ~VARE_WANTRES,
+args.str = ParseModifierPart(>next, delim, st->eflags & ~VARE_WANTRES,
  st->ctxt, NULL, NULL, NULL);
 if (args.str == NULL) {
 	st->missing_delim = delim;
 	return FALSE;
 }
 
-st->termc = *st->cp;
+st->termc = *st->next;
 
 args.eflags = st->eflags & (VARE_UNDEFERR | VARE_WANTRES);
 int prev_sep = st->sep;
@@ -2167,8 +2167,8 @@ ApplyModifier_Defined(const char *mod, A
 	}
 }
 
-st->cp = p;
-st->termc = *st->cp;
+st->next = p;
+st->termc = *st->next;
 
 if (st->v->flags & VAR_JUNK)
 	st->v->flags |= VAR_KEEP;
@@ -2185,7 +2185,7 @@ static Boolean
 ApplyModifier_Gmtime(const char *mod, ApplyModifiersState *st)
 {
 if (!ModMatchEq(mod, "gmtime", st->endc)) {
-	st->cp = mod + 1;
+	st->next = mod + 1;
 	return FALSE;
 }
 
@@ -2193,13 +2193,13 @@ ApplyModifier_Gmtime(const char *mod, Ap
 if (mod[6] == '=') {
 	char *ep;
 	utc = strtoul(mod + 7, , 10);
-	st->cp = ep;
+	st->next = ep;
 } else {
 	utc = 0;
-	st->cp = mod + 6;
+	st->next = mod + 6;
 }
 st->newStr = VarStrftime(st->nstr, 1, utc);
-st->termc = *st->cp;
+st->termc = *st->next;
 return TRUE;
 }
 
@@ -2208,7 +2208,7 @@ static Boolean
 ApplyModifier_Localtime(const char *mod, ApplyModifiersState *st)
 {
 if (!ModMatchEq(mod, "localtime", st->endc)) {
-	st->cp = mod + 1;
+	st->next = mod + 1;
 	return FALSE;
 }
 
@@ -2216,13 +2216,13 @@ ApplyModifier_Localtime(const char *mod,
 if (mod[9] == '=') {
 	char *ep;
 	utc = strtoul(mod + 10, , 10);
-	st->cp = ep;
+	st->next = ep;
 } else {
 	utc = 0;
-	st->cp = mod + 9;
+	st->next = mod + 9;
 }
 st->newStr = VarStrftime(st->nstr, 0, utc);
-st->termc = *st->cp;
+st->termc = *st->next;
 return TRUE;
 }
 
@@ -2231,13 +2231,13 @@ static Boolean
 ApplyModifier_Hash(const char *mod, ApplyModifiersState *st)
 {
 if (!ModMatch(mod, "hash", st->endc)) {
-	st->cp = mod + 1;
+	st->next = mod + 1;
 	return FALSE;
 }
 
 st->newStr = VarHash(st->nstr);
-st->cp = mod + 4;
-st->termc = *st->cp;
+st->next = mod + 4;
+st->termc = *st->next;
 return TRUE;
 }
 
@@ -2257,17 +2257,17 @@ ApplyModifier_Path(const char *mod, Appl
 }
 if (!st->newStr)
 	st->newStr = bmake_strdup(st->v->name);
-st->cp = mod + 1;
-st->termc = *st->cp;
+st->next = mod + 1;
+st->termc = *st->next;
 }
 
 /* :!cmd! */
 static Boolean
 ApplyModifier_Exclam(const char *mod, ApplyModifiersState *st)
 {
-st->cp = mod + 1;
+st->next = mod + 1;
 char delim = '!';
-char *cmd = ParseModifierPart(>cp, 

CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 23:04:18 UTC 2020

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

Log Message:
make(1): in ApplyModifier_Match, use short local variable name


To generate a diff of this commit:
cvs rdiff -u -r1.346 -r1.347 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.346 src/usr.bin/make/var.c:1.347
--- src/usr.bin/make/var.c:1.346	Mon Jul 27 22:59:49 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 23:04:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.346 2020/07/27 22:59:49 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.347 2020/07/27 23:04:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.346 2020/07/27 22:59:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.347 2020/07/27 23:04:18 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.346 2020/07/27 22:59:49 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.347 2020/07/27 23:04:18 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2325,34 +2325,33 @@ ApplyModifier_Match(const char *mod, App
  * XXX This will likely not work right if $() and ${} are intermixed.
  */
 int nest = 1;
-for (st->cp = mod + 1;
-	 *st->cp != '\0' && !(*st->cp == ':' && nest == 1);
-	 st->cp++) {
-	if (*st->cp == '\\' &&
-	(st->cp[1] == ':' || st->cp[1] == st->endc ||
-	 st->cp[1] == st->startc)) {
+const char *p;
+for (p = mod + 1; *p != '\0' && !(*p == ':' && nest == 1); p++) {
+	if (*p == '\\' &&
+	(p[1] == ':' || p[1] == st->endc || p[1] == st->startc)) {
 	if (!needSubst)
 		copy = TRUE;
-	st->cp++;
+	p++;
 	continue;
 	}
-	if (*st->cp == '$')
+	if (*p == '$')
 	needSubst = TRUE;
-	if (*st->cp == '(' || *st->cp == '{')
+	if (*p == '(' || *p == '{')
 	++nest;
-	if (*st->cp == ')' || *st->cp == '}') {
+	if (*p == ')' || *p == '}') {
 	--nest;
 	if (nest == 0)
 		break;
 	}
 }
+st->cp = p;
 st->termc = *st->cp;
 const char *endpat = st->cp;
 
 char *pattern;
 if (copy) {
 	/* Compress the \:'s out of the pattern. */
-	pattern = bmake_malloc(st->cp - (mod + 1) + 1);
+	pattern = bmake_malloc(endpat - (mod + 1) + 1);
 	char *dst = pattern;
 	const char *src = mod + 1;
 	for (; src < endpat; src++, dst++) {



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 22:59:49 UTC 2020

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

Log Message:
make(1): in ModifyWord_Match, use different variables

Using the same registers or memory locations for different variables is
the job of the register allocator, not the programmer.  For humans, that
practice is rather confusing.


To generate a diff of this commit:
cvs rdiff -u -r1.345 -r1.346 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.345 src/usr.bin/make/var.c:1.346
--- src/usr.bin/make/var.c:1.345	Mon Jul 27 22:50:01 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 22:59:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.345 2020/07/27 22:50:01 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.346 2020/07/27 22:59:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.345 2020/07/27 22:50:01 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.346 2020/07/27 22:59:49 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.345 2020/07/27 22:50:01 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.346 2020/07/27 22:59:49 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2349,22 +2349,21 @@ ApplyModifier_Match(const char *mod, App
 st->termc = *st->cp;
 const char *endpat = st->cp;
 
-char *pattern = NULL;
+char *pattern;
 if (copy) {
 	/* Compress the \:'s out of the pattern. */
 	pattern = bmake_malloc(st->cp - (mod + 1) + 1);
-	char *cp2;
-	for (cp2 = pattern, st->cp = mod + 1;
-	 st->cp < endpat;
-	 st->cp++, cp2++) {
-	if ((*st->cp == '\\') && (st->cp+1 < endpat) &&
+	char *dst = pattern;
+	const char *src = mod + 1;
+	for (; src < endpat; src++, dst++) {
+	if (src[0] == '\\' && src + 1 < endpat &&
 		/* XXX: st->startc is missing here; see above */
-		(st->cp[1] == ':' || st->cp[1] == st->endc))
-		st->cp++;
-	*cp2 = *st->cp;
+		(src[1] == ':' || src[1] == st->endc))
+		src++;
+	*dst = *src;
 	}
-	*cp2 = '\0';
-	endpat = cp2;
+	*dst = '\0';
+	endpat = dst;
 } else {
 	/*
 	 * Either Var_Subst or ModifyWords will need a
@@ -2372,15 +2371,18 @@ ApplyModifier_Match(const char *mod, App
 	 */
 	pattern = bmake_strndup(mod + 1, endpat - (mod + 1));
 }
+
 if (needSubst) {
 	/* pattern contains embedded '$', so use Var_Subst to expand it. */
 	char *old_pattern = pattern;
 	pattern = Var_Subst(NULL, pattern, st->ctxt, st->eflags);
 	free(old_pattern);
 }
+
 if (DEBUG(VAR))
 	fprintf(debug_file, "Pattern[%s] for [%s] is [%s]\n",
 	st->v->name, st->nstr, pattern);
+
 ModifyWordsCallback callback = mod[0] == 'M'
 	? ModifyWord_Match : ModifyWord_NoMatch;
 st->newStr = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->nstr,



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 22:50:01 UTC 2020

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

Log Message:
make(1): replace comment in ApplyModifier_Match with code


To generate a diff of this commit:
cvs rdiff -u -r1.344 -r1.345 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.344 src/usr.bin/make/var.c:1.345
--- src/usr.bin/make/var.c:1.344	Mon Jul 27 22:30:00 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 22:50:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.344 2020/07/27 22:30:00 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.345 2020/07/27 22:50:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.344 2020/07/27 22:30:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.345 2020/07/27 22:50:01 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.344 2020/07/27 22:30:00 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.345 2020/07/27 22:50:01 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2351,19 +2351,14 @@ ApplyModifier_Match(const char *mod, App
 
 char *pattern = NULL;
 if (copy) {
-	/*
-	 * Need to compress the \:'s out of the pattern, so
-	 * allocate enough room to hold the uncompressed
-	 * pattern (note that st->cp started at mod+1, so
-	 * st->cp - mod takes the null byte into account) and
-	 * compress the pattern into the space.
-	 */
-	pattern = bmake_malloc(st->cp - mod);
+	/* Compress the \:'s out of the pattern. */
+	pattern = bmake_malloc(st->cp - (mod + 1) + 1);
 	char *cp2;
 	for (cp2 = pattern, st->cp = mod + 1;
 	 st->cp < endpat;
 	 st->cp++, cp2++) {
 	if ((*st->cp == '\\') && (st->cp+1 < endpat) &&
+		/* XXX: st->startc is missing here; see above */
 		(st->cp[1] == ':' || st->cp[1] == st->endc))
 		st->cp++;
 	*cp2 = *st->cp;



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 22:30:00 UTC 2020

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

Log Message:
make(1): remove unused lengthPtr and freePtr from ApplyModifiersState


To generate a diff of this commit:
cvs rdiff -u -r1.343 -r1.344 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.343 src/usr.bin/make/var.c:1.344
--- src/usr.bin/make/var.c:1.343	Mon Jul 27 22:24:03 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 22:30:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.343 2020/07/27 22:24:03 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.344 2020/07/27 22:30:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.343 2020/07/27 22:24:03 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.344 2020/07/27 22:30:00 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.343 2020/07/27 22:24:03 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.344 2020/07/27 22:30:00 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2043,8 +2043,6 @@ typedef struct {
 Var *v;
 GNode *ctxt;
 VarEvalFlags eflags;
-int *lengthPtr;
-void **freePtr;
 
 /* read-write */
 char *nstr;
@@ -3075,7 +3073,7 @@ ApplyModifiers(char *nstr, const char * 
 	   int * const lengthPtr, void ** const freePtr)
 {
 ApplyModifiersState st = {
-	startc, endc, v, ctxt, eflags, lengthPtr, freePtr,
+	startc, endc, v, ctxt, eflags,
 	nstr, tstr, '\0', '\0', ' ', FALSE, NULL
 };
 
@@ -3116,7 +3114,7 @@ ApplyModifiers(char *nstr, const char * 
 		int used;
 
 		st.nstr = ApplyModifiers(st.nstr, rval, 0, 0, st.v,
-  st.ctxt, st.eflags, , st.freePtr);
+  st.ctxt, st.eflags, , freePtr);
 		if (st.nstr == var_Error
 		|| (st.nstr == varNoError && (st.eflags & VARE_UNDEFERR) == 0)
 		|| strlen(rval) != (size_t) used) {
@@ -3327,13 +3325,13 @@ ApplyModifiers(char *nstr, const char * 
 	}
 
 	if (st.newStr != st.nstr) {
-	if (*st.freePtr) {
+	if (*freePtr) {
 		free(st.nstr);
-		*st.freePtr = NULL;
+		*freePtr = NULL;
 	}
 	st.nstr = st.newStr;
 	if (st.nstr != var_Error && st.nstr != varNoError) {
-		*st.freePtr = st.nstr;
+		*freePtr = st.nstr;
 	}
 	}
 	if (st.termc == '\0' && st.endc != '\0') {
@@ -3346,7 +3344,7 @@ ApplyModifiers(char *nstr, const char * 
 	p = st.cp;
 }
 out:
-*st.lengthPtr = p - tstr;
+*lengthPtr = p - tstr;
 return st.nstr;
 
 bad_modifier:
@@ -3354,12 +3352,12 @@ bad_modifier:
 	  (int)strcspn(p, ":)}"), p, st.v->name);
 
 cleanup:
-*st.lengthPtr = st.cp - tstr;
+*lengthPtr = st.cp - tstr;
 if (st.missing_delim != '\0')
 	Error("Unclosed substitution for %s (%c missing)",
 	  st.v->name, st.missing_delim);
-free(*st.freePtr);
-*st.freePtr = NULL;
+free(*freePtr);
+*freePtr = NULL;
 return var_Error;
 }
 



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 22:24:04 UTC 2020

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

Log Message:
make(1): remove unnecessary field from ApplyModifiersState


To generate a diff of this commit:
cvs rdiff -u -r1.342 -r1.343 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.342 src/usr.bin/make/var.c:1.343
--- src/usr.bin/make/var.c:1.342	Mon Jul 27 22:21:29 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 22:24:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.342 2020/07/27 22:21:29 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.343 2020/07/27 22:24:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.342 2020/07/27 22:21:29 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.343 2020/07/27 22:24:03 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.342 2020/07/27 22:21:29 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.343 2020/07/27 22:24:03 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2048,7 +2048,6 @@ typedef struct {
 
 /* read-write */
 char *nstr;
-const char *start;
 const char *cp;		/* The position where parsing continues
  * after the current modifier. */
 char termc;			/* Character which terminated scan */
@@ -3070,15 +3069,14 @@ ApplyModifier_SysV(const char *mod, Appl
  * Assignment operators (see ApplyModifier_Assign).
  */
 static char *
-ApplyModifiers(char *nstr, const char *tstr,
+ApplyModifiers(char *nstr, const char * const tstr,
 	   int const startc, int const endc,
 	   Var * const v, GNode * const ctxt, VarEvalFlags const eflags,
 	   int * const lengthPtr, void ** const freePtr)
 {
 ApplyModifiersState st = {
 	startc, endc, v, ctxt, eflags, lengthPtr, freePtr,
-	nstr, tstr, tstr,
-	'\0', '\0', ' ', FALSE, NULL
+	nstr, tstr, '\0', '\0', ' ', FALSE, NULL
 };
 
 const char *p = tstr;
@@ -3348,7 +3346,7 @@ ApplyModifiers(char *nstr, const char *t
 	p = st.cp;
 }
 out:
-*st.lengthPtr = p - st.start;
+*st.lengthPtr = p - tstr;
 return st.nstr;
 
 bad_modifier:
@@ -3356,7 +3354,7 @@ bad_modifier:
 	  (int)strcspn(p, ":)}"), p, st.v->name);
 
 cleanup:
-*st.lengthPtr = st.cp - st.start;
+*st.lengthPtr = st.cp - tstr;
 if (st.missing_delim != '\0')
 	Error("Unclosed substitution for %s (%c missing)",
 	  st.v->name, st.missing_delim);



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 22:21:29 UTC 2020

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

Log Message:
make(1): remove unnecessary variable assignment

It is not the job of an ApplyModifier function to directly manipulate the
final result of the ApplyModifiers function.  In fact, the resulting
pointer was overwritten unconditionally, in such an obvious way that the
compiler could have detected this.  GCC 5 didn't though, which reduces
the code size a bit.


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.341 src/usr.bin/make/var.c:1.342
--- src/usr.bin/make/var.c:1.341	Mon Jul 27 22:02:26 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 22:21:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.341 2020/07/27 22:02:26 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.342 2020/07/27 22:21:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.341 2020/07/27 22:02:26 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.342 2020/07/27 22:21:29 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.341 2020/07/27 22:02:26 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.342 2020/07/27 22:21:29 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2510,7 +2510,6 @@ ApplyModifier_Regex(const char *mod, App
 int error = regcomp(, re, REG_EXTENDED);
 free(re);
 if (error) {
-	*st->lengthPtr = st->cp - st->start + 1;
 	VarREError(error, , "RE substitution error");
 	free(args.replace);
 	return FALSE;



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 22:02:26 UTC 2020

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

Log Message:
make(1): move modifier character out of ApplyModifiersState

It is only used in the outer part of the loop to apply the modifiers.


To generate a diff of this commit:
cvs rdiff -u -r1.340 -r1.341 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.340 src/usr.bin/make/var.c:1.341
--- src/usr.bin/make/var.c:1.340	Mon Jul 27 21:54:25 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 22:02:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.340 2020/07/27 21:54:25 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.341 2020/07/27 22:02:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.340 2020/07/27 21:54:25 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.341 2020/07/27 22:02:26 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.340 2020/07/27 21:54:25 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.341 2020/07/27 22:02:26 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2053,7 +2053,6 @@ typedef struct {
  * after the current modifier. */
 char termc;			/* Character which terminated scan */
 char missing_delim;		/* For error reporting */
-int modifier;		/* that we are processing */
 
 Byte	sep;		/* Word separator in expansions */
 Boolean	oneBigWord;	/* TRUE if we will treat the variable as a
@@ -3080,7 +3079,7 @@ ApplyModifiers(char *nstr, const char *t
 ApplyModifiersState st = {
 	startc, endc, v, ctxt, eflags, lengthPtr, freePtr,
 	nstr, tstr, tstr,
-	'\0', '\0', 0, ' ', FALSE, NULL
+	'\0', '\0', ' ', FALSE, NULL
 };
 
 const char *p = tstr;
@@ -3144,7 +3143,8 @@ ApplyModifiers(char *nstr, const char *t
 		*p, st.nstr);
 	}
 	st.newStr = var_Error;
-	switch ((st.modifier = *p)) {
+	char modifier = *p;
+	switch (modifier) {
 	case ':':
 	{
 		int res = ApplyModifier_Assign(p, );
@@ -3230,7 +3230,7 @@ ApplyModifiers(char *nstr, const char *t
 	case 'q':
 	case 'Q':
 	if (p[1] == st.endc || p[1] == ':') {
-		st.newStr = VarQuote(st.nstr, st.modifier == 'q');
+		st.newStr = VarQuote(st.nstr, modifier == 'q');
 		st.cp = p + 1;
 		st.termc = *st.cp;
 		break;
@@ -3326,7 +3326,7 @@ ApplyModifiers(char *nstr, const char *t
 	}
 	if (DEBUG(VAR)) {
 	fprintf(debug_file, "Result[%s] of :%c is \"%s\"\n",
-		st.v->name, st.modifier, st.newStr);
+		st.v->name, modifier, st.newStr);
 	}
 
 	if (st.newStr != st.nstr) {
@@ -3342,7 +3342,7 @@ ApplyModifiers(char *nstr, const char *t
 	if (st.termc == '\0' && st.endc != '\0') {
 	Error("Unclosed variable specification (expecting '%c') "
 		"for \"%s\" (value \"%s\") modifier %c",
-		st.endc, st.v->name, st.nstr, st.modifier);
+		st.endc, st.v->name, st.nstr, modifier);
 	} else if (st.termc == ':') {
 	st.cp++;
 	}



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 21:54:25 UTC 2020

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: modmisc.exp modmisc.mk

Log Message:
make(1): replace macros with functions

Having the hidden parameter st->endc in the macro made it unnecessarily
difficult to understand the code.


To generate a diff of this commit:
cvs rdiff -u -r1.339 -r1.340 src/usr.bin/make/var.c
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/modmisc.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/var.c
diff -u src/usr.bin/make/var.c:1.339 src/usr.bin/make/var.c:1.340
--- src/usr.bin/make/var.c:1.339	Mon Jul 27 21:08:41 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 21:54:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.339 2020/07/27 21:08:41 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.340 2020/07/27 21:54:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.339 2020/07/27 21:08:41 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.340 2020/07/27 21:54:25 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.339 2020/07/27 21:08:41 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.340 2020/07/27 21:54:25 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2067,12 +2067,21 @@ typedef struct {
 } ApplyModifiersState;
 
 /* we now have some modifiers with long names */
-#define STRMOD_MATCH(s, want, n) \
-(strncmp(s, want, n) == 0 && (s[n] == st->endc || s[n] == ':'))
-#define STRMOD_MATCHX(s, want, n) \
-(strncmp(s, want, n) == 0 && \
- (s[n] == st->endc || s[n] == ':' || s[n] == '='))
-#define CHARMOD_MATCH(c) (c == st->endc || c == ':')
+static Boolean
+ModMatch(const char *mod, const char *modname, char endc)
+{
+size_t n = strlen(modname);
+return strncmp(mod, modname, n) == 0 &&
+	   (mod[n] == endc || mod[n] == ':');
+}
+
+static inline Boolean
+ModMatchEq(const char *mod, const char *modname, char endc)
+{
+size_t n = strlen(modname);
+return strncmp(mod, modname, n) == 0 &&
+	   (mod[n] == endc || mod[n] == ':' || mod[n] == '=');
+}
 
 /* :@var@...${var}...@ */
 static Boolean
@@ -2179,13 +2188,14 @@ ApplyModifier_Defined(const char *mod, A
 static Boolean
 ApplyModifier_Gmtime(const char *mod, ApplyModifiersState *st)
 {
-time_t utc;
-char *ep;
-
-st->cp = mod + 1;		/* make sure it is set */
-if (!STRMOD_MATCHX(mod, "gmtime", 6))
+if (!ModMatchEq(mod, "gmtime", st->endc)) {
+	st->cp = mod + 1;
 	return FALSE;
+}
+
+time_t utc;
 if (mod[6] == '=') {
+	char *ep;
 	utc = strtoul(mod + 7, , 10);
 	st->cp = ep;
 } else {
@@ -2201,14 +2211,14 @@ ApplyModifier_Gmtime(const char *mod, Ap
 static Boolean
 ApplyModifier_Localtime(const char *mod, ApplyModifiersState *st)
 {
-time_t utc;
-char *ep;
-
-st->cp = mod + 1;	/* make sure it is set */
-if (!STRMOD_MATCHX(mod, "localtime", 9))
+if (!ModMatchEq(mod, "localtime", st->endc)) {
+	st->cp = mod + 1;
 	return FALSE;
+}
 
+time_t utc;
 if (mod[9] == '=') {
+	char *ep;
 	utc = strtoul(mod + 10, , 10);
 	st->cp = ep;
 } else {
@@ -2224,9 +2234,11 @@ ApplyModifier_Localtime(const char *mod,
 static Boolean
 ApplyModifier_Hash(const char *mod, ApplyModifiersState *st)
 {
-st->cp = mod + 1;	/* make sure it is set */
-if (!STRMOD_MATCH(mod, "hash", 4))
+if (!ModMatch(mod, "hash", st->endc)) {
+	st->cp = mod + 1;
 	return FALSE;
+}
+
 st->newStr = VarHash(st->nstr);
 st->cp = mod + 4;
 st->termc = *st->cp;
@@ -2286,14 +2298,14 @@ ApplyModifier_Exclam(const char *mod, Ap
 static Boolean
 ApplyModifier_Range(const char *mod, ApplyModifiersState *st)
 {
-int n;
-char *ep;
-
-st->cp = mod + 1;	/* make sure it is set */
-if (!STRMOD_MATCHX(mod, "range", 5))
+if (!ModMatchEq(mod, "range", st->endc)) {
+	st->cp = mod + 1;
 	return FALSE;
+}
 
+int n;
 if (mod[5] == '=') {
+	char *ep;
 	n = strtoul(mod + 6, , 10);
 	st->cp = ep;
 } else {
@@ -2910,23 +2922,20 @@ ApplyModifier_Assign(const char *mod, Ap
 static Boolean
 ApplyModifier_Remember(const char *mod, ApplyModifiersState *st)
 {
-st->cp = mod + 1;	/* make sure it is set */
-if (!STRMOD_MATCHX(mod, "_", 1))
+if (!ModMatchEq(mod, "_", st->endc)) {
+	st->cp = mod + 1;
 	return FALSE;
+}
 
 if (mod[1] == '=') {
-	char *np;
-	int n;
-
-	st->cp++;
-	n = strcspn(st->cp, ":)}");
-	np = bmake_strndup(st->cp, n + 1);
-	np[n] = '\0';
+	size_t n = strcspn(mod + 2, ":)}");
+	char *name = bmake_strndup(mod + 2, n);
+	Var_Set(name, st->nstr, st->ctxt);
+	free(name);
 	st->cp = mod + 2 + n;
-	Var_Set(np, st->nstr, st->ctxt);
-	

CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 21:08:41 UTC 2020

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

Log Message:
make(1): use shorter variable name for parsing :D and :U


To generate a diff of this commit:
cvs rdiff -u -r1.338 -r1.339 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.338 src/usr.bin/make/var.c:1.339
--- src/usr.bin/make/var.c:1.338	Mon Jul 27 19:59:59 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 21:08:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.338 2020/07/27 19:59:59 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.339 2020/07/27 21:08:41 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.338 2020/07/27 19:59:59 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.339 2020/07/27 21:08:41 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.338 2020/07/27 19:59:59 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.339 2020/07/27 21:08:41 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2137,15 +2137,13 @@ ApplyModifier_Defined(const char *mod, A
  * The result is left in the Buffer buf.
  */
 Buf_Init(, 0);
-for (st->cp = mod + 1;
-	 *st->cp != st->endc && *st->cp != ':' && *st->cp != '\0';
-	 st->cp++) {
-	if (*st->cp == '\\' &&
-	(st->cp[1] == ':' || st->cp[1] == '$' || st->cp[1] == st->endc ||
-	 st->cp[1] == '\\')) {
-	Buf_AddByte(, st->cp[1]);
-	st->cp++;
-	} else if (*st->cp == '$') {
+const char *p = mod + 1;
+while (*p != st->endc && *p != ':' && *p != '\0') {
+	if (*p == '\\' &&
+	(p[1] == ':' || p[1] == '$' || p[1] == st->endc || p[1] == '\\')) {
+	Buf_AddByte(, p[1]);
+	p += 2;
+	} else if (*p == '$') {
 	/*
 	 * If unescaped dollar sign, assume it's a
 	 * variable substitution and recurse.
@@ -2154,15 +2152,17 @@ ApplyModifier_Defined(const char *mod, A
 	int	len;
 	void*freeIt;
 
-	cp2 = Var_Parse(st->cp, st->ctxt, neflags, , );
+	cp2 = Var_Parse(p, st->ctxt, neflags, , );
 	Buf_AddStr(, cp2);
 	free(freeIt);
-	st->cp += len - 1;
+	p += len;
 	} else {
-	Buf_AddByte(, *st->cp);
+	Buf_AddByte(, *p);
+	p++;
 	}
 }
 
+st->cp = p;
 st->termc = *st->cp;
 
 if (st->v->flags & VAR_JUNK)



CVS commit: src/tests/sys/crypto/chacha

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:59:53 UTC 2020

Modified Files:
src/tests/sys/crypto/chacha: t_chacha.c

Log Message:
It's __ARM_NEON, not __ARM_NEON__, sometimes, apparently.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/sys/crypto/chacha/t_chacha.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/sys/crypto/chacha/t_chacha.c
diff -u src/tests/sys/crypto/chacha/t_chacha.c:1.2 src/tests/sys/crypto/chacha/t_chacha.c:1.3
--- src/tests/sys/crypto/chacha/t_chacha.c:1.2	Mon Jul 27 20:51:29 2020
+++ src/tests/sys/crypto/chacha/t_chacha.c	Mon Jul 27 20:59:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_chacha.c,v 1.2 2020/07/27 20:51:29 riastradh Exp $	*/
+/*	$NetBSD: t_chacha.c,v 1.3 2020/07/27 20:59:53 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include 
 #endif
 
-#ifdef __ARM_NEON__
+#ifdef __ARM_NEON
 #include 
 #endif
 
@@ -81,7 +81,7 @@ ATF_TC_BODY(name, tc)			  \
 		atf_tc_fail("%s self-test failed", (impl)->ci_name);	  \
 }
 
-#ifdef __ARM_NEON__
+#ifdef __ARM_NEON
 CHACHA_SELFTEST(chacha_neon_selftest, _neon_impl,
 "ARM NEON ChaCha self-test")
 #endif
@@ -96,7 +96,7 @@ ATF_TP_ADD_TCS(tp)
 
 	ATF_TP_ADD_TC(tp, chacha_ref_selftest);
 
-#ifdef __ARM_NEON__
+#ifdef __ARM_NEON
 	ATF_TP_ADD_TC(tp, chacha_neon_selftest);
 #endif
 



CVS commit: src/sys/crypto/chacha/arch/arm

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:58:56 UTC 2020

Modified Files:
src/sys/crypto/chacha/arch/arm: arm_neon.h chacha_neon.c

Log Message:
Note that VSRI seems to hurt here.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/crypto/chacha/arch/arm/arm_neon.h
cvs rdiff -u -r1.4 -r1.5 src/sys/crypto/chacha/arch/arm/chacha_neon.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/crypto/chacha/arch/arm/arm_neon.h
diff -u src/sys/crypto/chacha/arch/arm/arm_neon.h:1.2 src/sys/crypto/chacha/arch/arm/arm_neon.h:1.3
--- src/sys/crypto/chacha/arch/arm/arm_neon.h:1.2	Mon Jul 27 20:58:06 2020
+++ src/sys/crypto/chacha/arch/arm/arm_neon.h	Mon Jul 27 20:58:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm_neon.h,v 1.2 2020/07/27 20:58:06 riastradh Exp $	*/
+/*	$NetBSD: arm_neon.h,v 1.3 2020/07/27 20:58:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -529,6 +529,40 @@ vsliq_n_s32(int32x4_t __vins, int32x4_t 
 #endif	/* __LITTLE_ENDIAN__ */
 #endif
 
+#if defined(__GNUC__) && !defined(__clang__)
+_INTRINSATTR
+static __inline uint32x4_t
+vsriq_n_u32(uint32x4_t __vins, uint32x4_t __vsh, uint8_t __bits)
+{
+#ifdef __aarch64__
+	return __builtin_aarch64_usri_nv4si_uuus(__vins, __vsh, __bits);
+#else
+	return (uint32x4_t)__builtin_neon_vsri_nv4si((int32x4_t)__vins,
+	(int32x4_t)__vsh, __bits);
+#endif
+}
+#elif defined(__clang__)
+#ifdef __LITTLE_ENDIAN__
+#define	vsriq_n_u32(__vins, __vsh, __bits)  \
+	(int32x4_t)__builtin_neon_vsriq_n_v((int32x4_t)(__vins),	  \
+	(int32x4_t)(__vsh), (__bits), 34)
+#else
+#define	vsliq_n_s32(__vins, __vsh, __bits) (  \
+{	  \
+	int32x4_t __tvins = (__vins);	  \
+	int32x4_t __tvsh = (__vsh);	  \
+	uint8_t __tbits = (__bits);	  \
+	int32x4_t __vins_r = __builtin_shufflevector(__tvins, __tvins,	  \
+	3,2,1,0);			  \
+	int32x4_t __vsh_r = __builtin_shufflevector(__tvsh, __tvsh,	  \
+	3,2,1,0);			  \
+	int32x4_t __r = __builtin_neon_vsriq_n_v(__tvins, __tvsh, __tbits,\
+	34);			  \
+	__builtin_shufflevector(__r, __r, 3,2,1,0);			  \
+})
+#endif
+#endif
+
 _INTRINSATTR
 static __inline void
 vst1q_u32(uint32_t *__p32, uint32x4_t __v)

Index: src/sys/crypto/chacha/arch/arm/chacha_neon.c
diff -u src/sys/crypto/chacha/arch/arm/chacha_neon.c:1.4 src/sys/crypto/chacha/arch/arm/chacha_neon.c:1.5
--- src/sys/crypto/chacha/arch/arm/chacha_neon.c:1.4	Mon Jul 27 20:58:06 2020
+++ src/sys/crypto/chacha/arch/arm/chacha_neon.c	Mon Jul 27 20:58:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: chacha_neon.c,v 1.4 2020/07/27 20:58:06 riastradh Exp $	*/
+/*	$NetBSD: chacha_neon.c,v 1.5 2020/07/27 20:58:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -36,7 +36,15 @@ static inline uint32x4_t
 vrolq_n_u32(uint32x4_t x, uint8_t n)
 {
 
+	/*
+	 * Tempting to use VSHL/VSRI instead of VSHL/VSHR/VORR, but in
+	 * practice it hurts performance at least on Cortex-A8.
+	 */
+#if 1
 	return vshlq_n_u32(x, n) | vshrq_n_u32(x, 32 - n);
+#else
+	return vsriq_n_u32(vshlq_n_u32(x, n), x, 32 - n);
+#endif
 }
 
 static inline uint32x4_t



CVS commit: src/sys/crypto/chacha/arch/arm

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:58:07 UTC 2020

Modified Files:
src/sys/crypto/chacha/arch/arm: arm_neon.h chacha_neon.c

Log Message:
Take advantage of REV32 and TBL for 16-bit and 8-bit rotations.

However, disable use of (V)TBL on armv7/aarch32 for now, because for
some reason GCC spills things to the stack despite having plenty of
free registers, which hurts performance more than it helps at least
on ARM Cortex-A8.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/chacha/arch/arm/arm_neon.h
cvs rdiff -u -r1.3 -r1.4 src/sys/crypto/chacha/arch/arm/chacha_neon.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/crypto/chacha/arch/arm/arm_neon.h
diff -u src/sys/crypto/chacha/arch/arm/arm_neon.h:1.1 src/sys/crypto/chacha/arch/arm/arm_neon.h:1.2
--- src/sys/crypto/chacha/arch/arm/arm_neon.h:1.1	Sat Jul 25 22:51:57 2020
+++ src/sys/crypto/chacha/arch/arm/arm_neon.h	Mon Jul 27 20:58:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm_neon.h,v 1.1 2020/07/25 22:51:57 riastradh Exp $	*/
+/*	$NetBSD: arm_neon.h,v 1.2 2020/07/27 20:58:06 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -39,6 +39,7 @@
 typedef __Int32x4_t int32x4_t;
 typedef __Int64x2_t int64x2_t;
 typedef __Int8x16_t int8x16_t;
+typedef __Uint16x8_t uint16x8_t;
 typedef __Uint32x4_t uint32x4_t;
 typedef __Uint64x2_t uint64x2_t;
 typedef __Uint8x16_t uint8x16_t;
@@ -46,6 +47,7 @@ typedef __Uint8x16_t uint8x16_t;
 typedef __simd128_int32_t int32x4_t;
 typedef __simd128_int64_t int64x2_t;
 typedef __simd128_int8_t int8x16_t;
+typedef __simd128_uint16_t uint16x8_t;
 typedef __simd128_uint32_t uint32x4_t;
 typedef __simd128_uint64_t uint64x2_t;
 typedef __simd128_uint8_t uint8x16_t;
@@ -70,9 +72,11 @@ typedef struct { uint8x8_t val[2]; } uin
 typedef __attribute__((neon_vector_type(16))) int8_t int8x16_t;
 typedef __attribute__((neon_vector_type(2))) int64_t int64x2_t;
 typedef __attribute__((neon_vector_type(4))) int32_t int32x4_t;
+
 typedef __attribute__((neon_vector_type(16))) uint8_t uint8x16_t;
 typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t;
 typedef __attribute__((neon_vector_type(4))) uint32_t uint32x4_t;
+typedef __attribute__((neon_vector_type(8))) uint16_t uint16x8_t;
 
 typedef __attribute__((neon_vector_type(8))) uint8_t uint8x8_t;
 typedef struct { uint8x8_t val[2]; } uint8x8x2_t;
@@ -330,6 +334,27 @@ vreinterpretq_s32_u8(uint8x16_t __v)
 }
 
 _INTRINSATTR
+static __inline uint16x8_t
+vreinterpretq_u16_u32(uint32x4_t __v)
+{
+	return (uint16x8_t)__v;
+}
+
+_INTRINSATTR
+static __inline uint32x4_t
+vreinterpretq_u32_u16(uint16x8_t __v)
+{
+	return (uint32x4_t)__v;
+}
+
+_INTRINSATTR
+static __inline uint32x4_t
+vreinterpretq_u32_u64(uint64x2_t __v)
+{
+	return (uint32x4_t)__v;
+}
+
+_INTRINSATTR
 static __inline uint32x4_t
 vreinterpretq_u32_u8(uint8x16_t __v)
 {
@@ -338,6 +363,13 @@ vreinterpretq_u32_u8(uint8x16_t __v)
 
 _INTRINSATTR
 static __inline uint64x2_t
+vreinterpretq_u64_u32(uint32x4_t __v)
+{
+	return (uint64x2_t)__v;
+}
+
+_INTRINSATTR
+static __inline uint64x2_t
 vreinterpretq_u64_u8(uint8x16_t __v)
 {
 	return (uint64x2_t)__v;
@@ -365,6 +397,17 @@ vreinterpretq_u8_u64(uint64x2_t __v)
 }
 
 _INTRINSATTR
+static __inline uint16x8_t
+vrev32q_u16(uint16x8_t __v)
+{
+#if defined(__GNUC__) && !defined(__clang__)
+	return __builtin_shuffle(__v, (uint16x8_t) { 1,0, 3,2, 5,4, 7,6 });
+#elif defined(__clang__)
+	return __builtin_shufflevector(__v,  1,0, 3,2, 5,4, 7,6);
+#endif
+}
+
+_INTRINSATTR
 static __inline uint8x16_t
 vrev32q_u8(uint8x16_t __v)
 {
@@ -531,4 +574,58 @@ vst1q_u8(uint8_t *__p8, uint8x16_t __v)
 #endif
 }
 
+#ifndef __aarch64__		/* XXX */
+
+_INTRINSATTR
+static __inline uint8x8_t
+vtbl1_u8(uint8x8_t __tab, uint8x8_t __idx)
+{
+#if defined(__GNUC__) && !defined(__clang__)
+	return (uint8x8_t)__builtin_neon_vtbl1v8qi((int8x8_t)__tab,
+	(int8x8_t)__idx);
+#elif defined(__clang__)
+	uint8x8_t __ret;
+#ifndef __LITTLE_ENDIAN__
+	__tab = __builtin_shufflevector(__tab, __tab, 7,6,5,4,3,2,1,0);
+	__idx = __builtin_shufflevector(__idx, __idx, 7,6,5,4,3,2,1,0);
+#endif
+	__ret = (uint8x8_t)__builtin_neon_vtbl1_v((int8x8_t)__tab,
+	(int8x8_t)__idx, 16);
+#ifndef __LITTLE_ENDIAN__
+	__ret = __builtin_shufflevector(__ret, __ret, 7,6,5,4,3,2,1,0);
+#endif
+	return __ret;
+#endif
+}
+
+_INTRINSATTR
+static __inline uint8x8_t
+vtbl2_u8(uint8x8x2_t __tab, uint8x8_t __idx)
+{
+#if defined(__GNUC__) && !defined(__clang__)
+	union {
+		uint8x8x2_t __u8x8x82;
+		__builtin_neon_ti __ti;
+	} __u = { __tab };
+	return (uint8x8_t)__builtin_neon_vtbl2v8qi(__u.__ti, (int8x8_t)__idx);
+#elif defined(__clang__)
+	uint8x8_t __ret;
+#ifndef __LITTLE_ENDIAN__
+	__tab.val[0] = __builtin_shufflevector(__tab.val[0], __tab.val[0],
+	7,6,5,4,3,2,1,0);
+	__tab.val[1] = __builtin_shufflevector(__tab.val[1], __tab.val[1],
+	

CVS commit: src/sys/crypto

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:57:23 UTC 2020

Modified Files:
src/sys/crypto/aes/arch/arm: aes_armv8_64.S aes_neon_32.S
src/sys/crypto/aes/arch/x86: aes_ni_64.S
src/sys/crypto/chacha/arch/arm: chacha_neon_64.S

Log Message:
Add RCSIDs to the AES and ChaCha .S sources.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/crypto/aes/arch/arm/aes_armv8_64.S
cvs rdiff -u -r1.3 -r1.4 src/sys/crypto/aes/arch/arm/aes_neon_32.S
cvs rdiff -u -r1.5 -r1.6 src/sys/crypto/aes/arch/x86/aes_ni_64.S
cvs rdiff -u -r1.3 -r1.4 src/sys/crypto/chacha/arch/arm/chacha_neon_64.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/crypto/aes/arch/arm/aes_armv8_64.S
diff -u src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.10 src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.11
--- src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.10	Mon Jul 27 20:54:11 2020
+++ src/sys/crypto/aes/arch/arm/aes_armv8_64.S	Mon Jul 27 20:57:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aes_armv8_64.S,v 1.10 2020/07/27 20:54:11 riastradh Exp $	*/
+/*	$NetBSD: aes_armv8_64.S,v 1.11 2020/07/27 20:57:23 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,6 +30,8 @@
 
 #include 
 
+RCSID("$NetBSD: aes_armv8_64.S,v 1.11 2020/07/27 20:57:23 riastradh Exp $")
+
 	.arch_extension	aes
 
 /*

Index: src/sys/crypto/aes/arch/arm/aes_neon_32.S
diff -u src/sys/crypto/aes/arch/arm/aes_neon_32.S:1.3 src/sys/crypto/aes/arch/arm/aes_neon_32.S:1.4
--- src/sys/crypto/aes/arch/arm/aes_neon_32.S:1.3	Mon Jul 27 20:53:22 2020
+++ src/sys/crypto/aes/arch/arm/aes_neon_32.S	Mon Jul 27 20:57:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aes_neon_32.S,v 1.3 2020/07/27 20:53:22 riastradh Exp $	*/
+/*	$NetBSD: aes_neon_32.S,v 1.4 2020/07/27 20:57:23 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,6 +28,8 @@
 
 #include 
 
+RCSID("$NetBSD: aes_neon_32.S,v 1.4 2020/07/27 20:57:23 riastradh Exp $")
+
 	.fpu	neon
 
 	.text

Index: src/sys/crypto/aes/arch/x86/aes_ni_64.S
diff -u src/sys/crypto/aes/arch/x86/aes_ni_64.S:1.5 src/sys/crypto/aes/arch/x86/aes_ni_64.S:1.6
--- src/sys/crypto/aes/arch/x86/aes_ni_64.S:1.5	Mon Jul 27 20:53:22 2020
+++ src/sys/crypto/aes/arch/x86/aes_ni_64.S	Mon Jul 27 20:57:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aes_ni_64.S,v 1.5 2020/07/27 20:53:22 riastradh Exp $	*/
+/*	$NetBSD: aes_ni_64.S,v 1.6 2020/07/27 20:57:23 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,6 +28,8 @@
 
 #include 
 
+RCSID("$NetBSD: aes_ni_64.S,v 1.6 2020/07/27 20:57:23 riastradh Exp $")
+
 /*
  * MOVDQA/MOVDQU are Move Double Quadword (Aligned/Unaligned), defined
  * to operate on integers; MOVAPS/MOVUPS are Move (Aligned/Unaligned)

Index: src/sys/crypto/chacha/arch/arm/chacha_neon_64.S
diff -u src/sys/crypto/chacha/arch/arm/chacha_neon_64.S:1.3 src/sys/crypto/chacha/arch/arm/chacha_neon_64.S:1.4
--- src/sys/crypto/chacha/arch/arm/chacha_neon_64.S:1.3	Mon Jul 27 20:53:23 2020
+++ src/sys/crypto/chacha/arch/arm/chacha_neon_64.S	Mon Jul 27 20:57:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: chacha_neon_64.S,v 1.3 2020/07/27 20:53:23 riastradh Exp $	*/
+/*	$NetBSD: chacha_neon_64.S,v 1.4 2020/07/27 20:57:23 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,6 +28,8 @@
 
 #include 
 
+RCSID("$NetBSD: chacha_neon_64.S,v 1.4 2020/07/27 20:57:23 riastradh Exp $")
+
 #define	ROUND(a0,b0,c0,d0,a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3,t0,t1,t2,t3, r) \
 STEP(STEP0,a0,b0,c0,d0,a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3,t0,t1,t2,t3, r);   \
 STEP(STEP1,a0,b0,c0,d0,a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3,t0,t1,t2,t3, r);   \



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

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 20:55:59 UTC 2020

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

Log Message:
make(1): document where to fix the .INCLUDEDFROM bug


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/include-main.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/include-main.mk
diff -u src/usr.bin/make/unit-tests/include-main.mk:1.1 src/usr.bin/make/unit-tests/include-main.mk:1.2
--- src/usr.bin/make/unit-tests/include-main.mk:1.1	Sun May 17 12:36:26 2020
+++ src/usr.bin/make/unit-tests/include-main.mk	Mon Jul 27 20:55:59 2020
@@ -1,11 +1,11 @@
-# $NetBSD: include-main.mk,v 1.1 2020/05/17 12:36:26 rillig Exp $
+# $NetBSD: include-main.mk,v 1.2 2020/07/27 20:55:59 rillig Exp $
 #
 # Demonstrates that the .INCLUDEDFROMFILE magic variable does not behave
 # as described in the manual page.
 #
 # The manual page says that it is the "filename of the file this Makefile
 # was included from", while in reality it is the "filename in which the
-# latest .include happened".
+# latest .include happened". See parse.c, function ParseSetIncludeFile.
 #
 
 .if !defined(.INCLUDEDFROMFILE)



CVS commit: src/sbin/gpt

2020-07-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul 27 20:54:18 UTC 2020

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
catch up with source rename of fbsd-zfs -> zfs


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sbin/gpt/gpt.8

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

Modified files:

Index: src/sbin/gpt/gpt.8
diff -u src/sbin/gpt/gpt.8:1.73 src/sbin/gpt/gpt.8:1.74
--- src/sbin/gpt/gpt.8:1.73	Sun May 24 16:59:16 2020
+++ src/sbin/gpt/gpt.8	Mon Jul 27 16:54:18 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.73 2020/05/24 20:59:16 wiz Exp $
+.\" $NetBSD: gpt.8,v 1.74 2020/07/27 20:54:18 christos Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
 .\"
-.Dd May 24, 2020
+.Dd July 27, 2020
 .Dt GPT 8
 .Os
 .Sh NAME
@@ -203,8 +203,9 @@ UFS/UFS2
 .It Cm fbsd-vinum
 .Fx
 vinum
-.It Cm fbsd-zfs
-.Fx
+.It Cm zfs
+.Fx ,
+.Nx
 ZFS
 .It Cm linux-data
 Linux data



CVS commit: src/sys/crypto/aes/arch/arm

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:54:12 UTC 2020

Modified Files:
src/sys/crypto/aes/arch/arm: aes_armv8_64.S

Log Message:
Issue aese/aesmc and aesd/aesimc in pairs.

Advised by the aarch64 optimization guide; increases cgd throughput
by about 10%.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/crypto/aes/arch/arm/aes_armv8_64.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/crypto/aes/arch/arm/aes_armv8_64.S
diff -u src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.9 src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.10
--- src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.9	Mon Jul 27 20:53:22 2020
+++ src/sys/crypto/aes/arch/arm/aes_armv8_64.S	Mon Jul 27 20:54:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aes_armv8_64.S,v 1.9 2020/07/27 20:53:22 riastradh Exp $	*/
+/*	$NetBSD: aes_armv8_64.S,v 1.10 2020/07/27 20:54:11 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -1041,15 +1041,18 @@ END(ctr32_inc)
 	.type	aesarmv8_enc1,@function
 aesarmv8_enc1:
 	ldr	q16, [x0], #0x10	/* load round key */
-	b	2f
+	sub	x3, x3, #1
 	_ALIGN_TEXT
-1:	/* q0 := MixColumns(q0) */
+1:	/* q0 := MixColumns(ShiftRows(SubBytes(AddRoundKey_q16(q0 */
+	aese	v0.16b, v16.16b
 	aesmc	v0.16b, v0.16b
-2:	subs	x3, x3, #1
+	ldr	q16, [x0], #0x10
+	subs	x3, x3, #1
+	b.ne	1b
 	/* q0 := ShiftRows(SubBytes(AddRoundKey_q16(q0))) */
 	aese	v0.16b, v16.16b
-	ldr	q16, [x0], #0x10		/* load next round key */
-	b.ne	1b
+	ldr	q16, [x0]		/* load last round key */
+	/* q0 := AddRoundKey_q16(q0) */
 	eor	v0.16b, v0.16b, v16.16b
 	ret
 END(aesarmv8_enc1)
@@ -1067,17 +1070,21 @@ END(aesarmv8_enc1)
 	.type	aesarmv8_enc2,@function
 aesarmv8_enc2:
 	ldr	q16, [x0], #0x10	/* load round key */
-	b	2f
+	sub	x3, x3, #1
 	_ALIGN_TEXT
-1:	/* q[i] := MixColumns(q[i]) */
+1:	/* q[i] := MixColumns(ShiftRows(SubBytes(AddRoundKey_q16(q[i] */
+	aese	v0.16b, v16.16b
 	aesmc	v0.16b, v0.16b
+	aese	v1.16b, v16.16b
 	aesmc	v1.16b, v1.16b
-2:	subs	x3, x3, #1
+	ldr	q16, [x0], #0x10	/* load next round key */
+	subs	x3, x3, #1
+	b.ne	1b
 	/* q[i] := ShiftRows(SubBytes(AddRoundKey_q16(q[i]))) */
 	aese	v0.16b, v16.16b
 	aese	v1.16b, v16.16b
-	ldr	q16, [x0], #0x10		/* load next round key */
-	b.ne	1b
+	ldr	q16, [x0]		/* load last round key */
+	/* q[i] := AddRoundKey_q16(q[i]) */
 	eor	v0.16b, v0.16b, v16.16b
 	eor	v1.16b, v1.16b, v16.16b
 	ret
@@ -1097,18 +1104,28 @@ END(aesarmv8_enc2)
 	.type	aesarmv8_enc8,@function
 aesarmv8_enc8:
 	ldr	q16, [x0], #0x10	/* load round key */
-	b	2f
+	sub	x3, x3, #1
 	_ALIGN_TEXT
-1:	/* q[i] := MixColumns(q[i]) */
+1:	/* q[i] := MixColumns(ShiftRows(SubBytes(AddRoundKey_q16(q[i] */
+	aese	v0.16b, v16.16b
 	aesmc	v0.16b, v0.16b
+	aese	v1.16b, v16.16b
 	aesmc	v1.16b, v1.16b
+	aese	v2.16b, v16.16b
 	aesmc	v2.16b, v2.16b
+	aese	v3.16b, v16.16b
 	aesmc	v3.16b, v3.16b
+	aese	v4.16b, v16.16b
 	aesmc	v4.16b, v4.16b
+	aese	v5.16b, v16.16b
 	aesmc	v5.16b, v5.16b
+	aese	v6.16b, v16.16b
 	aesmc	v6.16b, v6.16b
+	aese	v7.16b, v16.16b
 	aesmc	v7.16b, v7.16b
-2:	subs	x3, x3, #1
+	ldr	q16, [x0], #0x10	/* load next round key */
+	subs	x3, x3, #1
+	b.ne	1b
 	/* q[i] := ShiftRows(SubBytes(AddRoundKey_q16(q[i]))) */
 	aese	v0.16b, v16.16b
 	aese	v1.16b, v16.16b
@@ -1118,9 +1135,9 @@ aesarmv8_enc8:
 	aese	v5.16b, v16.16b
 	aese	v6.16b, v16.16b
 	aese	v7.16b, v16.16b
-	ldr	q16, [x0], #0x10	/* load next round key */
-	b.ne	1b
-	eor	v0.16b, v0.16b, v16.16b	/* AddRoundKey */
+	ldr	q16, [x0]		/* load last round key */
+	/* q[i] := AddRoundKey_q16(q[i]) */
+	eor	v0.16b, v0.16b, v16.16b
 	eor	v1.16b, v1.16b, v16.16b
 	eor	v2.16b, v2.16b, v16.16b
 	eor	v3.16b, v3.16b, v16.16b
@@ -1144,15 +1161,19 @@ END(aesarmv8_enc8)
 	.type	aesarmv8_dec1,@function
 aesarmv8_dec1:
 	ldr	q16, [x0], #0x10	/* load round key */
-	b	2f
+	sub	x3, x3, #1
 	_ALIGN_TEXT
-1:	/* q0 := InMixColumns(q0) */
-	aesimc	v0.16b, v0.16b
-2:	subs	x3, x3, #1
-	/* q0 := InSubBytes(InShiftRows(AddRoundKey_q16(q0))) */
+1:	/* q0 := InSubBytes(InShiftRows(AddRoundKey_q16(q0))) */
 	aesd	v0.16b, v16.16b
+	/* q0 := InMixColumns(q0) */
+	aesimc	v0.16b, v0.16b
 	ldr	q16, [x0], #0x10	/* load next round key */
+	subs	x3, x3, #1
 	b.ne	1b
+	/* q0 := InSubBytes(InShiftRows(AddRoundKey_q16(q0))) */
+	aesd	v0.16b, v16.16b
+	ldr	q16, [x0]		/* load last round key */
+	/* q0 := AddRoundKey_q16(q0) */
 	eor	v0.16b, v0.16b, v16.16b
 	ret
 END(aesarmv8_dec1)
@@ -1171,18 +1192,29 @@ END(aesarmv8_dec1)
 	.type	aesarmv8_dec8,@function
 aesarmv8_dec8:
 	ldr	q16, [x0], #0x10	/* load round key */
-	b	2f
+	sub	x3, x3, #1
 	_ALIGN_TEXT
-1:	/* q[i] := InMixColumns(q[i]) */
+1:	/* q[i] := InSubBytes(InShiftRows(AddRoundKey_q16(q[i]))) */
+	aesd	v0.16b, v16.16b
+	/* q[i] := InMixColumns(q[i]) */
 	aesimc	v0.16b, v0.16b
+	aesd	v1.16b, v16.16b
 	aesimc	v1.16b, v1.16b
+	aesd	v2.16b, v16.16b
 	aesimc	v2.16b, v2.16b
+	aesd	v3.16b, v16.16b
 	aesimc	v3.16b, 

CVS commit: src/sys/crypto

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:53:23 UTC 2020

Modified Files:
src/sys/crypto/aes/arch/arm: aes_armv8_64.S aes_neon_32.S
src/sys/crypto/aes/arch/x86: aes_ni_64.S
src/sys/crypto/chacha/arch/arm: chacha_neon_64.S

Log Message:
Align critical-path loops in AES and ChaCha.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/crypto/aes/arch/arm/aes_armv8_64.S
cvs rdiff -u -r1.2 -r1.3 src/sys/crypto/aes/arch/arm/aes_neon_32.S
cvs rdiff -u -r1.4 -r1.5 src/sys/crypto/aes/arch/x86/aes_ni_64.S
cvs rdiff -u -r1.2 -r1.3 src/sys/crypto/chacha/arch/arm/chacha_neon_64.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/crypto/aes/arch/arm/aes_armv8_64.S
diff -u src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.8 src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.9
--- src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.8	Sat Jul 25 22:33:04 2020
+++ src/sys/crypto/aes/arch/arm/aes_armv8_64.S	Mon Jul 27 20:53:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aes_armv8_64.S,v 1.8 2020/07/25 22:33:04 riastradh Exp $	*/
+/*	$NetBSD: aes_armv8_64.S,v 1.9 2020/07/27 20:53:22 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -440,6 +440,7 @@ END(aesarmv8_setenckey256)
 ENTRY(aesarmv8_enctodec)
 	ldr	q0, [x0, x2, lsl #4]	/* load last round key */
 	b	2f
+	_ALIGN_TEXT
 1:	aesimc	v0.16b, v0.16b	/* convert encryption to decryption */
 2:	str	q0, [x1], #0x10	/* store round key */
 	subs	x2, x2, #1	/* count down round */
@@ -503,6 +504,7 @@ ENTRY(aesarmv8_cbc_enc)
 	mov	x9, x0			/* x9 := enckey */
 	mov	x10, x3			/* x10 := nbytes */
 	ldr	q0, [x4]		/* q0 := chaining value */
+	_ALIGN_TEXT
 1:	ldr	q1, [x1], #0x10		/* q1 := plaintext block */
 	eor	v0.16b, v0.16b, v1.16b	/* q0 := cv ^ ptxt */
 	mov	x0, x9			/* x0 := enckey */
@@ -539,6 +541,7 @@ ENTRY(aesarmv8_cbc_dec1)
 	ldr	q0, [x1, #-0x10]!	/* q0 := last ciphertext block */
 	str	q0, [x4]		/* update iv */
 	b	2f
+	_ALIGN_TEXT
 1:	ldr	q31, [x1, #-0x10]!	/* q31 := chaining value */
 	eor	v0.16b, v0.16b, v31.16b	/* q0 := plaintext block */
 	str	q0, [x2, #-0x10]!	/* store plaintext block */
@@ -576,6 +579,7 @@ ENTRY(aesarmv8_cbc_dec8)
 	ldp	q6, q7, [x1, #-0x20]!	/* q6, q7 := last ciphertext blocks */
 	str	q7, [x4]		/* update iv */
 	b	2f
+	_ALIGN_TEXT
 1:	ldp	q6, q7, [x1, #-0x20]!
 	eor	v0.16b, v0.16b, v7.16b	/* q0 := pt0 */
 	stp	q0, q1, [x2, #-0x20]!
@@ -629,6 +633,7 @@ ENTRY(aesarmv8_xts_enc1)
 	mov	x9, x0			/* x9 := enckey */
 	mov	x10, x3			/* x10 := nbytes */
 	ldr	q31, [x4]		/* q31 := tweak */
+	_ALIGN_TEXT
 1:	ldr	q0, [x1], #0x10		/* q0 := ptxt */
 	mov	x0, x9			/* x0 := enckey */
 	mov	x3, x5			/* x3 := nrounds */
@@ -661,6 +666,7 @@ ENTRY(aesarmv8_xts_enc8)
 	mov	x9, x0			/* x9 := enckey */
 	mov	x10, x3			/* x10 := nbytes */
 	ldr	q31, [x4]		/* q31 := tweak */
+	_ALIGN_TEXT
 1:	mov	v24.16b, v31.16b	/* q24 := tweak[0] */
 	bl	aesarmv8_xts_mulx	/* q31 *= x; trash x0/q0/q1 */
 	mov	v25.16b, v31.16b	/* q25 := tweak[1] */
@@ -729,6 +735,7 @@ ENTRY(aesarmv8_xts_dec1)
 	mov	x9, x0			/* x9 := deckey */
 	mov	x10, x3			/* x10 := nbytes */
 	ldr	q31, [x4]		/* q31 := tweak */
+	_ALIGN_TEXT
 1:	ldr	q0, [x1], #0x10		/* q0 := ctxt */
 	mov	x0, x9			/* x0 := deckey */
 	mov	x3, x5			/* x3 := nrounds */
@@ -761,6 +768,7 @@ ENTRY(aesarmv8_xts_dec8)
 	mov	x9, x0			/* x9 := deckey */
 	mov	x10, x3			/* x10 := nbytes */
 	ldr	q31, [x4]		/* q31 := tweak */
+	_ALIGN_TEXT
 1:	mov	v24.16b, v31.16b	/* q24 := tweak[0] */
 	bl	aesarmv8_xts_mulx	/* q31 *= x; trash x0/q0/q1 */
 	mov	v25.16b, v31.16b	/* q25 := tweak[1] */
@@ -879,6 +887,7 @@ ENTRY(aesarmv8_cbcmac_update1)
 	ldr	q0, [x3]		/* q0 := initial authenticator */
 	mov	x9, x0			/* x9 := enckey */
 	mov	x5, x3			/* x5 :=  (enc1 trashes x3) */
+	_ALIGN_TEXT
 1:	ldr	q1, [x1], #0x10		/* q1 := plaintext block */
 	mov	x0, x9			/* x0 := enckey */
 	mov	x3, x4			/* x3 := nrounds */
@@ -913,6 +922,7 @@ ENTRY(aesarmv8_ccm_enc1)
 #if _BYTE_ORDER == _LITTLE_ENDIAN
 	rev32	v2.16b, v2.16b		/* q2 := ctr (host-endian) */
 #endif
+	_ALIGN_TEXT
 1:	ldr	q3, [x1], #0x10		/* q3 := plaintext block */
 	add	v2.4s, v2.4s, v5.4s	/* increment ctr (32-bit) */
 	mov	x0, x9			/* x0 := enckey */
@@ -972,6 +982,7 @@ ENTRY(aesarmv8_ccm_dec1)
 	bl	aesarmv8_enc1		/* q0 := pad; trash x0/x3/q16 */
 	b	2f
 
+	_ALIGN_TEXT
 1:	/*
 	 * Authenticate the last block and decrypt the next block
 	 * simultaneously.
@@ -1031,6 +1042,7 @@ END(ctr32_inc)
 aesarmv8_enc1:
 	ldr	q16, [x0], #0x10	/* load round key */
 	b	2f
+	_ALIGN_TEXT
 1:	/* q0 := MixColumns(q0) */
 	aesmc	v0.16b, v0.16b
 2:	subs	x3, x3, #1
@@ -1056,6 +1068,7 @@ END(aesarmv8_enc1)
 aesarmv8_enc2:
 	ldr	q16, [x0], #0x10	/* load round key */
 	b	2f
+	_ALIGN_TEXT
 1:	/* q[i] := MixColumns(q[i]) */
 	aesmc	v0.16b, v0.16b
 	aesmc	v1.16b, v1.16b
@@ -1085,6 +1098,7 @@ END(aesarmv8_enc2)
 aesarmv8_enc8:
 	ldr	q16, [x0], #0x10	/* load round key */
 	b	2f
+	

CVS commit: src/sys/crypto/aes/arch/arm

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:52:11 UTC 2020

Modified Files:
src/sys/crypto/aes/arch/arm: aes_neon_32.S

Log Message:
PIC for aes_neon_32.S.

Without this, tests/sys/crypto/aes/t_aes fails to start on armv7
because of R_ARM_ABS32 relocations in a nonwritable text segment for
a PIE -- which atf quietly ignores in the final report!  Yikes.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/aes/arch/arm/aes_neon_32.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/crypto/aes/arch/arm/aes_neon_32.S
diff -u src/sys/crypto/aes/arch/arm/aes_neon_32.S:1.1 src/sys/crypto/aes/arch/arm/aes_neon_32.S:1.2
--- src/sys/crypto/aes/arch/arm/aes_neon_32.S:1.1	Mon Jun 29 23:57:56 2020
+++ src/sys/crypto/aes/arch/arm/aes_neon_32.S	Mon Jul 27 20:52:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aes_neon_32.S,v 1.1 2020/06/29 23:57:56 riastradh Exp $	*/
+/*	$NetBSD: aes_neon_32.S,v 1.2 2020/07/27 20:52:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,8 +30,14 @@
 
 	.fpu	neon
 
+	.text
+	.p2align 2
+.Lconstants_addr:
+	.long	.Lconstants - .
+
 	.section .rodata
 	.p2align 4
+.Lconstants:
 
 	.type	inv,_ASM_TYPE_OBJECT
 inv:
@@ -239,7 +245,7 @@ ENTRY(aes_neon_enc1)
 	 * r3: rmod4
 	 * r4: mc_forward
 	 * r5: mc_backward
-	 * r6,r7,r8,r10,r11: temporaries
+	 * r6,r7,r8,r10,r11,r12: temporaries
 	 * q0={d0-d1}: x/ak/A
 	 * q1={d2-d3}: 0x0f0f...
 	 * q2={d4-d5}: lo/k/j/io
@@ -258,23 +264,30 @@ ENTRY(aes_neon_enc1)
 	 * q15={d30-d31}: A2_B/sr[rmod4]
 	 */
 
+	/* r12 := .Lconstants - .Lconstants_addr, r11 := .Lconstants_addr */
+	ldr	r12, .Lconstants_addr
+	adr	r11, .Lconstants_addr
+
 	vld1.64	{d28-d29}, [r0 :128]!	/* q14 = *rk++ */
 	movw	r3, #0
 	vmov.i8	q1, #0x0f
 
+	/* r12 := .Lconstants */
+	add	r12, r12, r11
+
 	/* (q4, q5) := (iptlo, ipthi) */
-	ldr	r6, =iptlo
-	ldr	r7, =ipthi
+	add	r6, r12, #(iptlo - .Lconstants)
+	add	r7, r12, #(ipthi - .Lconstants)
 	vld1.64	{d8-d9}, [r6 :128]
 	vld1.64	{d10-d11}, [r7 :128]
 
 	/* load the rest of the constants */
-	ldr	r4, =sb1_0
-	ldr	r5, =sb1_1
-	ldr	r6, =sb2_0
-	ldr	r7, =sb2_1
-	ldr	r8, =inv
-	ldr	r10, =inva
+	add	r4, r12, #(sb1_0 - .Lconstants)
+	add	r5, r12, #(sb1_1 - .Lconstants)
+	add	r6, r12, #(sb2_0 - .Lconstants)
+	add	r7, r12, #(sb2_1 - .Lconstants)
+	add	r8, r12, #(inv - .Lconstants)
+	add	r10, r12, #(inva - .Lconstants)
 	vld1.64	{d12-d13}, [r4 :128]	/* q6 = sb1[0] */
 	vld1.64	{d14-d15}, [r5 :128]	/* q7 = sb1[1] */
 	vld1.64	{d16-d17}, [r6 :128]	/* q8 = sb2[0] */
@@ -283,8 +296,8 @@ ENTRY(aes_neon_enc1)
 	vld1.64	{d22-d23}, [r10 :128]	/* q11 = inva */
 
 	/* (r4, r5) := (_forward[0], _backward[0]) */
-	ldr	r4, =mc_forward
-	ldr	r5, =mc_backward
+	add	r4, r12, #(mc_forward - .Lconstants)
+	add	r5, r12, #(mc_backward - .Lconstants)
 
 	/* (q2, q3) := (lo, hi) */
 	vshr.u8	q3, q0, #4
@@ -392,9 +405,9 @@ ENTRY(aes_neon_enc1)
 	bne	1b
 
 	/* (q6, q7, q15) := (sbo[0], sbo[1], sr[rmod4]) */
-	ldr	r8, =sr
-	ldr	r6, =sbo_0
-	ldr	r7, =sbo_1
+	add	r8, r12, #(sr - .Lconstants)
+	add	r6, r12, #(sbo_0 - .Lconstants)
+	add	r7, r12, #(sbo_1 - .Lconstants)
 	add	r8, r8, r3, lsl #4
 	vld1.64	{d12-d13}, [r6 :128]
 	vld1.64	{d14-d15}, [r7 :128]
@@ -469,23 +482,30 @@ ENTRY(aes_neon_dec1)
 	 * q15={d30-d31}: mc/sr[3 & ~(nrounds - 1)]
 	 */
 
+	/* r12 := .Lconstants - .Lconstants_addr, r11 := .Lconstants_addr */
+	ldr	r12, .Lconstants_addr
+	adr	r11, .Lconstants_addr
+
 	vld1.64	{d28-d29}, [r0 :128]!	/* q14 = *rk++ */
 	rsb	r3, r1, #0		/* r3 := ~(x - 1) = -x */
 	vmov.i8	q1, #0x0f
 	and	r3, r3, #3		/* r3 := 3 & ~(x - 1) */
 
+	/* r12 := .Lconstants */
+	add	r12, r12, r11
+
 	/* (q4, q5) := (diptlo, dipthi) */
-	ldr	r6, =diptlo
-	ldr	r7, =dipthi
+	add	r6, r12, #(diptlo - .Lconstants)
+	add	r7, r12, #(dipthi - .Lconstants)
 	vld1.64	{d8-d9}, [r6 :128]
 	vld1.64	{d10-d11}, [r7 :128]
 
 	/* load the rest of the constants */
-	ldr	r4, =dsbb_0
-	ldr	r5, =dsbb_1
-	ldr	r6, =inv
-	ldr	r7, =inva
-	ldr	r8, =.Lmc_forward_3
+	add	r4, r12, #(dsbb_0 - .Lconstants)
+	add	r5, r12, #(dsbb_1 - .Lconstants)
+	add	r6, r12, #(inv - .Lconstants)
+	add	r7, r12, #(inva - .Lconstants)
+	add	r8, r12, #(.Lmc_forward_3 - .Lconstants)
 	vld1.64	{d12-d13}, [r4 :128]	/* q6 := dsbb[0] */
 	vld1.64	{d14-d15}, [r5 :128]	/* q7 := dsbb[1] */
 	vld1.64	{d20-d21}, [r6 :128]	/* q10 := inv */
@@ -504,8 +524,8 @@ ENTRY(aes_neon_dec1)
 	vtbl.8	d7, {d10-d11}, d7
 
 	/* load dsb9 */
-	ldr	r4, =dsb9_0
-	ldr	r5, =dsb9_1
+	add	r4, r12, #(dsb9_0 - .Lconstants)
+	add	r5, r12, #(dsb9_1 - .Lconstants)
 	vld1.64	{d8-d9}, [r4 :128]	/* q4 := dsb9[0] */
 	vld1.64	{d10-d11}, [r5 :128]	/* q5 := dsb9[1] */
 
@@ -516,7 +536,7 @@ ENTRY(aes_neon_dec1)
 	b	2f
 
 1:	/* load dsbd */
-	ldr	r4, =dsbd_0
+	add	r4, r12, #(dsbd_0 - .Lconstants)
 	vld1.64	{d16-d17}, [r4 :128]!	/* q8 := dsbd[0] */
 	vld1.64	{d18-d19}, [r4 :128]	/* q9 := dsbd[1] */
 
@@ -543,7 +563,7 

CVS commit: src

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:51:29 UTC 2020

Modified Files:
src/sys/arch/arm/conf: files.arm
src/sys/arch/arm/vfp: vfp_init.c
src/sys/crypto/chacha/arch/arm: chacha_neon.c chacha_neon.h
files.chacha_arm
src/tests/sys/crypto/chacha: Makefile t_chacha.c

Log Message:
Enable ChaCha NEON code on armv7 too.

The 4-blocks-at-a-time assembly helper is disabled for now; adapting
it to armv7 is going to be a little annoying with only 16 128-bit
vector registers.

(Should also do a fifth block in the integer registers for 320 bytes
at a time.)


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/arch/arm/conf/files.arm
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/arm/vfp/vfp_init.c
cvs rdiff -u -r1.2 -r1.3 src/sys/crypto/chacha/arch/arm/chacha_neon.c
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/chacha/arch/arm/chacha_neon.h \
src/sys/crypto/chacha/arch/arm/files.chacha_arm
cvs rdiff -u -r1.1 -r1.2 src/tests/sys/crypto/chacha/Makefile \
src/tests/sys/crypto/chacha/t_chacha.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/conf/files.arm
diff -u src/sys/arch/arm/conf/files.arm:1.159 src/sys/arch/arm/conf/files.arm:1.160
--- src/sys/arch/arm/conf/files.arm:1.159	Mon Jul 27 20:49:45 2020
+++ src/sys/arch/arm/conf/files.arm	Mon Jul 27 20:51:29 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.arm,v 1.159 2020/07/27 20:49:45 riastradh Exp $
+#	$NetBSD: files.arm,v 1.160 2020/07/27 20:51:29 riastradh Exp $
 
 # temporary define to allow easy moving to ../arch/arm/arm32
 defflagARM32
@@ -265,3 +265,6 @@ file	dev/tprof/tprof_armv7.c			tprof
 
 # vpaes with ARM NEON
 include "crypto/aes/arch/arm/files.aesneon"
+
+# ChaCha with ARM NEON
+include "crypto/chacha/arch/arm/files.chacha_arm"

Index: src/sys/arch/arm/vfp/vfp_init.c
diff -u src/sys/arch/arm/vfp/vfp_init.c:1.69 src/sys/arch/arm/vfp/vfp_init.c:1.70
--- src/sys/arch/arm/vfp/vfp_init.c:1.69	Sat Jul 25 22:12:56 2020
+++ src/sys/arch/arm/vfp/vfp_init.c	Mon Jul 27 20:51:29 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: vfp_init.c,v 1.69 2020/07/25 22:12:56 riastradh Exp $ */
+/*  $NetBSD: vfp_init.c,v 1.70 2020/07/27 20:51:29 riastradh Exp $ */
 
 /*
  * Copyright (c) 2008 ARM Ltd
@@ -32,7 +32,7 @@
 #include "opt_cputypes.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v 1.69 2020/07/25 22:12:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v 1.70 2020/07/27 20:51:29 riastradh Exp $");
 
 #include 
 #include 
@@ -52,6 +52,8 @@ __KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v
 
 #include 
 #include 
+#include 
+#include 
 
 #ifdef FPU_VFP
 
@@ -409,6 +411,7 @@ vfp_attach(struct cpu_info *ci)
 			install_coproc_handler(CORE_UNKNOWN_HANDLER,
 			neon_handler);
 			aes_md_init(_neon_impl);
+			chacha_md_init(_neon_impl);
 		}
 #endif
 	}

Index: src/sys/crypto/chacha/arch/arm/chacha_neon.c
diff -u src/sys/crypto/chacha/arch/arm/chacha_neon.c:1.2 src/sys/crypto/chacha/arch/arm/chacha_neon.c:1.3
--- src/sys/crypto/chacha/arch/arm/chacha_neon.c:1.2	Mon Jul 27 20:48:18 2020
+++ src/sys/crypto/chacha/arch/arm/chacha_neon.c	Mon Jul 27 20:51:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: chacha_neon.c,v 1.2 2020/07/27 20:48:18 riastradh Exp $	*/
+/*	$NetBSD: chacha_neon.c,v 1.3 2020/07/27 20:51:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -150,8 +150,10 @@ chacha_stream_neon(uint8_t *restrict s, 
 unsigned nr)
 {
 
+#ifdef __aarch64__
 	for (; n >= 256; s += 256, n -= 256, blkno += 4)
 		chacha_stream256_neon(s, blkno, nonce, k, chacha_const32, nr);
+#endif
 
 	if (n) {
 		const uint32x4_t blkno_inc = {1,0,0,0};
@@ -208,9 +210,11 @@ chacha_stream_xor_neon(uint8_t *s, const
 unsigned nr)
 {
 
+#ifdef __aarch64__
 	for (; n >= 256; s += 256, p += 256, n -= 256, blkno += 4)
 		chacha_stream_xor256_neon(s, p, blkno, nonce, k,
 		chacha_const32, nr);
+#endif
 
 	if (n) {
 		const uint32x4_t blkno_inc = {1,0,0,0};

Index: src/sys/crypto/chacha/arch/arm/chacha_neon.h
diff -u src/sys/crypto/chacha/arch/arm/chacha_neon.h:1.1 src/sys/crypto/chacha/arch/arm/chacha_neon.h:1.2
--- src/sys/crypto/chacha/arch/arm/chacha_neon.h:1.1	Sat Jul 25 22:51:57 2020
+++ src/sys/crypto/chacha/arch/arm/chacha_neon.h	Mon Jul 27 20:51:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: chacha_neon.h,v 1.1 2020/07/25 22:51:57 riastradh Exp $	*/
+/*	$NetBSD: chacha_neon.h,v 1.2 2020/07/27 20:51:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -64,7 +64,8 @@ void	xchacha_stream_xor_neon(uint8_t *, 
 	const uint8_t[static 32],
 	unsigned);
 
-/* Assembly helpers */
+#ifdef __aarch64__
+/* Assembly helpers -- aarch64 only for now */
 void	chacha_stream256_neon(uint8_t[restrict static 256], uint32_t,
 	const uint8_t[static 12],
 	const uint8_t[static 32],
@@ -77,6 +78,7 @@ void	chacha_stream_xor256_neon(uint8_t[r
 	const 

CVS commit: src/sys/crypto/chacha/arch/arm

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:50:25 UTC 2020

Modified Files:
src/sys/crypto/chacha/arch/arm: chacha_neon_64.S

Log Message:
Use  rather than copying things from it here.

Vestige from userland build on netbsd-9 during development.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/chacha/arch/arm/chacha_neon_64.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/crypto/chacha/arch/arm/chacha_neon_64.S
diff -u src/sys/crypto/chacha/arch/arm/chacha_neon_64.S:1.1 src/sys/crypto/chacha/arch/arm/chacha_neon_64.S:1.2
--- src/sys/crypto/chacha/arch/arm/chacha_neon_64.S:1.1	Sat Jul 25 22:51:57 2020
+++ src/sys/crypto/chacha/arch/arm/chacha_neon_64.S	Mon Jul 27 20:50:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: chacha_neon_64.S,v 1.1 2020/07/25 22:51:57 riastradh Exp $	*/
+/*	$NetBSD: chacha_neon_64.S,v 1.2 2020/07/27 20:50:25 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -26,23 +26,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-.macro	adrl 	reg, addr
-	adrp	\reg, \addr
-	add	\reg, \reg, #:lo12:\addr
-.endm
-
-#define	_ALIGN_TEXT			  \
-	.p2align 4
-
-#define	ENTRY(x)			  \
-	.text;  \
-	_ALIGN_TEXT;			  \
-	.global	x;			  \
-	.type	x,@function;		  \
-x:
-
-#define	END(x)  \
-	.size x, . - x
+#include 
 
 #define	ROUND(a0,b0,c0,d0,a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3,t0,t1,t2,t3, r) \
 STEP(STEP0,a0,b0,c0,d0,a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3,t0,t1,t2,t3, r);   \



CVS commit: src/sys/crypto/chacha

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:49:10 UTC 2020

Modified Files:
src/sys/crypto/chacha: chacha_impl.c

Log Message:
Simplify ChaCha selection and allow it to be used much earlier.

This way we can use it for cprng_fast early on.  ChaCha is easy
because there's no data formats that must be preserved from call to
call but vary from implementation to implementation -- we could even
make it a sysctl knob to dynamically select it with negligible cost.

(In contrast, different AES implementations use different expanded
key formats which must be preserved from aes_setenckey to aes_enc,
for example, which means a considerably greater burden on dynamic
selection that's not really worth it.)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/crypto/chacha/chacha_impl.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/crypto/chacha/chacha_impl.c
diff -u src/sys/crypto/chacha/chacha_impl.c:1.2 src/sys/crypto/chacha/chacha_impl.c:1.3
--- src/sys/crypto/chacha/chacha_impl.c:1.2	Mon Jul 27 20:45:15 2020
+++ src/sys/crypto/chacha/chacha_impl.c	Mon Jul 27 20:49:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: chacha_impl.c,v 1.2 2020/07/27 20:45:15 riastradh Exp $	*/
+/*	$NetBSD: chacha_impl.c,v 1.3 2020/07/27 20:49:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -38,17 +38,14 @@
 #include "chacha.h"
 #include "chacha_ref.h"
 
-static const struct chacha_impl	*chacha_md_impl	__read_mostly;
-static const struct chacha_impl	*chacha_impl	__read_mostly;
+static const struct chacha_impl	*chacha_md_impl __read_mostly;
+static const struct chacha_impl	*chacha_impl __read_mostly = _ref_impl;
 
 static int
 sysctl_kern_crypto_chacha_selected(SYSCTLFN_ARGS)
 {
 	struct sysctlnode node;
 
-	KASSERTMSG(chacha_impl != NULL,
-	"sysctl ran before ChaCha implementation was selected");
-
 	node = *rnode;
 	node.sysctl_data = __UNCONST(chacha_impl->ci_name);
 	node.sysctl_size = strlen(chacha_impl->ci_name) + 1;
@@ -79,8 +76,6 @@ static int
 chacha_select(void)
 {
 
-	KASSERT(chacha_impl == NULL);
-
 	if (chacha_md_impl) {
 		if (chacha_selftest(chacha_md_impl))
 			aprint_error("chacha: self-test failed: %s\n",
@@ -88,15 +83,6 @@ chacha_select(void)
 		else
 			chacha_impl = chacha_md_impl;
 	}
-	if (chacha_impl == NULL) {
-		if (chacha_selftest(_ref_impl))
-			aprint_error("chacha: self-test failed: %s\n",
-			chacha_ref_impl.ci_name);
-		else
-			chacha_impl = _ref_impl;
-	}
-	if (chacha_impl == NULL)
-		panic("ChaCha self-tests failed");
 
 	aprint_verbose("chacha: %s\n", chacha_impl->ci_name);
 	return 0;
@@ -118,26 +104,11 @@ chacha_modcmd(modcmd_t cmd, void *opaque
 	}
 }
 
-static void
-chacha_guarantee_selected(void)
-{
-#if 0
-	static once_t once;
-	int error;
-
-	error = RUN_ONCE(, chacha_select);
-	KASSERT(error == 0);
-#endif
-}
-
 void
 chacha_md_init(const struct chacha_impl *impl)
 {
 
 	KASSERT(cold);
-	KASSERTMSG(chacha_impl == NULL,
-	"ChaCha implementation `%s' already chosen, can't offer `%s'",
-	chacha_impl->ci_name, impl->ci_name);
 	KASSERTMSG(chacha_md_impl == NULL,
 	"ChaCha implementation `%s' already offered, can't offer `%s'",
 	chacha_md_impl->ci_name, impl->ci_name);
@@ -153,7 +124,6 @@ chacha_core(uint8_t out[restrict static 
 unsigned nr)
 {
 
-	chacha_guarantee_selected();
 	(*chacha_impl->ci_chacha_core)(out, in, k, c, nr);
 }
 
@@ -165,7 +135,6 @@ hchacha(uint8_t out[restrict static HCHA
 unsigned nr)
 {
 
-	chacha_guarantee_selected();
 	(*chacha_impl->ci_hchacha)(out, in, k, c, nr);
 }
 
@@ -176,7 +145,6 @@ chacha_stream(uint8_t *restrict s, size_
 unsigned nr)
 {
 
-	chacha_guarantee_selected();
 	(*chacha_impl->ci_chacha_stream)(s, nbytes, blkno, nonce, key, nr);
 }
 
@@ -187,7 +155,6 @@ chacha_stream_xor(uint8_t *c, const uint
 unsigned nr)
 {
 
-	chacha_guarantee_selected();
 	(*chacha_impl->ci_chacha_stream_xor)(c, p, nbytes, blkno, nonce, key,
 	nr);
 }
@@ -199,7 +166,6 @@ xchacha_stream(uint8_t *restrict s, size
 unsigned nr)
 {
 
-	chacha_guarantee_selected();
 	(*chacha_impl->ci_xchacha_stream)(s, nbytes, blkno, nonce, key, nr);
 }
 
@@ -210,7 +176,6 @@ xchacha_stream_xor(uint8_t *c, const uin
 unsigned nr)
 {
 
-	chacha_guarantee_selected();
 	(*chacha_impl->ci_xchacha_stream_xor)(c, p, nbytes, blkno, nonce, key,
 	nr);
 }



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

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:49:46 UTC 2020

Modified Files:
src/sys/arch/arm/conf: files.arm

Log Message:
Fix outdated comment.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sys/arch/arm/conf/files.arm

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/conf/files.arm
diff -u src/sys/arch/arm/conf/files.arm:1.158 src/sys/arch/arm/conf/files.arm:1.159
--- src/sys/arch/arm/conf/files.arm:1.158	Mon Jun 29 23:56:31 2020
+++ src/sys/arch/arm/conf/files.arm	Mon Jul 27 20:49:45 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.arm,v 1.158 2020/06/29 23:56:31 riastradh Exp $
+#	$NetBSD: files.arm,v 1.159 2020/07/27 20:49:45 riastradh Exp $
 
 # temporary define to allow easy moving to ../arch/arm/arm32
 defflagARM32
@@ -263,6 +263,5 @@ file	arch/arm/arm/linux_trap.c		compat_l
 # profiling support
 file	dev/tprof/tprof_armv7.c			tprof
 
-# vpaes with ARM NEON -- disabled for now pending arm32 kernel fpu
-# support and ctf
+# vpaes with ARM NEON
 include "crypto/aes/arch/arm/files.aesneon"



CVS commit: src/sys/crypto/chacha/arch

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:48:18 UTC 2020

Modified Files:
src/sys/crypto/chacha/arch/arm: chacha_neon.c
src/sys/crypto/chacha/arch/x86: chacha_sse2.c

Log Message:
Reduce some duplication.

Shouldn't substantively hurt performance -- the comparison that has
been moved into the loop was essentially the former loop condition --
and may improve performance by reducing code size since there's only
one inline call to chacha_permute instead of two.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/chacha/arch/arm/chacha_neon.c
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/chacha/arch/x86/chacha_sse2.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/crypto/chacha/arch/arm/chacha_neon.c
diff -u src/sys/crypto/chacha/arch/arm/chacha_neon.c:1.1 src/sys/crypto/chacha/arch/arm/chacha_neon.c:1.2
--- src/sys/crypto/chacha/arch/arm/chacha_neon.c:1.1	Sat Jul 25 22:51:57 2020
+++ src/sys/crypto/chacha/arch/arm/chacha_neon.c	Mon Jul 27 20:48:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: chacha_neon.c,v 1.1 2020/07/25 22:51:57 riastradh Exp $	*/
+/*	$NetBSD: chacha_neon.c,v 1.2 2020/07/27 20:48:18 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -168,7 +168,7 @@ chacha_stream_neon(uint8_t *restrict s, 
 			le32dec(nonce + 8)
 		};
 
-		for (; n >= 64; s += 64, n -= 64) {
+		for (; n; s += 64, n -= 64) {
 			r0 = in0;
 			r1 = in1;
 			r2 = in2;
@@ -178,32 +178,25 @@ chacha_stream_neon(uint8_t *restrict s, 
 			r1 = vhtole_u32(vaddq_u32(r1, in1));
 			r2 = vhtole_u32(vaddq_u32(r2, in2));
 			r3 = vhtole_u32(vaddq_u32(r3, in3));
+
+			if (n < 64) {
+uint8_t buf[64] __aligned(16);
+
+vst1q_u32((uint32_t *)buf + 4*0, r0);
+vst1q_u32((uint32_t *)buf + 4*1, r1);
+vst1q_u32((uint32_t *)buf + 4*2, r2);
+vst1q_u32((uint32_t *)buf + 4*3, r3);
+memcpy(s, buf, n);
+
+break;
+			}
+
 			vst1q_u32((uint32_t *)s + 4*0, r0);
 			vst1q_u32((uint32_t *)s + 4*1, r1);
 			vst1q_u32((uint32_t *)s + 4*2, r2);
 			vst1q_u32((uint32_t *)s + 4*3, r3);
 			in3 = vaddq_u32(in3, blkno_inc);
 		}
-
-		if (n) {
-			uint8_t buf[64];
-
-			r0 = in0;
-			r1 = in1;
-			r2 = in2;
-			r3 = in3;
-			chacha_permute(, , , , nr);
-			r0 = vhtole_u32(vaddq_u32(r0, in0));
-			r1 = vhtole_u32(vaddq_u32(r1, in1));
-			r2 = vhtole_u32(vaddq_u32(r2, in2));
-			r3 = vhtole_u32(vaddq_u32(r3, in3));
-			vst1q_u32((uint32_t *)buf + 4*0, r0);
-			vst1q_u32((uint32_t *)buf + 4*1, r1);
-			vst1q_u32((uint32_t *)buf + 4*2, r2);
-			vst1q_u32((uint32_t *)buf + 4*3, r3);
-
-			memcpy(s, buf, n);
-		}
 	}
 }
 
@@ -234,7 +227,7 @@ chacha_stream_xor_neon(uint8_t *s, const
 			le32dec(nonce + 8)
 		};
 
-		for (; n >= 64; s += 64, p += 64, n -= 64) {
+		for (; n; s += 64, p += 64, n -= 64) {
 			r0 = in0;
 			r1 = in1;
 			r2 = in2;
@@ -244,6 +237,25 @@ chacha_stream_xor_neon(uint8_t *s, const
 			r1 = vhtole_u32(vaddq_u32(r1, in1));
 			r2 = vhtole_u32(vaddq_u32(r2, in2));
 			r3 = vhtole_u32(vaddq_u32(r3, in3));
+
+			if (n < 64) {
+uint8_t buf[64] __aligned(16);
+unsigned i;
+
+vst1q_u32((uint32_t *)buf + 4*0, r0);
+vst1q_u32((uint32_t *)buf + 4*1, r1);
+vst1q_u32((uint32_t *)buf + 4*2, r2);
+vst1q_u32((uint32_t *)buf + 4*3, r3);
+
+for (i = 0; i < n - n%4; i += 4)
+	le32enc(s + i,
+	le32dec(p + i) ^ le32dec(buf + i));
+for (; i < n; i++)
+	s[i] = p[i] ^ buf[i];
+
+break;
+			}
+
 			r0 ^= vld1q_u32((const uint32_t *)p + 4*0);
 			r1 ^= vld1q_u32((const uint32_t *)p + 4*1);
 			r2 ^= vld1q_u32((const uint32_t *)p + 4*2);
@@ -254,31 +266,6 @@ chacha_stream_xor_neon(uint8_t *s, const
 			vst1q_u32((uint32_t *)s + 4*3, r3);
 			in3 = vaddq_u32(in3, blkno_inc);
 		}
-
-		if (n) {
-			uint8_t buf[64];
-			unsigned i;
-
-			r0 = in0;
-			r1 = in1;
-			r2 = in2;
-			r3 = in3;
-			chacha_permute(, , , , nr);
-			r0 = vhtole_u32(vaddq_u32(r0, in0));
-			r1 = vhtole_u32(vaddq_u32(r1, in1));
-			r2 = vhtole_u32(vaddq_u32(r2, in2));
-			r3 = vhtole_u32(vaddq_u32(r3, in3));
-			vst1q_u32((uint32_t *)buf + 4*0, r0);
-			vst1q_u32((uint32_t *)buf + 4*1, r1);
-			vst1q_u32((uint32_t *)buf + 4*2, r2);
-			vst1q_u32((uint32_t *)buf + 4*3, r3);
-
-			for (i = 0; i < n - n%4; i += 4)
-le32enc(s + i,
-le32dec(p + i) ^ le32dec(buf + i));
-			for (; i < n; i++)
-s[i] = p[i] ^ buf[i];
-		}
 	}
 }
 

Index: src/sys/crypto/chacha/arch/x86/chacha_sse2.c
diff -u src/sys/crypto/chacha/arch/x86/chacha_sse2.c:1.1 src/sys/crypto/chacha/arch/x86/chacha_sse2.c:1.2
--- src/sys/crypto/chacha/arch/x86/chacha_sse2.c:1.1	Sat Jul 25 22:49:20 2020
+++ src/sys/crypto/chacha/arch/x86/chacha_sse2.c	Mon Jul 27 20:48:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: chacha_sse2.c,v 1.1 2020/07/25 22:49:20 riastradh Exp $	*/
+/*	$NetBSD: chacha_sse2.c,v 1.2 2020/07/27 20:48:18 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD 

CVS commit: src

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 20:46:18 UTC 2020

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

Log Message:
make(1): add tests for parsing directives like .if and .info


To generate a diff of this commit:
cvs rdiff -u -r1.879 -r1.880 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/directives.exp \
src/usr.bin/make/unit-tests/directives.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.879 src/distrib/sets/lists/tests/mi:1.880
--- src/distrib/sets/lists/tests/mi:1.879	Mon Jul 27 18:51:03 2020
+++ src/distrib/sets/lists/tests/mi	Mon Jul 27 20:46:18 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.879 2020/07/27 18:51:03 rillig Exp $
+# $NetBSD: mi,v 1.880 2020/07/27 20:46:18 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4534,6 +4534,8 @@
 ./usr/tests/usr.bin/make/unit-tests/cond1.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond2.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond2.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/directives.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/directives.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dollar.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dollar.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/doterror.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.69 src/usr.bin/make/unit-tests/Makefile:1.70
--- src/usr.bin/make/unit-tests/Makefile:1.69	Mon Jul 27 19:45:56 2020
+++ src/usr.bin/make/unit-tests/Makefile	Mon Jul 27 20:46:17 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.69 2020/07/27 19:45:56 rillig Exp $
+# $NetBSD: Makefile,v 1.70 2020/07/27 20:46:17 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -36,6 +36,7 @@ TESTS+=		cond-late
 TESTS+=		cond-short
 TESTS+=		cond1
 TESTS+=		cond2
+TESTS+=		directives
 TESTS+=		dollar
 TESTS+=		doterror
 TESTS+=		dotwait

Added files:

Index: src/usr.bin/make/unit-tests/directives.exp
diff -u /dev/null src/usr.bin/make/unit-tests/directives.exp:1.1
--- /dev/null	Mon Jul 27 20:46:18 2020
+++ src/usr.bin/make/unit-tests/directives.exp	Mon Jul 27 20:46:17 2020
@@ -0,0 +1,30 @@
+make: "directives.mk" line 10: begin .export tests
+make: "directives.mk" line 11: Unknown directive
+make: "directives.mk" line 20: begin .export-env tests
+make: "directives.mk" line 30: begin .export-literal tests
+make: "directives.mk" line 40: begin .info tests
+make: "directives.mk" line 41: Unknown directive
+make: "directives.mk" line 42: Unknown directive
+make: "directives.mk" line 43: message
+make: "directives.mk" line 44: indented message
+make: "directives.mk" line 45: Unknown directive
+make: "directives.mk" line 46: message
+make: "directives.mk" line 50: begin .undef tests
+make: "directives.mk" line 51: Unknown directive
+make: "directives.mk" line 60: begin .unexport tests
+make: "directives.mk" line 61: Unknown directive
+make: "directives.mk" line 70: begin .unexport-env tests
+make: "directives.mk" line 80: begin .warning tests
+make: "directives.mk" line 81: Unknown directive
+make: "directives.mk" line 82: Unknown directive
+make: "directives.mk" line 83: Unknown directive
+make: "directives.mk" line 84: warning: message
+make: "directives.mk" line 85: Unknown directive
+make: "directives.mk" line 86: warning: messages
+make: "directives.mk" line 90: begin .elif misspellings tests, part 1
+make: "directives.mk" line 100: begin .elif misspellings tests, part 2
+make: "directives.mk" line 110: begin .elif misspellings tests, part 3
+make: "directives.mk" line 120: end of the tests
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/directives.mk
diff -u /dev/null src/usr.bin/make/unit-tests/directives.mk:1.1
--- /dev/null	Mon Jul 27 20:46:18 2020
+++ src/usr.bin/make/unit-tests/directives.mk	Mon Jul 27 20:46:17 2020
@@ -0,0 +1,123 @@
+# $NetBSD: directives.mk,v 1.1 2020/07/27 20:46:17 rillig Exp $
+#
+# Tests for parsing directives, in the same order as in the manual page.
+#
+# Each test group has 10 lines, to keep the expected file stable.
+#
+# no tests for .error since it exits immediately, see ParseMessage.
+
+
+.info begin .export tests
+.expor# misspelled
+.export# oops: missing argument
+.export VARNAME
+.exporting works		# oops: misspelled
+
+

CVS commit: src/sys/crypto

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:45:15 UTC 2020

Modified Files:
src/sys/crypto/aes: aes_impl.c
src/sys/crypto/chacha: chacha_impl.c

Log Message:
New sysctl subtree kern.crypto.

kern.crypto.aes.selected (formerly hw.aes_impl)
kern.crypto.chacha.selected (formerly hw.chacha_impl)

XXX Should maybe deduplicate creation of kern.crypto.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/crypto/aes/aes_impl.c
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/chacha/chacha_impl.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/crypto/aes/aes_impl.c
diff -u src/sys/crypto/aes/aes_impl.c:1.8 src/sys/crypto/aes/aes_impl.c:1.9
--- src/sys/crypto/aes/aes_impl.c:1.8	Sat Jul 25 22:42:03 2020
+++ src/sys/crypto/aes/aes_impl.c	Mon Jul 27 20:45:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aes_impl.c,v 1.8 2020/07/25 22:42:03 riastradh Exp $	*/
+/*	$NetBSD: aes_impl.c,v 1.9 2020/07/27 20:45:15 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aes_impl.c,v 1.8 2020/07/25 22:42:03 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_impl.c,v 1.9 2020/07/27 20:45:15 riastradh Exp $");
 
 #include 
 #include 
@@ -48,7 +48,7 @@ static const struct aes_impl	*aes_md_imp
 static const struct aes_impl	*aes_impl	__read_mostly;
 
 static int
-sysctl_hw_aes_impl(SYSCTLFN_ARGS)
+sysctl_kern_crypto_aes_selected(SYSCTLFN_ARGS)
 {
 	struct sysctlnode node;
 
@@ -61,14 +61,24 @@ sysctl_hw_aes_impl(SYSCTLFN_ARGS)
 	return sysctl_lookup(SYSCTLFN_CALL());
 }
 
-SYSCTL_SETUP(sysctl_hw_aes_setup, "sysctl hw.aes_impl setup")
+SYSCTL_SETUP(sysctl_kern_crypto_aes_setup, "sysctl kern.crypto.aes setup")
 {
+	const struct sysctlnode *cnode;
+	const struct sysctlnode *aes_node;
 
-	sysctl_createv(clog, 0, NULL, NULL,
-	CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_STRING, "aes_impl",
+	sysctl_createv(clog, 0, NULL, , 0, CTLTYPE_NODE, "crypto",
+	SYSCTL_DESCR("Kernel cryptography"),
+	NULL, 0, NULL, 0,
+	CTL_KERN, CTL_CREATE, CTL_EOL);
+	sysctl_createv(clog, 0, , _node, 0, CTLTYPE_NODE, "aes",
+	SYSCTL_DESCR("AES -- Advanced Encryption Standard"),
+	NULL, 0, NULL, 0,
+	CTL_CREATE, CTL_EOL);
+	sysctl_createv(clog, 0, _node, NULL,
+	CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_STRING, "selected",
 	SYSCTL_DESCR("Selected AES implementation"),
-	sysctl_hw_aes_impl, 0, NULL, 0,
-	CTL_HW, CTL_CREATE, CTL_EOL);
+	sysctl_kern_crypto_aes_selected, 0, NULL, 0,
+	CTL_CREATE, CTL_EOL);
 }
 
 /*

Index: src/sys/crypto/chacha/chacha_impl.c
diff -u src/sys/crypto/chacha/chacha_impl.c:1.1 src/sys/crypto/chacha/chacha_impl.c:1.2
--- src/sys/crypto/chacha/chacha_impl.c:1.1	Sat Jul 25 22:46:34 2020
+++ src/sys/crypto/chacha/chacha_impl.c	Mon Jul 27 20:45:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: chacha_impl.c,v 1.1 2020/07/25 22:46:34 riastradh Exp $	*/
+/*	$NetBSD: chacha_impl.c,v 1.2 2020/07/27 20:45:15 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@ static const struct chacha_impl	*chacha_
 static const struct chacha_impl	*chacha_impl	__read_mostly;
 
 static int
-sysctl_hw_chacha_impl(SYSCTLFN_ARGS)
+sysctl_kern_crypto_chacha_selected(SYSCTLFN_ARGS)
 {
 	struct sysctlnode node;
 
@@ -55,14 +55,24 @@ sysctl_hw_chacha_impl(SYSCTLFN_ARGS)
 	return sysctl_lookup(SYSCTLFN_CALL());
 }
 
-SYSCTL_SETUP(sysctl_hw_chacha_setup, "sysctl hw.chacha_impl setup")
+SYSCTL_SETUP(sysctl_kern_crypto_chacha_setup, "sysctl kern.crypto.chacha setup")
 {
+	const struct sysctlnode *cnode;
+	const struct sysctlnode *chacha_node;
 
-	sysctl_createv(clog, 0, NULL, NULL,
-	CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_STRING, "chacha_impl",
+	sysctl_createv(clog, 0, NULL, , 0, CTLTYPE_NODE, "crypto",
+	SYSCTL_DESCR("Kernel cryptography"),
+	NULL, 0, NULL, 0,
+	CTL_KERN, CTL_CREATE, CTL_EOL);
+	sysctl_createv(clog, 0, , _node, 0, CTLTYPE_NODE, "chacha",
+	SYSCTL_DESCR("ChaCha"),
+	NULL, 0, NULL, 0,
+	CTL_CREATE, CTL_EOL);
+	sysctl_createv(clog, 0, _node, NULL,
+	CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_STRING, "selected",
 	SYSCTL_DESCR("Selected ChaCha implementation"),
-	sysctl_hw_chacha_impl, 0, NULL, 0,
-	CTL_HW, CTL_CREATE, CTL_EOL);
+	sysctl_kern_crypto_chacha_selected, 0, NULL, 0,
+	CTL_CREATE, CTL_EOL);
 }
 
 static int



CVS commit: src/sys/crypto/aes

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 20:44:30 UTC 2020

Modified Files:
src/sys/crypto/aes: aes_ccm.c aes_ccm.h

Log Message:
Gather auth[16] and ctr[16] into one authctr[32].

Should appease clang.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/crypto/aes/aes_ccm.c
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/aes/aes_ccm.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/crypto/aes/aes_ccm.c
diff -u src/sys/crypto/aes/aes_ccm.c:1.3 src/sys/crypto/aes/aes_ccm.c:1.4
--- src/sys/crypto/aes/aes_ccm.c:1.3	Sun Jul 26 04:44:47 2020
+++ src/sys/crypto/aes/aes_ccm.c	Mon Jul 27 20:44:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aes_ccm.c,v 1.3 2020/07/26 04:44:47 riastradh Exp $	*/
+/*	$NetBSD: aes_ccm.c,v 1.4 2020/07/27 20:44:30 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aes_ccm.c,v 1.3 2020/07/26 04:44:47 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_ccm.c,v 1.4 2020/07/27 20:44:30 riastradh Exp $");
 
 #include 
 #include 
@@ -66,18 +66,20 @@ xor(uint8_t *x, const uint8_t *a, const 
 static void
 aes_ccm_inc(struct aes_ccm *C)
 {
+	uint8_t *ctr = C->authctr + 16;
 
 	KASSERT(C->L == 2);
-	if (++C->in[15] == 0 && ++C->in[14] == 0)
+	if (++ctr[15] == 0 && ++ctr[14] == 0)
 		panic("AES-CCM overflow");
 }
 
 static void
 aes_ccm_zero_ctr(struct aes_ccm *C)
 {
+	uint8_t *ctr = C->authctr + 16;
 
 	KASSERT(C->L == 2);
-	C->in[14] = C->in[15] = 0;
+	ctr[14] = ctr[15] = 0;
 }
 
 void
@@ -87,6 +89,8 @@ aes_ccm_init(struct aes_ccm *C, unsigned
 size_t mlen)
 {
 	const uint8_t *adp = ad;
+	uint8_t *auth = C->authctr;
+	uint8_t *ctr = C->authctr + 16;
 	unsigned i;
 
 	KASSERT(L == 2);
@@ -102,58 +106,58 @@ aes_ccm_init(struct aes_ccm *C, unsigned
 	C->mlen = C->mleft = mlen;
 
 	/* Encode B0, the initial authenticated data block.  */
-	C->auth[0] = __SHIFTIN(adlen == 0 ? 0 : 1, CCM_AFLAGS_ADATA);
-	C->auth[0] |= __SHIFTIN((M - 2)/2, CCM_AFLAGS_M);
-	C->auth[0] |= __SHIFTIN(L - 1, CCM_AFLAGS_L);
-	memcpy(C->auth + 1, nonce, noncelen);
+	auth[0] = __SHIFTIN(adlen == 0 ? 0 : 1, CCM_AFLAGS_ADATA);
+	auth[0] |= __SHIFTIN((M - 2)/2, CCM_AFLAGS_M);
+	auth[0] |= __SHIFTIN(L - 1, CCM_AFLAGS_L);
+	memcpy(auth + 1, nonce, noncelen);
 	for (i = 0; i < L; i++, mlen >>= 8) {
 		KASSERT(i < 16 - 1 - noncelen);
-		C->auth[16 - i - 1] = mlen & 0xff;
+		auth[16 - i - 1] = mlen & 0xff;
 	}
-	aes_enc(enc, C->auth, C->auth, C->nr);
+	aes_enc(enc, auth, auth, C->nr);
 
 	/* Process additional authenticated data, if any.  */
 	if (adlen) {
 		/* Encode the length according to the table on p. 4.  */
 		if (adlen < 0xff00) {
-			C->auth[0] ^= adlen >> 8;
-			C->auth[1] ^= adlen;
+			auth[0] ^= adlen >> 8;
+			auth[1] ^= adlen;
 			i = 2;
 		} else if (adlen < 0x) {
-			C->auth[0] ^= 0xff;
-			C->auth[1] ^= 0xfe;
-			C->auth[2] ^= adlen >> 24;
-			C->auth[3] ^= adlen >> 16;
-			C->auth[4] ^= adlen >> 8;
-			C->auth[5] ^= adlen;
+			auth[0] ^= 0xff;
+			auth[1] ^= 0xfe;
+			auth[2] ^= adlen >> 24;
+			auth[3] ^= adlen >> 16;
+			auth[4] ^= adlen >> 8;
+			auth[5] ^= adlen;
 			i = 6;
 #if SIZE_MAX > 0xU
 		} else {
 			CTASSERT(SIZE_MAX <= 0x);
-			C->auth[0] ^= 0xff;
-			C->auth[1] ^= 0xff;
-			C->auth[2] ^= adlen >> 56;
-			C->auth[3] ^= adlen >> 48;
-			C->auth[4] ^= adlen >> 40;
-			C->auth[5] ^= adlen >> 32;
-			C->auth[6] ^= adlen >> 24;
-			C->auth[7] ^= adlen >> 16;
-			C->auth[8] ^= adlen >> 8;
-			C->auth[9] ^= adlen;
+			auth[0] ^= 0xff;
+			auth[1] ^= 0xff;
+			auth[2] ^= adlen >> 56;
+			auth[3] ^= adlen >> 48;
+			auth[4] ^= adlen >> 40;
+			auth[5] ^= adlen >> 32;
+			auth[6] ^= adlen >> 24;
+			auth[7] ^= adlen >> 16;
+			auth[8] ^= adlen >> 8;
+			auth[9] ^= adlen;
 			i = 10;
 #endif
 		}
 
 		/* Fill out the partial block if we can, and encrypt.  */
-		xor(C->auth + i, C->auth + i, adp, MIN(adlen, 16 - i));
+		xor(auth + i, auth + i, adp, MIN(adlen, 16 - i));
 		adp += MIN(adlen, 16 - i);
 		adlen -= MIN(adlen, 16 - i);
-		aes_enc(enc, C->auth, C->auth, C->nr);
+		aes_enc(enc, auth, auth, C->nr);
 
 		/* If there was anything more, process 16 bytes at a time.  */
 		if (adlen - (adlen % 16)) {
 			aes_cbcmac_update1(enc, adp, adlen - (adlen % 16),
-			C->auth, C->nr);
+			auth, C->nr);
 			adlen %= 16;
 		}
 
@@ -162,15 +166,15 @@ aes_ccm_init(struct aes_ccm *C, unsigned
 		 * with zeros, which is a no-op) and process it.
 		 */
 		if (adlen) {
-			xor(C->auth, C->auth, adp, adlen);
-			aes_enc(enc, C->auth, C->auth, C->nr);
+			xor(auth, auth, adp, adlen);
+			aes_enc(enc, auth, auth, C->nr);
 		}
 	}
 
 	/* Set up the AES input for AES-CTR encryption.  */
-	C->in[0] = __SHIFTIN(L - 1, CCM_EFLAGS_L);
-	memcpy(C->in + 1, nonce, noncelen);
-	memset(C->in + 1 + noncelen, 0, 16 - 1 - noncelen);
+	ctr[0] = __SHIFTIN(L - 1, CCM_EFLAGS_L);
+	

CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 19:59:59 UTC 2020

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

Log Message:
make(1): remove unnecessary argument validation


To generate a diff of this commit:
cvs rdiff -u -r1.337 -r1.338 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.337 src/usr.bin/make/var.c:1.338
--- src/usr.bin/make/var.c:1.337	Mon Jul 27 17:41:09 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 19:59:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.337 2020/07/27 17:41:09 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.338 2020/07/27 19:59:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.337 2020/07/27 17:41:09 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.338 2020/07/27 19:59:59 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.337 2020/07/27 17:41:09 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.338 2020/07/27 19:59:59 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -690,6 +690,8 @@ extern char **environ;
 
 /*
  * This is called when .unexport[-env] is seen.
+ *
+ * str must have the form "unexport[-env] varname...".
  */
 void
 Var_UnExport(char *str)
@@ -700,12 +702,9 @@ Var_UnExport(char *str)
 Boolean unexport_env;
 int n;
 
-if (str == NULL || str[0] == '\0')
-	return;			/* assert? */
-
 vlist = NULL;
 
-str += 8;
+str += strlen("unexport");
 unexport_env = (strncmp(str, "-env", 4) == 0);
 if (unexport_env) {
 	char **newenv;



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

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 19:53:37 UTC 2020

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

Log Message:
make(1): add test for exporting single-character variables


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/export.exp \
src/usr.bin/make/unit-tests/export.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/export.exp
diff -u src/usr.bin/make/unit-tests/export.exp:1.2 src/usr.bin/make/unit-tests/export.exp:1.3
--- src/usr.bin/make/unit-tests/export.exp:1.2	Mon Jul 27 19:45:56 2020
+++ src/usr.bin/make/unit-tests/export.exp	Mon Jul 27 19:53:37 2020
@@ -1,3 +1,4 @@
+&=ampersand
 .MAKE.LEVEL.ENV=MAKELEVEL
 MAKELEVEL=1
 UT_DOLLAR=This is $UT_FU
Index: src/usr.bin/make/unit-tests/export.mk
diff -u src/usr.bin/make/unit-tests/export.mk:1.2 src/usr.bin/make/unit-tests/export.mk:1.3
--- src/usr.bin/make/unit-tests/export.mk:1.2	Mon Jul 27 19:45:56 2020
+++ src/usr.bin/make/unit-tests/export.mk	Mon Jul 27 19:53:37 2020
@@ -1,4 +1,4 @@
-# $Id: export.mk,v 1.2 2020/07/27 19:45:56 rillig Exp $
+# $Id: export.mk,v 1.3 2020/07/27 19:53:37 rillig Exp $
 
 UT_TEST=export
 UT_FOO=foo${BAR}
@@ -10,8 +10,28 @@ UT_DOLLAR= This is $$UT_FU
 
 .export UT_FU UT_FOO
 .export UT_DOLLAR
-# this one will be ignored
+
+.if !defined(.MAKE.PID)
+.error .MAKE.PID must be defined
+.endif
+@=	at
+%=	percent
+*=	asterisk
+${:U!}=	exclamation		# A direct != would try to run "exclamation"
+# as a shell command and assign its output
+# to the empty variable.
+&=	ampersand
+
+# This is ignored because it is internal.
 .export .MAKE.PID
+# These are ignored because they are local to the target.
+.export @
+.export %
+.export *
+.export !
+.export &
+# This is ignored because it is undefined.
+.export UNDEFINED
 
 BAR=bar is ${UT_FU}
 



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

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 19:45:56 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile export-all.mk export.exp
export.mk unexport-env.mk unexport.mk

Log Message:
make(1): prepare test for .export to show all exported variables

Currently the unit tests don't cover exporting of local variables like
.TARGET or @.  To see the effects, all exported variables must be listed
by the tests.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/export-all.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/export.exp \
src/usr.bin/make/unit-tests/export.mk \
src/usr.bin/make/unit-tests/unexport-env.mk \
src/usr.bin/make/unit-tests/unexport.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/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.68 src/usr.bin/make/unit-tests/Makefile:1.69
--- src/usr.bin/make/unit-tests/Makefile:1.68	Mon Jul 27 19:23:12 2020
+++ src/usr.bin/make/unit-tests/Makefile	Mon Jul 27 19:45:56 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.68 2020/07/27 19:23:12 rillig Exp $
+# $NetBSD: Makefile,v 1.69 2020/07/27 19:45:56 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -79,6 +79,7 @@ TESTS+=		varshell
 
 # Override environment variables for some of the tests.
 ENV.envfirst=		FROM_ENV=value-from-env
+ENV.export=		-i PATH=${PATH:Q}
 ENV.varmisc=		FROM_ENV=env
 ENV.varmisc+=		FROM_ENV_BEFORE=env
 ENV.varmisc+=		FROM_ENV_AFTER=env
@@ -133,7 +134,7 @@ LANG=		C
 	@echo testing ${.IMPSRC}
 	@set -eu; \
 	cd ${.OBJDIR}; \
-	${ENV.${.TARGET:R}} ${TEST_MAKE} \
+	env ${ENV.${.TARGET:R}} ${TEST_MAKE} \
 	  ${FLAGS.${.TARGET:R}:U-k} -f ${.IMPSRC} \
 	  > ${.TARGET}.tmp 2>&1 \
 	&& status=$$? || status=$$?; \

Index: src/usr.bin/make/unit-tests/export-all.mk
diff -u src/usr.bin/make/unit-tests/export-all.mk:1.2 src/usr.bin/make/unit-tests/export-all.mk:1.3
--- src/usr.bin/make/unit-tests/export-all.mk:1.2	Fri Apr 10 20:41:59 2015
+++ src/usr.bin/make/unit-tests/export-all.mk	Mon Jul 27 19:45:56 2020
@@ -1,4 +1,4 @@
-# $Id: export-all.mk,v 1.2 2015/04/10 20:41:59 sjg Exp $
+# $Id: export-all.mk,v 1.3 2020/07/27 19:45:56 rillig Exp $
 
 UT_OK=good
 UT_F=fine
@@ -17,6 +17,7 @@ UT_OKDIR = ${${here}/../${here:T}:L:${M_
 
 .export
 
+FILTER_CMD=	grep ^UT_
 .include "export.mk"
 
 UT_TEST=export-all

Index: src/usr.bin/make/unit-tests/export.exp
diff -u src/usr.bin/make/unit-tests/export.exp:1.1 src/usr.bin/make/unit-tests/export.exp:1.2
--- src/usr.bin/make/unit-tests/export.exp:1.1	Thu Aug 21 13:44:51 2014
+++ src/usr.bin/make/unit-tests/export.exp	Mon Jul 27 19:45:56 2020
@@ -1,3 +1,5 @@
+.MAKE.LEVEL.ENV=MAKELEVEL
+MAKELEVEL=1
 UT_DOLLAR=This is $UT_FU
 UT_FOO=foobar is fubar
 UT_FU=fubar
Index: src/usr.bin/make/unit-tests/export.mk
diff -u src/usr.bin/make/unit-tests/export.mk:1.1 src/usr.bin/make/unit-tests/export.mk:1.2
--- src/usr.bin/make/unit-tests/export.mk:1.1	Thu Aug 21 13:44:51 2014
+++ src/usr.bin/make/unit-tests/export.mk	Mon Jul 27 19:45:56 2020
@@ -1,4 +1,4 @@
-# $Id: export.mk,v 1.1 2014/08/21 13:44:51 apb Exp $
+# $Id: export.mk,v 1.2 2020/07/27 19:45:56 rillig Exp $
 
 UT_TEST=export
 UT_FOO=foo${BAR}
@@ -17,6 +17,7 @@ BAR=bar is ${UT_FU}
 
 .MAKE.EXPORTED+= UT_ZOO UT_TEST
 
-all:
-	@env | grep '^UT_' | sort
+FILTER_CMD?=	grep -v -E '^(MAKEFLAGS|PATH|PWD)='
 
+all:
+	@env | ${FILTER_CMD} | sort
Index: src/usr.bin/make/unit-tests/unexport-env.mk
diff -u src/usr.bin/make/unit-tests/unexport-env.mk:1.1 src/usr.bin/make/unit-tests/unexport-env.mk:1.2
--- src/usr.bin/make/unit-tests/unexport-env.mk:1.1	Thu Aug 21 13:44:52 2014
+++ src/usr.bin/make/unit-tests/unexport-env.mk	Mon Jul 27 19:45:56 2020
@@ -1,6 +1,7 @@
-# $Id: unexport-env.mk,v 1.1 2014/08/21 13:44:52 apb Exp $
+# $Id: unexport-env.mk,v 1.2 2020/07/27 19:45:56 rillig Exp $
 
 # pick up a bunch of exported vars
+FILTER_CMD=	grep ^UT_
 .include "export.mk"
 
 # an example of setting up a minimal environment.
Index: src/usr.bin/make/unit-tests/unexport.mk
diff -u src/usr.bin/make/unit-tests/unexport.mk:1.1 src/usr.bin/make/unit-tests/unexport.mk:1.2
--- src/usr.bin/make/unit-tests/unexport.mk:1.1	Thu Aug 21 13:44:52 2014
+++ src/usr.bin/make/unit-tests/unexport.mk	Mon Jul 27 19:45:56 2020
@@ -1,6 +1,7 @@
-# $Id: unexport.mk,v 1.1 2014/08/21 13:44:52 apb Exp $
+# $Id: unexport.mk,v 1.2 2020/07/27 19:45:56 rillig Exp $
 
 # pick up a bunch of exported vars
+FILTER_CMD=	grep ^UT_
 .include "export.mk"
 
 .unexport UT_ZOO UT_FOO



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

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 19:23:12 UTC 2020

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

Log Message:
make(1): sort flags for test cases alphabetically


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

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.67 src/usr.bin/make/unit-tests/Makefile:1.68
--- src/usr.bin/make/unit-tests/Makefile:1.67	Mon Jul 27 18:51:56 2020
+++ src/usr.bin/make/unit-tests/Makefile	Mon Jul 27 19:23:12 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.67 2020/07/27 18:51:56 rillig Exp $
+# $NetBSD: Makefile,v 1.68 2020/07/27 19:23:12 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -85,8 +85,8 @@ ENV.varmisc+=		FROM_ENV_AFTER=env
 
 # Override make flags for some of the tests; default is -k.
 FLAGS.doterror=		# none
-FLAGS.order=		-j1
 FLAGS.envfirst=		-e
+FLAGS.order=		-j1
 FLAGS.vardebug=		-k -dv FROM_CMDLINE=
 
 # Some tests need extra post-processing.



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 19:06:45 UTC 2020

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

Log Message:
make(1): improve const-correctness in archive handling

The return value of Var_Value must not be modified.  Ideally it would be
declared as const char *, but that still takes a while, especially since
much of the make code is not yet covered by the unit tests.

The variable cp had to be changed to const char * as well, and while here
was split up into one variable per actual use case.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/usr.bin/make/arch.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/arch.c
diff -u src/usr.bin/make/arch.c:1.75 src/usr.bin/make/arch.c:1.76
--- src/usr.bin/make/arch.c:1.75	Sun Jul 26 20:21:31 2020
+++ src/usr.bin/make/arch.c	Mon Jul 27 19:06:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.75 2020/07/26 20:21:31 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.76 2020/07/27 19:06:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.75 2020/07/26 20:21:31 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.76 2020/07/27 19:06:45 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.75 2020/07/26 20:21:31 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.76 2020/07/27 19:06:45 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -168,8 +168,9 @@ static int ArchFindArchive(const void *,
 #ifdef CLEANUP
 static void ArchFree(void *);
 #endif
-static struct ar_hdr *ArchStatMember(char *, char *, Boolean);
-static FILE *ArchFindMember(char *, char *, struct ar_hdr *, const char *);
+static struct ar_hdr *ArchStatMember(const char *, const char *, Boolean);
+static FILE *ArchFindMember(const char *, const char *,
+			struct ar_hdr *, const char *);
 #if defined(__svr4__) || defined(__SVR4) || defined(__ELF__)
 #define SVR4ARCHIVES
 static int ArchSVR4Entry(Arch *, char *, size_t, FILE *);
@@ -523,12 +524,11 @@ ArchFindArchive(const void *ar, const vo
  *---
  */
 static struct ar_hdr *
-ArchStatMember(char *archive, char *member, Boolean hash)
+ArchStatMember(const char *archive, const char *member, Boolean hash)
 {
 #define AR_MAX_NAME_LEN	(sizeof(arh.ar_name)-1)
 FILE *	  arch;	  /* Stream to archive */
 int		  size;   /* Size of archive member */
-char	  *cp;	  /* Useful character pointer */
 char	  magic[SARMAG];
 LstNode	  ln;	  /* Lst member containing archive descriptor */
 Arch	  *ar;	  /* Archive descriptor */
@@ -543,9 +543,9 @@ ArchStatMember(char *archive, char *memb
  * to point 'member' to the final component, if there is one, to make
  * the comparisons easier...
  */
-cp = strrchr(member, '/');
-if (cp != NULL) {
-	member = cp + 1;
+const char *base = strrchr(member, '/');
+if (base != NULL) {
+	member = base + 1;
 }
 
 ln = Lst_Find(archives, archive, ArchFindArchive);
@@ -636,10 +636,11 @@ ArchStatMember(char *archive, char *memb
 	size = (int)strtol(arh.ar_size, NULL, 10);
 
 	memcpy(memName, arh.ar_name, sizeof(arh.ar_name));
-	for (cp = [AR_MAX_NAME_LEN]; *cp == ' '; cp--) {
-		continue;
+	char *nameend = memName + AR_MAX_NAME_LEN;
+	while (*nameend == ' ') {
+		nameend--;
 	}
-	cp[1] = '\0';
+	nameend[1] = '\0';
 
 #ifdef SVR4ARCHIVES
 	/*
@@ -659,8 +660,8 @@ ArchStatMember(char *archive, char *memb
 		}
 	}
 	else {
-		if (cp[0] == '/')
-		cp[0] = '\0';
+		if (nameend[0] == '/')
+		nameend[0] = '\0';
 	}
 #endif
 
@@ -846,12 +847,11 @@ ArchSVR4Entry(Arch *ar, char *name, size
  *---
  */
 static FILE *
-ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
+ArchFindMember(const char *archive, const char *member, struct ar_hdr *arhPtr,
 const char *mode)
 {
 FILE *	  arch;	  /* Stream to archive */
 int		  size;   /* Size of archive member */
-char	  *cp;	  /* Useful character pointer */
 char	  magic[SARMAG];
 size_t	  len, tlen;
 
@@ -876,9 +876,9 @@ ArchFindMember(char *archive, char *memb
  * to point 'member' to the final component, if there is one, to make
  * the comparisons easier...
  */
-cp = strrchr(member, '/');
-if (cp != NULL) {
-	member = cp + 1;
+const char *base = strrchr(member, '/');
+if (base != NULL) {
+	member = base + 1;
 }
 len = tlen = strlen(member);
 if (len > sizeof(arhPtr->ar_name)) {



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 18:59:56 UTC 2020

Added Files:
src/usr.bin/make: .cvsignore

Log Message:
make(1): ignore gcov files for CVS


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/.cvsignore

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

Added files:

Index: src/usr.bin/make/.cvsignore
diff -u /dev/null src/usr.bin/make/.cvsignore:1.1
--- /dev/null	Mon Jul 27 18:59:56 2020
+++ src/usr.bin/make/.cvsignore	Mon Jul 27 18:59:56 2020
@@ -0,0 +1,3 @@
+*.gcov
+*.gcda
+*.gcno



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

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 18:57:42 UTC 2020

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

Log Message:
make(1): add test for unsetting an environment variable in -e mode


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/envfirst.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/envfirst.mk
diff -u src/usr.bin/make/unit-tests/envfirst.mk:1.1 src/usr.bin/make/unit-tests/envfirst.mk:1.2
--- src/usr.bin/make/unit-tests/envfirst.mk:1.1	Sat Jul 25 21:19:29 2020
+++ src/usr.bin/make/unit-tests/envfirst.mk	Mon Jul 27 18:57:42 2020
@@ -1,4 +1,4 @@
-# $NetBSD: envfirst.mk,v 1.1 2020/07/25 21:19:29 rillig Exp $
+# $NetBSD: envfirst.mk,v 1.2 2020/07/27 18:57:42 rillig Exp $
 #
 # The -e option makes environment variables stronger than global variables.
 
@@ -31,5 +31,12 @@ FROM_ENV?=	default
 .error ${FROM_ENV}
 .endif
 
+# Even .undef doesn't work since it only affects the global context,
+# which is independent from the environment variables.
+.undef FROM_ENV
+.if ${FROM_ENV} != value-from-env
+.error ${FROM_ENV}
+.endif
+
 all:
 	@: nothing



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

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 18:51:56 UTC 2020

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

Log Message:
make(1): add very basic test for archive handling

The whole code in arch.c had been uncovered by tests before.

The code coverage shows that neither the archive name nor the member
contain any $, even though archive.mk looks like it.  It could be
necessary to place the variable assignments below the dependency line,
to force late evaluation.


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

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.66 src/usr.bin/make/unit-tests/Makefile:1.67
--- src/usr.bin/make/unit-tests/Makefile:1.66	Sun Jul 26 22:15:36 2020
+++ src/usr.bin/make/unit-tests/Makefile	Mon Jul 27 18:51:56 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.66 2020/07/26 22:15:36 rillig Exp $
+# $NetBSD: Makefile,v 1.67 2020/07/27 18:51:56 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -30,6 +30,7 @@
 
 # Each test is in a sub-makefile.
 # Keep the list sorted.
+TESTS+=		archive
 TESTS+=		comment
 TESTS+=		cond-late
 TESTS+=		cond-short



CVS commit: src

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 18:51:03 UTC 2020

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

Log Message:
make(1): add very basic test for archive handling

The whole code in arch.c had been uncovered by tests before.

The code coverage shows that neither the archive name nor the member
contain any $, even though archive.mk looks like it.  It could be
necessary to place the variable assignments below the dependency line,
to force late evaluation.


To generate a diff of this commit:
cvs rdiff -u -r1.878 -r1.879 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/archive.exp \
src/usr.bin/make/unit-tests/archive.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.878 src/distrib/sets/lists/tests/mi:1.879
--- src/distrib/sets/lists/tests/mi:1.878	Sun Jul 26 22:15:36 2020
+++ src/distrib/sets/lists/tests/mi	Mon Jul 27 18:51:03 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.878 2020/07/26 22:15:36 rillig Exp $
+# $NetBSD: mi,v 1.879 2020/07/27 18:51:03 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4522,6 +4522,8 @@
 ./usr/tests/usr.bin/make/t_make			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/Makefile	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/archive.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/archive.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/comment.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/comment.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond-late.exp	tests-usr.bin-tests	compattestfile,atf

Added files:

Index: src/usr.bin/make/unit-tests/archive.exp
diff -u /dev/null src/usr.bin/make/unit-tests/archive.exp:1.1
--- /dev/null	Mon Jul 27 18:51:03 2020
+++ src/usr.bin/make/unit-tests/archive.exp	Mon Jul 27 18:51:03 2020
@@ -0,0 +1,10 @@
+ar cru libprog.a archive.mk modmisc.mk varmisc.mk
+ranlib libprog.a
+ar t libprog.a
+archive.mk
+modmisc.mk
+varmisc.mk
+depend-on-existing-member
+`depend-on-nonexistent-member' is up to date.
+rm libprog.a
+exit status 0
Index: src/usr.bin/make/unit-tests/archive.mk
diff -u /dev/null src/usr.bin/make/unit-tests/archive.mk:1.1
--- /dev/null	Mon Jul 27 18:51:03 2020
+++ src/usr.bin/make/unit-tests/archive.mk	Mon Jul 27 18:51:03 2020
@@ -0,0 +1,37 @@
+# $NetBSD: archive.mk,v 1.1 2020/07/27 18:51:03 rillig Exp $
+#
+# Very basic demonstration of handling archives, based on the description
+# in PSD.doc/tutorial.ms.
+
+ARCHIVE=	libprog.${EXT.a}
+FILES=		archive.${EXT.mk} modmisc.${EXT.mk} varmisc.mk
+
+EXT.a=		a
+EXT.mk=		mk
+
+MAKE_CMD=	${.MAKE} -f ${MAKEFILE}
+RUN?=		@set -eu;
+
+all:
+	${RUN} ${MAKE_CMD} create-archive
+	${RUN} ${MAKE_CMD} list-archive
+	${RUN} ${MAKE_CMD} depend-on-existing-member
+	${RUN} ${MAKE_CMD} depend-on-nonexistent-member
+	${RUN} ${MAKE_CMD} remove-archive
+
+create-archive: ${ARCHIVE}
+${ARCHIVE}: ${ARCHIVE}(${FILES})
+	ar cru ${.TARGET} ${.OODATE}
+	ranlib ${.TARGET}
+
+list-archive: ${ARCHIVE}
+	ar t ${.ALLSRC}
+
+depend-on-existing-member: ${ARCHIVE}(archive.mk)
+	${RUN} echo $@
+
+depend-on-nonexistent-member: ${ARCHIVE}(nonexistent.mk)
+	${RUN} echo $@
+
+remove-archive: ${ARCHIVE}
+	rm ${ARCHIVE}



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

2020-07-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul 27 18:38:10 UTC 2020

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

Log Message:
Skip v2m probe if armgic fails to attach


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/acpi/gic_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/gic_acpi.c
diff -u src/sys/arch/arm/acpi/gic_acpi.c:1.4 src/sys/arch/arm/acpi/gic_acpi.c:1.5
--- src/sys/arch/arm/acpi/gic_acpi.c:1.4	Mon Oct 14 11:00:13 2019
+++ src/sys/arch/arm/acpi/gic_acpi.c	Mon Jul 27 18:38:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_acpi.c,v 1.4 2019/10/14 11:00:13 jmcneill Exp $ */
+/* $NetBSD: gic_acpi.c,v 1.5 2020/07/27 18:38:10 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_acpi.c,v 1.4 2019/10/14 11:00:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_acpi.c,v 1.5 2020/07/27 18:38:10 jmcneill Exp $");
 
 #include 
 #include 
@@ -124,12 +124,13 @@ gic_acpi_attach(device_t parent, device_
 	};
 
 	armgic = config_found(self, , NULL);
-	if (armgic != NULL)
+	if (armgic != NULL) {
 		arm_fdt_irq_set_handler(armgic_irq_handler);
 
 #if NPCI > 0
-	acpi_madt_walk(gic_v2m_acpi_find_msi_frame, armgic);
+		acpi_madt_walk(gic_v2m_acpi_find_msi_frame, armgic);
 #endif
+	}
 }
 
 static ACPI_STATUS



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

2020-07-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul 27 18:36:23 UTC 2020

Modified Files:
src/sys/arch/arm/cortex: gic.c

Log Message:
Remove CPU ID test in armgic_match. Perfectly normal to have GIC in
non-Cortex cores.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/arm/cortex/gic.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/cortex/gic.c
diff -u src/sys/arch/arm/cortex/gic.c:1.40 src/sys/arch/arm/cortex/gic.c:1.41
--- src/sys/arch/arm/cortex/gic.c:1.40	Sun Jul 12 13:33:44 2020
+++ src/sys/arch/arm/cortex/gic.c	Mon Jul 27 18:36:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: gic.c,v 1.40 2020/07/12 13:33:44 skrll Exp $	*/
+/*	$NetBSD: gic.c,v 1.41 2020/07/27 18:36:23 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.40 2020/07/12 13:33:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.41 2020/07/27 18:36:23 jmcneill Exp $");
 
 #include 
 #include 
@@ -571,8 +571,6 @@ armgic_match(device_t parent, cfdata_t c
 
 	if (strcmp(cf->cf_name, mpcaa->mpcaa_name) != 0)
 		return 0;
-	if (!CPU_ID_CORTEX_P(cputype) || CPU_ID_CORTEX_A8_P(cputype))
-		return 0;
 
 	return 1;
 }



CVS commit: src/usr.bin/make

2020-07-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 27 17:41:09 UTC 2020

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

Log Message:
make(1): document API of Var_Value


To generate a diff of this commit:
cvs rdiff -u -r1.336 -r1.337 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.336 src/usr.bin/make/var.c:1.337
--- src/usr.bin/make/var.c:1.336	Sun Jul 26 23:03:54 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 17:41:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.336 2020/07/26 23:03:54 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.337 2020/07/27 17:41:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.336 2020/07/26 23:03:54 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.337 2020/07/27 17:41:09 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.336 2020/07/26 23:03:54 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.337 2020/07/27 17:41:09 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -98,8 +98,8 @@ __RCSID("$NetBSD: var.c,v 1.336 2020/07/
  *
  *	Var_Exists	See if a variable exists.
  *
- *	Var_Value 	Return the value of a variable in a context or
- *			NULL if the variable is undefined.
+ *	Var_Value 	Return the unexpanded value of a variable in a
+ *			context or NULL if the variable is undefined.
  *
  *	Var_Subst 	Substitute either a single variable or all
  *			variables in a string, using the given context.
@@ -1015,30 +1015,30 @@ Var_Exists(const char *name, GNode *ctxt
 /*-
  *---
  * Var_Value --
- *	Return the value of the named variable in the given context
+ *	Return the unexpanded value of the given variable in the given
+ *	context.
  *
  * Input:
  *	name		name to find
  *	ctxt		context in which to search for it
  *
  * Results:
- *	The value if the variable exists, NULL if it doesn't
- *
- * Side Effects:
- *	None
+ *	The value if the variable exists, NULL if it doesn't.
+ *	If the returned value is not NULL, the caller must free *freeIt
+ *	as soon as the returned value is no longer needed.
  *---
  */
 char *
-Var_Value(const char *name, GNode *ctxt, char **frp)
+Var_Value(const char *name, GNode *ctxt, char **freeIt)
 {
 Var *v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
-*frp = NULL;
+*freeIt = NULL;
 if (v == NULL)
 	return NULL;
 
 char *p = Buf_GetAll(>val, NULL);
 if (VarFreeEnv(v, FALSE))
-	*frp = p;
+	*freeIt = p;
 return p;
 }
 



CVS commit: src/tests/sbin/ifconfig

2020-07-27 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Mon Jul 27 16:57:45 UTC 2020

Modified Files:
src/tests/sbin/ifconfig: t_repeated_link_addr.sh

Log Message:
Skip the repeated_link_addr test by default as it causes the
evbarm-aarch64 testbed to hang (PR port-evbarm/55521), and will not be
safe to run by default even after that bug is fixed, for similar
reasons as t_repeated_updown.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/sbin/ifconfig/t_repeated_link_addr.sh

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

Modified files:

Index: src/tests/sbin/ifconfig/t_repeated_link_addr.sh
diff -u src/tests/sbin/ifconfig/t_repeated_link_addr.sh:1.3 src/tests/sbin/ifconfig/t_repeated_link_addr.sh:1.4
--- src/tests/sbin/ifconfig/t_repeated_link_addr.sh:1.3	Mon Jul  6 10:35:00 2020
+++ src/tests/sbin/ifconfig/t_repeated_link_addr.sh	Mon Jul 27 16:57:44 2020
@@ -1,4 +1,4 @@
-# $NetBSD: t_repeated_link_addr.sh,v 1.3 2020/07/06 10:35:00 jruoho Exp $
+# $NetBSD: t_repeated_link_addr.sh,v 1.4 2020/07/27 16:57:44 gson Exp $
 #
 # Copyright (c) 2020 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -37,6 +37,11 @@ repeated_link_addr_head() {
 
 repeated_link_addr_body() {
 
+	if ! [ $(atf_config_get "run_unsafe" "no") = "yes" ]
+	then
+		atf_skip "can disrupt networking; also PR port-evbarm/55521"
+	fi
+
 	fail=0
 	addrs="00:11:00:00:00:00 \
 	   00:11:11:00:00:00 \



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

2020-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 27 16:26:51 UTC 2020

Modified Files:
src/sys/arch/arm/pic: pic.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/arm/pic/pic.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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.56 src/sys/arch/arm/pic/pic.c:1.57
--- src/sys/arch/arm/pic/pic.c:1.56	Sat Feb  1 12:55:35 2020
+++ src/sys/arch/arm/pic/pic.c	Mon Jul 27 16:26:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.56 2020/02/01 12:55:35 riastradh Exp $	*/
+/*	$NetBSD: pic.c,v 1.57 2020/07/27 16:26:51 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.56 2020/02/01 12:55:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.57 2020/07/27 16:26:51 skrll Exp $");
 
 #include 
 #include 
@@ -692,7 +692,7 @@ pic_add(struct pic_softc *pic, int irqba
 	KASSERT((pic->pic_cpus != NULL) == (pic->pic_ops->pic_ipi_send != NULL));
 #endif
 	pic_list[slot] = pic;
-	
+
 	return irqbase;
 }
 



CVS commit: src/sys/dev/scsipi

2020-07-27 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jul 27 15:41:03 UTC 2020

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

Log Message:
Improve the workqueue and callout handling.  Prompted by riastradh@.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/scsipi/if_se.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/if_se.c
diff -u src/sys/dev/scsipi/if_se.c:1.110 src/sys/dev/scsipi/if_se.c:1.111
--- src/sys/dev/scsipi/if_se.c:1.110	Wed Jul 22 17:18:10 2020
+++ src/sys/dev/scsipi/if_se.c	Mon Jul 27 15:41:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_se.c,v 1.110 2020/07/22 17:18:10 riastradh Exp $	*/
+/*	$NetBSD: if_se.c,v 1.111 2020/07/27 15:41:03 jdc Exp $	*/
 
 /*
  * Copyright (c) 1997 Ian W. Dall 
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.110 2020/07/22 17:18:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.111 2020/07/27 15:41:03 jdc Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -332,6 +332,7 @@ seattach(device_t parent, device_t self,
 
 	sc->sc_attach_state = 0;
 	callout_init(>sc_recv_ch, CALLOUT_MPSAFE);
+	callout_setfunc(>sc_recv_ch, se_recv_callout, (void *)sc);
 	mutex_init(>sc_iflock, MUTEX_DEFAULT, IPL_SOFTNET);
 
 	/*
@@ -415,7 +416,6 @@ sedetach(device_t self, int flags)
 		mutex_enter(>sc_iflock);
 		ifp->if_flags &= ~IFF_RUNNING;
 		se_disable(sc);
-		callout_halt(>sc_recv_ch, NULL);
 		ether_ifdetach(ifp);
 		if_detach(ifp);
 		mutex_exit(>sc_iflock);
@@ -464,18 +464,13 @@ static void
 se_ifstart(struct ifnet *ifp)
 {
 	struct se_softc *sc = ifp->if_softc;
-	int i = 100;
 
 	mutex_enter(>sc_iflock);
-	while (i && sc->sc_send_work_pending == true) {
-		i--;
-		delay(10);
-	}
-	if (i) {
+	if (!sc->sc_send_work_pending)  {
 		sc->sc_send_work_pending = true;
 		workqueue_enqueue(sc->sc_send_wq, >sc_send_work, NULL);
-	} else
-		if_statinc(ifp, if_oerrors);
+	} 
+	/* else: nothing to do - work is already queued */
 	mutex_exit(>sc_iflock);
 }
 
@@ -575,8 +570,7 @@ sedone(struct scsipi_xfer *xs, int error
 		/* scsipi_free_xs will call start. Harmless. */
 		if (error) {
 			/* Reschedule after a delay */
-			callout_reset(>sc_recv_ch, se_poll,
-			se_recv_callout, (void *)sc);
+			callout_schedule(>sc_recv_ch, se_poll);
 		} else {
 			int n, ntimeo;
 			n = se_read(sc, xs->data, xs->datalen - xs->resid);
@@ -597,8 +591,7 @@ sedone(struct scsipi_xfer *xs, int error
 	  se_poll: ntimeo);
 			}
 			sc->sc_last_timeout = ntimeo;
-			callout_reset(>sc_recv_ch, ntimeo,
-			se_recv_callout, (void *)sc);
+			callout_schedule(>sc_recv_ch, ntimeo);
 		}
 	}
 }
@@ -618,8 +611,8 @@ se_recv_callout(void *v)
 
 	mutex_enter(>sc_iflock);
 	if (sc->sc_recv_work_pending == true) {
-		callout_reset(>sc_recv_ch, se_poll,
-		se_recv_callout, (void *)sc);
+		callout_schedule(>sc_recv_ch, se_poll);
+		mutex_exit(>sc_iflock);
 		return;
 	}
 
@@ -660,8 +653,7 @@ se_recv(struct se_softc *sc)
 	sc->sc_rbuf, RBUF_LEN, SERETRIES, SETIMEOUT, NULL,
 	XS_CTL_NOSLEEP | XS_CTL_DATA_IN);
 	if (error)
-		callout_reset(>sc_recv_ch, se_poll,
-		se_recv_callout, (void *)sc);
+		callout_schedule(>sc_recv_ch, se_poll);
 }
 
 /*
@@ -923,12 +915,19 @@ se_init(struct se_softc *sc)
 	if ((ifp->if_flags & (IFF_RUNNING | IFF_UP)) == IFF_UP) {
 		ifp->if_flags |= IFF_RUNNING;
 		mutex_enter(>sc_iflock);
-		sc->sc_recv_work_pending = true;
-		workqueue_enqueue(sc->sc_recv_wq, >sc_recv_work, NULL);
+		if (!sc->sc_recv_work_pending)  {
+			sc->sc_recv_work_pending = true;
+			workqueue_enqueue(sc->sc_recv_wq, >sc_recv_work,
+			NULL);
+		} 
 		mutex_exit(>sc_iflock);
 		ifp->if_flags &= ~IFF_OACTIVE;
 		mutex_enter(>sc_iflock);
-		workqueue_enqueue(sc->sc_send_wq, >sc_send_work, NULL);
+		if (!sc->sc_send_work_pending)  {
+			sc->sc_send_work_pending = true;
+			workqueue_enqueue(sc->sc_send_wq, >sc_send_work,
+			NULL);
+		} 
 		mutex_exit(>sc_iflock);
 	}
 	return (error);
@@ -1019,7 +1018,7 @@ se_stop(struct se_softc *sc)
 {
 
 	/* Don't schedule any reads */
-	callout_stop(>sc_recv_ch);
+	callout_halt(>sc_recv_ch, >sc_iflock);
 
 	/* Wait for the workqueues to finish */
 	mutex_enter(>sc_iflock);



CVS commit: src/sys

2020-07-27 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jul 27 14:52:55 UTC 2020

Modified Files:
src/sys/netinet: icmp6.h
src/sys/netinet6: icmp6.c

Log Message:
icmp6: Remove __packed attribute from icmp6 structures

They should naturally align.
Add compile time assertations to icmp6.c to prove this.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/netinet/icmp6.h
cvs rdiff -u -r1.245 -r1.246 src/sys/netinet6/icmp6.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/netinet/icmp6.h
diff -u src/sys/netinet/icmp6.h:1.56 src/sys/netinet/icmp6.h:1.57
--- src/sys/netinet/icmp6.h:1.56	Mon Jun 15 23:41:35 2020
+++ src/sys/netinet/icmp6.h	Mon Jul 27 14:52:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.h,v 1.56 2020/06/15 23:41:35 roy Exp $	*/
+/*	$NetBSD: icmp6.h,v 1.57 2020/07/27 14:52:55 roy Exp $	*/
 /*	$KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $	*/
 
 
@@ -77,7 +77,7 @@ struct icmp6_hdr {
 		u_int16_t	icmp6_un_data16[2]; /* type-specific field */
 		u_int8_t	icmp6_un_data8[4];  /* type-specific field */
 	} icmp6_dataun;
-} __packed;
+};
 
 #define icmp6_data32	icmp6_dataun.icmp6_un_data32
 #define icmp6_data16	icmp6_dataun.icmp6_un_data16
@@ -182,7 +182,7 @@ struct icmp6_hdr {
 struct mld_hdr {
 	struct icmp6_hdr	mld_icmp6_hdr;
 	struct in6_addr		mld_addr; /* multicast address */
-} __packed;
+};
 
 /* definitions to provide backward compatibility to old KAME applications */
 #ifndef _KERNEL
@@ -211,7 +211,7 @@ struct mld_hdr {
 struct nd_router_solicit {	/* router solicitation */
 	struct icmp6_hdr 	nd_rs_hdr;
 	/* could be followed by options */
-} __packed;
+};
 
 #define nd_rs_type	nd_rs_hdr.icmp6_type
 #define nd_rs_code	nd_rs_hdr.icmp6_code
@@ -223,7 +223,7 @@ struct nd_router_advert {	/* router adve
 	u_int32_t		nd_ra_reachable;	/* reachable time */
 	u_int32_t		nd_ra_retransmit;	/* retransmit timer */
 	/* could be followed by options */
-} __packed;
+};
 
 #define nd_ra_type		nd_ra_hdr.icmp6_type
 #define nd_ra_code		nd_ra_hdr.icmp6_code
@@ -251,7 +251,7 @@ struct nd_neighbor_solicit {	/* neighbor
 	struct icmp6_hdr	nd_ns_hdr;
 	struct in6_addr		nd_ns_target;	/*target address */
 	/* could be followed by options */
-} __packed;
+};
 
 #define nd_ns_type		nd_ns_hdr.icmp6_type
 #define nd_ns_code		nd_ns_hdr.icmp6_code
@@ -262,7 +262,7 @@ struct nd_neighbor_advert {	/* neighbor 
 	struct icmp6_hdr	nd_na_hdr;
 	struct in6_addr		nd_na_target;	/* target address */
 	/* could be followed by options */
-} __packed;
+};
 
 #define nd_na_type		nd_na_hdr.icmp6_type
 #define nd_na_code		nd_na_hdr.icmp6_code
@@ -285,7 +285,7 @@ struct nd_redirect {		/* redirect */
 	struct in6_addr		nd_rd_target;	/* target address */
 	struct in6_addr		nd_rd_dst;	/* destination address */
 	/* could be followed by options */
-} __packed;
+};
 
 #define nd_rd_type		nd_rd_hdr.icmp6_type
 #define nd_rd_code		nd_rd_hdr.icmp6_code
@@ -296,7 +296,7 @@ struct nd_opt_hdr {		/* Neighbor discove
 	u_int8_t	nd_opt_type;
 	u_int8_t	nd_opt_len;
 	/* followed by option specific data*/
-} __packed;
+};
 
 #define ND_OPT_SOURCE_LINKADDR		1
 #define ND_OPT_TARGET_LINKADDR		2
@@ -332,7 +332,7 @@ struct nd_opt_prefix_info {	/* prefix in
 	u_int32_t	nd_opt_pi_preferred_time;
 	u_int32_t	nd_opt_pi_reserved2;
 	struct in6_addr	nd_opt_pi_prefix;
-} __packed;
+};
 
 #define ND_OPT_PI_FLAG_ONLINK		0x80
 #define ND_OPT_PI_FLAG_AUTO		0x40
@@ -344,14 +344,14 @@ struct nd_opt_rd_hdr {		/* redirected he
 	u_int16_t	nd_opt_rh_reserved1;
 	u_int32_t	nd_opt_rh_reserved2;
 	/* followed by IP header and data */
-} __packed;
+};
 
 struct nd_opt_mtu {		/* MTU option */
 	u_int8_t	nd_opt_mtu_type;
 	u_int8_t	nd_opt_mtu_len;
 	u_int16_t	nd_opt_mtu_reserved;
 	u_int32_t	nd_opt_mtu_mtu;
-} __packed;
+};
 
 #define	ND_OPT_NONCE_LEN	((1 * 8) - 2)
 #if ((ND_OPT_NONCE_LEN + 2) % 8) != 0
@@ -361,7 +361,7 @@ struct nd_opt_nonce {
 	u_int8_t	nd_opt_nonce_type;
 	u_int8_t	nd_opt_nonce_len;
 	u_int8_t	nd_opt_nonce[ND_OPT_NONCE_LEN];
-} __packed;
+};
 
 struct nd_opt_rdnss {		/* RDNSS option RFC 6106 */
 	u_int8_t	nd_opt_rdnss_type;
@@ -369,7 +369,7 @@ struct nd_opt_rdnss {		/* RDNSS option R
 	u_int16_t	nd_opt_rdnss_reserved;
 	u_int32_t	nd_opt_rdnss_lifetime;
 	/* followed by list of IP prefixes */
-} __packed;
+};
 
 struct nd_opt_dnssl {		/* DNSSL option RFC 6106 */
 	u_int8_t	nd_opt_dnssl_type;
@@ -377,7 +377,7 @@ struct nd_opt_dnssl {		/* DNSSL option R
 	u_int16_t	nd_opt_dnssl_reserved;
 	u_int32_t	nd_opt_dnssl_lifetime;
 	/* followed by list of IP prefixes */
-} __packed;
+};
 
 /*
  * icmp6 namelookup
@@ -392,7 +392,7 @@ struct icmp6_namelookup {
 	u_int8_t	icmp6_nl_name[3];
 #endif
 	/* could be followed by options */
-} __packed;
+};
 
 /*
  * icmp6 node information
@@ -401,7 +401,7 @@ struct icmp6_nodeinfo {
 	struct icmp6_hdr icmp6_ni_hdr;
 	u_int8_t icmp6_ni_nonce[8];
 	/* could be followed by reply data */
-} __packed;

CVS commit: src/share/man/man4

2020-07-27 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Jul 27 14:17:47 UTC 2020

Modified Files:
src/share/man/man4: wwanc.4

Log Message:
add reference to net/py-xmm7360 for the network initialization script


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/share/man/man4/wwanc.4

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

Modified files:

Index: src/share/man/man4/wwanc.4
diff -u src/share/man/man4/wwanc.4:1.5 src/share/man/man4/wwanc.4:1.6
--- src/share/man/man4/wwanc.4:1.5	Mon Jul 27 11:12:56 2020
+++ src/share/man/man4/wwanc.4	Mon Jul 27 14:17:47 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: wwanc.4,v 1.5 2020/07/27 11:12:56 jdolecek Exp $
+.\" $NetBSD: wwanc.4,v 1.6 2020/07/27 14:17:47 jdolecek Exp $
 .\"
 .\" Copyright (c) 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -87,7 +87,8 @@ The
 driver IPv6 support is untested.
 .Pp
 Network initialization requires a Python script published in the Linux
-driver repository.
+driver repository, available as package
+.Pa pkgsrc/net/py-xmm7360 .
 The script requires the management device nodes to be created via:
 .Bd -literal -offset indent
 cd /dev && ./MAKEDEV xmm0



CVS commit: src/sys/dev/pci

2020-07-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 27 14:09:00 UTC 2020

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

Log Message:
Nix trailing whitespace.

Helpful hint:

(setq show-trailing-whitespace t)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/xmm7360.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/xmm7360.c
diff -u src/sys/dev/pci/xmm7360.c:1.2 src/sys/dev/pci/xmm7360.c:1.3
--- src/sys/dev/pci/xmm7360.c:1.2	Sun Jul 26 17:12:41 2020
+++ src/sys/dev/pci/xmm7360.c	Mon Jul 27 14:09:00 2020
@@ -74,7 +74,7 @@ MODULE_DEVICE_TABLE(pci, xmm7360_ids);
 #include "opt_gateway.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.2 2020/07/26 17:12:41 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.3 2020/07/27 14:09:00 riastradh Exp $");
 #endif
 
 #include 
@@ -188,7 +188,7 @@ typedef struct mutex spinlock_t;
 	+ __validate_container_of(PTR, TYPE, FIELD))
 
 /* Copied from NetBSD  */
-#define __UNVOLATILE(a)		((void *)(unsigned long)(volatile void *)(a))	
+#define __UNVOLATILE(a)		((void *)(unsigned long)(volatile void *)(a))
 
 #if OpenBSD <= 201911
 /* Backward compat with OpenBSD 6.6 */
@@ -263,7 +263,7 @@ typedef struct kmutex spinlock_t;
 #define XMM_KQ_ISFD_INITIALIZER		.f_isfd = 1
 #define tty_lock()			mutex_spin_enter(_lock)
 #define tty_unlock()			mutex_spin_exit(_lock)
-#define tty_locked()			KASSERT(mutex_owned(_lock))	
+#define tty_locked()			KASSERT(mutex_owned(_lock))
 #define bpfattach(bpf, ifp, dlt, sz)	bpf_attach(ifp, dlt, sz)
 #define NBPFILTER			1
 #define BPF_MTAP_OUT(ifp, m)		bpf_mtap(ifp, m, BPF_D_OUT)
@@ -3058,7 +3058,7 @@ wwan_if_input(struct ifnet *ifp, struct 
 	if_statadd(ifp, if_ibytes, m->m_pkthdr.len);
 
 	/*
-	 * The interface can't receive packets for other host, so never 
+	 * The interface can't receive packets for other host, so never
 	 * really IFF_PROMISC even if bpf listener is attached.
 	 */
 	if (pfil_run_hooks(ifp->if_pfil, , ifp, PFIL_IN) != 0)



CVS commit: src/sys

2020-07-27 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Jul 27 14:06:58 UTC 2020

Modified Files:
src/sys/netinet: ip6.h
src/sys/netinet6: ip6_input.c

Log Message:
ip6: Remove __packed attribute from ip6 structures

They should naturally align.
Add compile time assertations to ip6_input.c to prove this.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/netinet/ip6.h
cvs rdiff -u -r1.217 -r1.218 src/sys/netinet6/ip6_input.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/netinet/ip6.h
diff -u src/sys/netinet/ip6.h:1.25 src/sys/netinet/ip6.h:1.26
--- src/sys/netinet/ip6.h:1.25	Fri May 18 18:52:17 2018
+++ src/sys/netinet/ip6.h	Mon Jul 27 14:06:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6.h,v 1.25 2018/05/18 18:52:17 maxv Exp $	*/
+/*	$NetBSD: ip6.h,v 1.26 2020/07/27 14:06:58 roy Exp $	*/
 /*	$KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $	*/
 
 /*
@@ -81,7 +81,7 @@ struct ip6_hdr {
 	} ip6_ctlun;
 	struct in6_addr ip6_src;	/* source address */
 	struct in6_addr ip6_dst;	/* destination address */
-} __packed;
+};
 
 #define ip6_vfc		ip6_ctlun.ip6_un2_vfc
 #define ip6_flow	ip6_ctlun.ip6_un1.ip6_un1_flow
@@ -129,21 +129,21 @@ struct ip6_hdr_pseudo {
 struct ip6_ext {
 	u_int8_t ip6e_nxt;
 	u_int8_t ip6e_len;
-} __packed;
+};
 
 /* Hop-by-Hop options header */
 struct ip6_hbh {
 	u_int8_t ip6h_nxt;	/* next header */
 	u_int8_t ip6h_len;	/* length in units of 8 octets */
 	/* followed by options */
-} __packed;
+};
 
 /* Destination options header */
 struct ip6_dest {
 	u_int8_t ip6d_nxt;	/* next header */
 	u_int8_t ip6d_len;	/* length in units of 8 octets */
 	/* followed by options */
-} __packed;
+};
 
 /* Option types and related macros */
 #define IP6OPT_PAD1		0x00	/* 00 0 0 */
@@ -172,14 +172,14 @@ struct ip6_dest {
 struct ip6_opt {
 	u_int8_t ip6o_type;
 	u_int8_t ip6o_len;
-} __packed;
+};
 
 /* Jumbo Payload Option */
 struct ip6_opt_jumbo {
 	u_int8_t ip6oj_type;
 	u_int8_t ip6oj_len;
 	u_int8_t ip6oj_jumbo_len[4];
-} __packed;
+};
 #define IP6OPT_JUMBO_LEN 6
 
 /* NSAP Address Option */
@@ -190,21 +190,21 @@ struct ip6_opt_nsap {
 	u_int8_t ip6on_dst_nsap_len;
 	/* followed by source NSAP */
 	/* followed by destination NSAP */
-} __packed;
+};
 
 /* Tunnel Limit Option */
 struct ip6_opt_tunnel {
 	u_int8_t ip6ot_type;
 	u_int8_t ip6ot_len;
 	u_int8_t ip6ot_encap_limit;
-} __packed;
+};
 
 /* Router Alert Option */
 struct ip6_opt_router {
 	u_int8_t ip6or_type;
 	u_int8_t ip6or_len;
 	u_int8_t ip6or_value[2];
-} __packed;
+};
 /* Router alert values (in network byte order) */
 #if BYTE_ORDER == BIG_ENDIAN
 #define IP6_ALERT_MLD	0x
@@ -225,7 +225,7 @@ struct ip6_rthdr {
 	u_int8_t ip6r_type;	/* routing type */
 	u_int8_t ip6r_segleft;	/* segments left */
 	/* followed by routing type specific data */
-} __packed;
+};
 
 /* Type 0 Routing header */
 struct ip6_rthdr0 {
@@ -234,7 +234,7 @@ struct ip6_rthdr0 {
 	u_int8_t  ip6r0_type;		/* always zero */
 	u_int8_t  ip6r0_segleft;	/* segments left */
 	u_int32_t ip6r0_reserved;	/* reserved field */
-} __packed;
+};
 
 /* Fragment header */
 struct ip6_frag {
@@ -242,7 +242,7 @@ struct ip6_frag {
 	u_int8_t  ip6f_reserved;	/* reserved field */
 	u_int16_t ip6f_offlg;		/* offset, reserved, and flag */
 	u_int32_t ip6f_ident;		/* identification */
-} __packed;
+};
 
 #if BYTE_ORDER == BIG_ENDIAN
 #define IP6F_OFF_MASK		0xfff8	/* mask out offset from _offlg */

Index: src/sys/netinet6/ip6_input.c
diff -u src/sys/netinet6/ip6_input.c:1.217 src/sys/netinet6/ip6_input.c:1.218
--- src/sys/netinet6/ip6_input.c:1.217	Fri Jun 19 16:08:06 2020
+++ src/sys/netinet6/ip6_input.c	Mon Jul 27 14:06:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_input.c,v 1.217 2020/06/19 16:08:06 maxv Exp $	*/
+/*	$NetBSD: ip6_input.c,v 1.218 2020/07/27 14:06:58 roy Exp $	*/
 /*	$KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.217 2020/06/19 16:08:06 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.218 2020/07/27 14:06:58 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -156,6 +156,20 @@ static void sysctl_net_inet6_ip6_setup(s
 #define	SOFTNET_UNLOCK()	KASSERT(mutex_owned(softnet_lock))
 #endif
 
+/* Ensure that non packed structures are the desired size. */
+__CTASSERT(sizeof(struct ip6_hdr) == 40);
+__CTASSERT(sizeof(struct ip6_ext) == 2);
+__CTASSERT(sizeof(struct ip6_hbh) == 2);
+__CTASSERT(sizeof(struct ip6_dest) == 2);
+__CTASSERT(sizeof(struct ip6_opt) == 2);
+__CTASSERT(sizeof(struct ip6_opt_jumbo) == 6);
+__CTASSERT(sizeof(struct ip6_opt_nsap) == 4);
+__CTASSERT(sizeof(struct ip6_opt_tunnel) == 3);
+__CTASSERT(sizeof(struct ip6_opt_router) == 4);
+__CTASSERT(sizeof(struct ip6_rthdr) == 4);
+__CTASSERT(sizeof(struct ip6_rthdr0) == 8);
+__CTASSERT(sizeof(struct ip6_frag) == 8);
+
 /*
  * IP6 initialization: fill 

CVS commit: src/sys/arch

2020-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 27 12:32:54 UTC 2020

Modified Files:
src/sys/arch/hpcarm/include: intr.h
src/sys/arch/iyonix/include: intr.h
src/sys/arch/zaurus/include: intr.h

Log Message:
Don't remove the _LKM #ifdefs, but do s/_LKM/_MODULE/


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/hpcarm/include/intr.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/iyonix/include/intr.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/zaurus/include/intr.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/hpcarm/include/intr.h
diff -u src/sys/arch/hpcarm/include/intr.h:1.20 src/sys/arch/hpcarm/include/intr.h:1.21
--- src/sys/arch/hpcarm/include/intr.h:1.20	Thu Jul 23 19:04:03 2020
+++ src/sys/arch/hpcarm/include/intr.h	Mon Jul 27 12:32:54 2020
@@ -1,4 +1,4 @@
-/* 	$NetBSD: intr.h,v 1.20 2020/07/23 19:04:03 skrll Exp $	*/
+/* 	$NetBSD: intr.h,v 1.21 2020/07/27 12:32:54 skrll Exp $	*/
 
 /*
  * Copyright (c) 1997 Mark Brinicombe.
@@ -72,6 +72,14 @@
 
 #include 
 
+#if defined(_MODULE)
+
+int	_splraise(int);
+int	_spllower(int);
+void	splx(int);
+
+#else	/* _MODULE */
+
 #include "opt_arm_intr_impl.h"
 
 #if defined(ARM_INTR_IMPL)
@@ -118,6 +126,8 @@
 
 #define splsoft()	_splraise(IPL_SOFT)
 
+#endif /* _MODULE */
+
 typedef uint8_t ipl_t;
 typedef struct {
 	ipl_t _ipl;

Index: src/sys/arch/iyonix/include/intr.h
diff -u src/sys/arch/iyonix/include/intr.h:1.11 src/sys/arch/iyonix/include/intr.h:1.12
--- src/sys/arch/iyonix/include/intr.h:1.11	Thu Jul 23 19:23:49 2020
+++ src/sys/arch/iyonix/include/intr.h	Mon Jul 27 12:32:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.11 2020/07/23 19:23:49 skrll Exp $	*/
+/*	$NetBSD: intr.h,v 1.12 2020/07/27 12:32:54 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2003 Wasabi Systems, Inc.
@@ -66,6 +66,14 @@
 
 #ifndef _LOCORE
 
+#if defined(_MODULE)
+
+int	_splraise(int);
+int	_spllower(int);
+void	splx(int);
+
+#else	/* _MODULE */
+
 #include "opt_arm_intr_impl.h"
 
 #if defined(ARM_INTR_IMPL)
@@ -110,6 +118,8 @@
 
 #endif	/* ARM_INTR_IMPL */
 
+#endif /* _MODULE */
+
 typedef uint8_t ipl_t;
 typedef struct {
 	ipl_t _ipl;

Index: src/sys/arch/zaurus/include/intr.h
diff -u src/sys/arch/zaurus/include/intr.h:1.10 src/sys/arch/zaurus/include/intr.h:1.11
--- src/sys/arch/zaurus/include/intr.h:1.10	Thu Jul 23 19:24:38 2020
+++ src/sys/arch/zaurus/include/intr.h	Mon Jul 27 12:32:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.10 2020/07/23 19:24:38 skrll Exp $	*/
+/*	$NetBSD: intr.h,v 1.11 2020/07/27 12:32:54 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2003 Wasabi Systems, Inc.
@@ -68,6 +68,14 @@
 
 #include 
 
+#if defined(_MODULE)
+
+int	_splraise(int);
+int	_spllower(int);
+void	splx(int);
+
+#else	/* _MODULE */
+
 #include "opt_arm_intr_impl.h"
 
 #if defined(ARM_INTR_IMPL)
@@ -113,6 +121,8 @@
 
 #define	splsoft()	_splraise(IPL_SOFT)
 
+#endif /* _MODULE */
+
 typedef uint8_t ipl_t;
 typedef struct {
 	ipl_t _ipl;



CVS commit: src/share/man/man4

2020-07-27 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Jul 27 11:12:56 UTC 2020

Modified Files:
src/share/man/man4: wwanc.4

Log Message:
more attribution


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/wwanc.4

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

Modified files:

Index: src/share/man/man4/wwanc.4
diff -u src/share/man/man4/wwanc.4:1.4 src/share/man/man4/wwanc.4:1.5
--- src/share/man/man4/wwanc.4:1.4	Sun Jul 26 21:47:16 2020
+++ src/share/man/man4/wwanc.4	Mon Jul 27 11:12:56 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: wwanc.4,v 1.4 2020/07/26 21:47:16 wiz Exp $
+.\" $NetBSD: wwanc.4,v 1.5 2020/07/27 11:12:56 jdolecek Exp $
 .\"
 .\" Copyright (c) 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd July 26, 2020
+.Dd July 27, 2020
 .Dt WWANC 4
 .Os
 .Sh NAME
@@ -67,6 +67,9 @@ device driver first appeared
 .Nx 10.0 .
 .Sh AUTHORS
 .An -nosplit
+Development of the Linux and
+.Ox
+driver was supported by genua GmbH.
 The
 .Nm
 driver was written by
@@ -76,7 +79,8 @@ for Linux, it was ported to
 and
 .Nx
 by
-.An Jaromir Dolecek Aq Mt jdole...@netbsd.org .
+.An Jaromir Dolecek Aq Mt jdole...@netbsd.org
+for Moritz Systems Technology Company Sp. z o.o.
 .Sh CAVEATS
 The
 .Nm



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

2020-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 27 10:59:11 UTC 2020

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

Log Message:
s/MODULE/_MODULE/

spotted by chuq@


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/mips/include/cache.h

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

Modified files:

Index: src/sys/arch/mips/include/cache.h
diff -u src/sys/arch/mips/include/cache.h:1.15 src/sys/arch/mips/include/cache.h:1.16
--- src/sys/arch/mips/include/cache.h:1.15	Sun Jul 26 08:08:41 2020
+++ src/sys/arch/mips/include/cache.h	Mon Jul 27 10:59:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cache.h,v 1.15 2020/07/26 08:08:41 simonb Exp $	*/
+/*	$NetBSD: cache.h,v 1.16 2020/07/27 10:59:10 skrll Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -228,7 +228,7 @@ struct mips_cache_info {
 
 #if (MIPS1 + MIPS64_RMIXL + MIPS64R2_RMIXL + MIPS64_OCTEON) > 0 && \
 (MIPS3 + MIPS4) == 0 \
- && !defined(MODULE)
+ && !defined(_MODULE)
 #define	MIPS_CACHE_ALIAS_MASK		0
 #define	MIPS_CACHE_VIRTUAL_ALIAS	false
 #else



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

2020-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 27 10:37:58 UTC 2020

Modified Files:
src/sys/arch/evbarm/include: intr.h

Log Message:
Don't remove the _LKM #ifdefs, but do s/_LKM/_MODULE/


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/evbarm/include/intr.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/evbarm/include/intr.h
diff -u src/sys/arch/evbarm/include/intr.h:1.27 src/sys/arch/evbarm/include/intr.h:1.28
--- src/sys/arch/evbarm/include/intr.h:1.27	Thu Jul 23 19:04:03 2020
+++ src/sys/arch/evbarm/include/intr.h	Mon Jul 27 10:37:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.27 2020/07/23 19:04:03 skrll Exp $	*/
+/*	$NetBSD: intr.h,v 1.28 2020/07/27 10:37:58 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2003 Wasabi Systems, Inc.
@@ -71,6 +71,14 @@
 
 #include 
 
+#if defined(_MODULE)
+
+int	_splraise(int);
+int	_spllower(int);
+void	splx(int);
+
+#else	/* _MODULE */
+
 #include "opt_arm_intr_impl.h"
 
 #if defined(ARM_INTR_IMPL)
@@ -114,6 +122,8 @@
 
 #endif	/* ARM_INTR_IMPL */
 
+#endif /* _MODULE */
+
 typedef uint8_t ipl_t;
 typedef struct {
 	ipl_t _ipl;



CVS commit: src/share/mk

2020-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 27 08:26:09 UTC 2020

Modified Files:
src/share/mk: bsd.kmodule.mk

Log Message:
Don't define _LKM. LKMs are dead. Long live modules.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/share/mk/bsd.kmodule.mk

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

Modified files:

Index: src/share/mk/bsd.kmodule.mk
diff -u src/share/mk/bsd.kmodule.mk:1.68 src/share/mk/bsd.kmodule.mk:1.69
--- src/share/mk/bsd.kmodule.mk:1.68	Mon May 11 10:21:24 2020
+++ src/share/mk/bsd.kmodule.mk	Mon Jul 27 08:26:09 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.kmodule.mk,v 1.68 2020/05/11 10:21:24 skrll Exp $
+#	$NetBSD: bsd.kmodule.mk,v 1.69 2020/07/27 08:26:09 skrll Exp $
 
 # We are not building this with PIE
 MKPIE=no
@@ -29,7 +29,7 @@ MKLDSCRIPT?=	no
 CFLAGS+=	-ffreestanding ${COPTS}
 CPPFLAGS+=	-nostdinc -I. -I${.CURDIR} -isystem $S -isystem $S/arch
 CPPFLAGS+=	-isystem ${S}/../common/include
-CPPFLAGS+=	-D_KERNEL -D_LKM -D_MODULE -DSYSCTL_INCLUDE_DESCR
+CPPFLAGS+=	-D_KERNEL -D_MODULE -DSYSCTL_INCLUDE_DESCR
 
 CWARNFLAGS.clang+=	-Wno-error=address-of-packed-member -Wno-error=constant-conversion
 



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

2020-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 27 08:25:28 UTC 2020

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

Log Message:
Fix typo _MODULAR -> _MODULE.  Hopefully this fixes the builds.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/arch/mips/include/locore.h

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

Modified files:

Index: src/sys/arch/mips/include/locore.h
diff -u src/sys/arch/mips/include/locore.h:1.110 src/sys/arch/mips/include/locore.h:1.111
--- src/sys/arch/mips/include/locore.h:1.110	Sun Jul 26 08:08:41 2020
+++ src/sys/arch/mips/include/locore.h	Mon Jul 27 08:25:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.h,v 1.110 2020/07/26 08:08:41 simonb Exp $ */
+/* $NetBSD: locore.h,v 1.111 2020/07/27 08:25:28 skrll Exp $ */
 
 /*
  * This file should not be included by MI code!!!
@@ -28,7 +28,7 @@
 #ifndef _MIPS_LOCORE_H
 #define	_MIPS_LOCORE_H
 
-#if defined(_KERNEL_OPT)
+#if !defined(_MODULE) && defined(_KERNEL_OPT)
 #include "opt_cputype.h"
 #endif
 
@@ -51,8 +51,8 @@ typedef uint32_t pt_entry_t;
 
 #ifdef _KERNEL
 
-#if defined(_MODULAR) || defined(_STANDALONE)
-/* Assume all CPU architectures are valid for LKM's and standlone progs */
+#if defined(_MODULE) || defined(_STANDALONE)
+/* Assume all CPU architectures are valid for modules and standlone progs */
 #if !defined(__mips_n32) && !defined(__mips_n64)
 #define	MIPS1		1
 #endif
@@ -64,7 +64,7 @@ typedef uint32_t pt_entry_t;
 #endif
 #define	MIPS64		1
 #define	MIPS64R2	1
-#endif /* _MODULAR || _STANDALONE */
+#endif /* _MODULE || _STANDALONE */
 
 #if (MIPS1 + MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) == 0
 #error at least one of MIPS1, MIPS3, MIPS4, MIPS32, MIPS32R2, MIPS64, or MIPS64R2 must be specified



CVS commit: src/tests/sbin

2020-07-27 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon Jul 27 07:36:19 UTC 2020

Modified Files:
src/tests/sbin/ifconfig: t_random_garbage.sh
src/tests/sbin/sysctl: t_random_garbage.sh

Log Message:
Use the new "run_unsafe" atf_config_get() option also with a couple of other
tests that are known to be unsafe.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/sbin/ifconfig/t_random_garbage.sh
cvs rdiff -u -r1.3 -r1.4 src/tests/sbin/sysctl/t_random_garbage.sh

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

Modified files:

Index: src/tests/sbin/ifconfig/t_random_garbage.sh
diff -u src/tests/sbin/ifconfig/t_random_garbage.sh:1.3 src/tests/sbin/ifconfig/t_random_garbage.sh:1.4
--- src/tests/sbin/ifconfig/t_random_garbage.sh:1.3	Fri Jul  3 07:03:14 2020
+++ src/tests/sbin/ifconfig/t_random_garbage.sh	Mon Jul 27 07:36:19 2020
@@ -1,4 +1,4 @@
-# $NetBSD: t_random_garbage.sh,v 1.3 2020/07/03 07:03:14 jruoho Exp $
+# $NetBSD: t_random_garbage.sh,v 1.4 2020/07/27 07:36:19 jruoho Exp $
 #
 # Copyright (c) 2020 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -63,7 +63,9 @@ random_garbage_body() {
 	#
 	# Take care.
 	#
-	atf_skip "The test is not safe (PR kern/55451)"
+	if ! [ $(atf_config_get "run_unsafe" "no") = "yes" ]; then
+		atf_skip "The test is not safe (PR kern/55451)"
+	fi
 
 	opts="advbase advskew broadcast carpdev description \
 	  media mediaopt -mediaopt mode instance metric mtu \

Index: src/tests/sbin/sysctl/t_random_garbage.sh
diff -u src/tests/sbin/sysctl/t_random_garbage.sh:1.3 src/tests/sbin/sysctl/t_random_garbage.sh:1.4
--- src/tests/sbin/sysctl/t_random_garbage.sh:1.3	Fri Jul  3 07:03:14 2020
+++ src/tests/sbin/sysctl/t_random_garbage.sh	Mon Jul 27 07:36:19 2020
@@ -1,4 +1,4 @@
-# $NetBSD: t_random_garbage.sh,v 1.3 2020/07/03 07:03:14 jruoho Exp $
+# $NetBSD: t_random_garbage.sh,v 1.4 2020/07/27 07:36:19 jruoho Exp $
 #
 # Copyright (c) 2020 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -47,7 +47,9 @@ random_garbage_head() {
 
 random_garbage_body() {
 
-	atf_skip "The test is not safe (PR kern/55451)"
+	if ! [ $(atf_config_get "run_unsafe" "no") = "yes" ]; then
+		atf_skip "The test is not safe (PR kern/55451)"
+	fi
 
 	while read line; do
 
@@ -87,7 +89,9 @@ random_garbage_body() {
 
 random_garbage_cleanup() {
 
-	atf_skip "The test is not safe (PR kern/55451)"
+	if ! [ $(atf_config_get "run_unsafe" "no") = "yes" ]; then
+		atf_skip "The test is not safe (PR kern/55451)"
+	fi
 
 	while read line; do
 		var=$(echo $line | awk '{print $1}')



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

2020-07-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul 27 07:32:48 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: trap.c

Log Message:
fix build error. need cast.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/aarch64/aarch64/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/aarch64/aarch64/trap.c
diff -u src/sys/arch/aarch64/aarch64/trap.c:1.33 src/sys/arch/aarch64/aarch64/trap.c:1.34
--- src/sys/arch/aarch64/aarch64/trap.c:1.33	Sun Jul 26 07:26:52 2020
+++ src/sys/arch/aarch64/aarch64/trap.c	Mon Jul 27 07:32:48 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.33 2020/07/26 07:26:52 ryo Exp $ */
+/* $NetBSD: trap.c,v 1.34 2020/07/27 07:32:48 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.33 2020/07/26 07:26:52 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.34 2020/07/27 07:32:48 ryo Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -615,10 +615,10 @@ emul_arm_swp(uint32_t insn, struct trapf
 	if ((error = cpu_set_onfault()) == 0) {
 		if (insn & 0x0040) {
 			/* swpb */
-			val = atomic_swap_8(vaddr, val);
+			val = atomic_swap_8((uint8_t *)vaddr, val);
 		} else {
 			/* swp */
-			val = atomic_swap_32(vaddr, val);
+			val = atomic_swap_32((uint32_t *)vaddr, val);
 		}
 		cpu_unset_onfault();
 		tf->tf_reg[Rd] = val;



CVS commit: src/tests/sbin/ifconfig

2020-07-27 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Mon Jul 27 06:52:48 UTC 2020

Modified Files:
src/tests/sbin/ifconfig: t_repeated_updown.sh

Log Message:
Instead of just skipping interfaces that are "up", skip the whole
repeated_updown test case unless explicitly enabled with "atf-run -v
run_unsafe=yes".  Gratuitously configuring interfaces "up" is no more
safe than gratuitously configuring them "down"; for example, it could
lead to accidentally connecting to an insecure network or diverting
traffic from the desired route.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/sbin/ifconfig/t_repeated_updown.sh

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

Modified files:

Index: src/tests/sbin/ifconfig/t_repeated_updown.sh
diff -u src/tests/sbin/ifconfig/t_repeated_updown.sh:1.4 src/tests/sbin/ifconfig/t_repeated_updown.sh:1.5
--- src/tests/sbin/ifconfig/t_repeated_updown.sh:1.4	Wed Jul 22 05:47:24 2020
+++ src/tests/sbin/ifconfig/t_repeated_updown.sh	Mon Jul 27 06:52:48 2020
@@ -1,4 +1,4 @@
-# $NetBSD: t_repeated_updown.sh,v 1.4 2020/07/22 05:47:24 martin Exp $
+# $NetBSD: t_repeated_updown.sh,v 1.5 2020/07/27 06:52:48 gson Exp $
 #
 # Copyright (c) 2020 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -36,18 +36,25 @@ repeated_updown_head() {
 
 repeated_updown_body() {
 
+	if ! [ $(atf_config_get "run_unsafe" "no") = "yes" ]
+	then
+		atf_skip "can disrupt networking; also PR port-evbarm/55504"
+	fi
+
 	# Try to avoid stalling any automated test runs.
 	#
 	n=35
 
 	for i in $(ifconfig -l); do
 
-		# skip all interfaces that are already marked UP
-		ifconfig $i | fgrep -q UP >/dev/null && continue
+		state="up"
+		ifconfig -s $i
 
-		state="down"
-		ifconfig $i up
-		echo "Initialized $i up"
+		if [ $? -eq 1 ]; then
+			state="down"
+			ifconfig $i up
+			echo "Initialized $i up"
+		fi
 
 		while [ $n -gt 0 ]; do
 			ifconfig $i down