CVS commit: src/usr.bin/config

2024-04-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Apr  5 00:43:42 UTC 2024

Modified Files:
src/usr.bin/config: defs.h files.c mkioconf.c mkmakefile.c pack.c

Log Message:
config(1): Make sort order deterministic.

Ensure we break ties in every case.  This way, even though we use the
unstable qsort(3) library routine, the output is reproducible, no
matter what algorithm is behind qsort(3).

It would be nice if we could just use a stable sort function here,
but mergesort(3) is nonstandard, so we'd have to add it to
tools/compat, which is a big pain.

Instead, put a tie-breaking rule in every comparison function we use
with qsort, and abort() in the event of ties -- that way, we noisily
refuse to rely on unstable sort order.

While here, dispense with any question of integer overflow, and
sprinkle comments.

PR bin/58115


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/config/defs.h
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/config/files.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/config/mkioconf.c
cvs rdiff -u -r1.72 -r1.73 src/usr.bin/config/mkmakefile.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/config/pack.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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.108 src/usr.bin/config/defs.h:1.109
--- src/usr.bin/config/defs.h:1.108	Thu Jan 18 05:41:38 2024
+++ src/usr.bin/config/defs.h	Fri Apr  5 00:43:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.108 2024/01/18 05:41:38 thorpej Exp $	*/
+/*	$NetBSD: defs.h,v 1.109 2024/04/05 00:43:42 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -207,6 +207,8 @@ struct attr {
 	/* "device class" */
 	const char *a_devclass;		/* device class described */
 	struct where a_where;
+
+	size_t	a_idx;			/* index to break sorting ties */
 };
 
 /*

Index: src/usr.bin/config/files.c
diff -u src/usr.bin/config/files.c:1.37 src/usr.bin/config/files.c:1.38
--- src/usr.bin/config/files.c:1.37	Sat Mar  7 19:26:13 2020
+++ src/usr.bin/config/files.c	Fri Apr  5 00:43:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: files.c,v 1.37 2020/03/07 19:26:13 christos Exp $	*/
+/*	$NetBSD: files.c,v 1.38 2024/04/05 00:43:42 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: files.c,v 1.37 2020/03/07 19:26:13 christos Exp $");
+__RCSID("$NetBSD: files.c,v 1.38 2024/04/05 00:43:42 riastradh Exp $");
 
 #include 
 #include 
@@ -281,9 +281,9 @@ cmpfiles(const void *a, const void *b)
 	if (sa < sb)
 		return -1;
 	else if (sa > sb)
-		return 1;
+		return +1;
 	else
-		return 0;
+		abort();	/* no ties possible */
 }
 
 /*

Index: src/usr.bin/config/mkioconf.c
diff -u src/usr.bin/config/mkioconf.c:1.35 src/usr.bin/config/mkioconf.c:1.36
--- src/usr.bin/config/mkioconf.c:1.35	Sun Nov 19 01:46:29 2017
+++ src/usr.bin/config/mkioconf.c	Fri Apr  5 00:43:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkioconf.c,v 1.35 2017/11/19 01:46:29 christos Exp $	*/
+/*	$NetBSD: mkioconf.c,v 1.36 2024/04/05 00:43:42 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: mkioconf.c,v 1.35 2017/11/19 01:46:29 christos Exp $");
+__RCSID("$NetBSD: mkioconf.c,v 1.36 2024/04/05 00:43:42 riastradh Exp $");
 
 #include 
 #include 
@@ -136,7 +136,12 @@ cforder(const void *a, const void *b)
 
 	n1 = (*(const struct devi * const *)a)->i_cfindex;
 	n2 = (*(const struct devi * const *)b)->i_cfindex;
-	return (n1 - n2);
+	if (n1 < n2)
+		return -1;
+	else if (n1 > n2)
+		return +1;
+	else
+		abort();	/* no ties possible */
 }
 
 static void

Index: src/usr.bin/config/mkmakefile.c
diff -u src/usr.bin/config/mkmakefile.c:1.72 src/usr.bin/config/mkmakefile.c:1.73
--- src/usr.bin/config/mkmakefile.c:1.72	Thu Jan 18 04:41:37 2024
+++ src/usr.bin/config/mkmakefile.c	Fri Apr  5 00:43:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkmakefile.c,v 1.72 2024/01/18 04:41:37 thorpej Exp $	*/
+/*	$NetBSD: mkmakefile.c,v 1.73 2024/04/05 00:43:42 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: mkmakefile.c,v 1.72 2024/01/18 04:41:37 thorpej Exp $");
+__RCSID("$NetBSD: mkmakefile.c,v 1.73 2024/04/05 00:43:42 riastradh Exp $");
 
 #include 
 #include 
@@ -413,6 +413,7 @@ emitallkobjscb(const char *name, void *v
 		return 0;
 	if (TAILQ_EMPTY(>a_files))
 		return 0;
+	a->a_idx = attridx;
 	attrbuf[attridx++] = a;
 	/* XXX nattrs tracking is not exact yet */
 	if (attridx == nattrs) {
@@ -447,7 +448,21 @@ attrcmp(const void *l, const void *r)
 {
 	const struct attr * const *a = l, * const *b = r;
 	const int wa = (*a)->a_weight, wb = (*b)->a_weight;
-	return (wa > wb) ? -1 : (wa < wb) ? 1 : 0;
+
+	/*
+	 * Higher-weight first; then, among equal weights, earlier
+	 * index first.
+	 */
+	if (wa > wb)
+		return -1;
+	else if (wa < wb)
+		return +1;
+	else if ((*a)->a_idx < (*b)->a_idx)
+		return -1;
+	else if 

CVS commit: src/usr.bin/config

2024-04-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Apr  5 00:43:42 UTC 2024

Modified Files:
src/usr.bin/config: defs.h files.c mkioconf.c mkmakefile.c pack.c

Log Message:
config(1): Make sort order deterministic.

Ensure we break ties in every case.  This way, even though we use the
unstable qsort(3) library routine, the output is reproducible, no
matter what algorithm is behind qsort(3).

It would be nice if we could just use a stable sort function here,
but mergesort(3) is nonstandard, so we'd have to add it to
tools/compat, which is a big pain.

Instead, put a tie-breaking rule in every comparison function we use
with qsort, and abort() in the event of ties -- that way, we noisily
refuse to rely on unstable sort order.

While here, dispense with any question of integer overflow, and
sprinkle comments.

PR bin/58115


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/config/defs.h
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/config/files.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/config/mkioconf.c
cvs rdiff -u -r1.72 -r1.73 src/usr.bin/config/mkmakefile.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/config/pack.c

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



CVS commit: src/usr.bin/config

2024-01-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jan 18 05:41:38 UTC 2024

Modified Files:
src/usr.bin/config: defs.h

Log Message:
Bump version.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/config/defs.h

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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.107 src/usr.bin/config/defs.h:1.108
--- src/usr.bin/config/defs.h:1.107	Thu Jan 18 04:41:37 2024
+++ src/usr.bin/config/defs.h	Thu Jan 18 05:41:38 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.107 2024/01/18 04:41:37 thorpej Exp $	*/
+/*	$NetBSD: defs.h,v 1.108 2024/01/18 05:41:38 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -107,7 +107,7 @@ extern const char *progname;
  * The next two lines define the current version of the config(1) binary,
  * and the minimum version of the configuration files it supports.
  */
-#define CONFIG_VERSION		20180827
+#define CONFIG_VERSION		20240118
 #define CONFIG_MINVERSION	0
 
 struct where {



CVS commit: src/usr.bin/config

2024-01-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jan 18 05:41:38 UTC 2024

Modified Files:
src/usr.bin/config: defs.h

Log Message:
Bump version.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/config/defs.h

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



CVS commit: src/usr.bin/config

2024-01-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jan 18 04:41:38 UTC 2024

Modified Files:
src/usr.bin/config: config.5 defs.h gram.y main.c mkmakefile.c scan.l
util.c

Log Message:
With config(1) as it exists today, a kernel Makefile is able to implement
logic on kernel options so long as those options are not defflag'd or
defparam'd.  This works because such options are automatally added to the
IDENT var in the kernel Makefile as a preprocessor define, and the Makefile
can then do an operation like:

.if !empty(IDENT:M-DSOMECOOLCPUOPTION)
CFLAGS+= -mcpu=somecoolcpu
.endif

Unfortunately, this precludes making it possible to generate a compile-time
dependency on SOMECOOLCPUOPTION, or having SOMECOOLCPUOPTION imply another
kernel config option using the normal config(1) option dependency function.

Fix this by introducing a new option description keyword: mkflagvar.  This
keyword marks an already defflag'd option as wanting a kernel Makefile var
defined if that option is selected in the kernel config file.  So:

defflag opt_coolcpu.h SOMECOOLCPUOPTION ANOTHERCOOLCPUOPTION
mkflagvar SOMECOOLCPUOPTION ANOTHERCOOLCPUOPTION

will cause:

KERNEL_OPT_SOMECOOLCPUOPTION="1"
KERNEL_OPT_ANOTHERCOOLCPUOPTION="1"

...to be emitted into the kernel Makefile if those options are, in fact,
selected with "options ..." in the kernel config file, thus allowing for
a compile-time dependency on the option to be generated in addition to
Makefile logic, which now looks like:

.if !empty(KERNEL_OPT_SOMECOOLCPUOPTION)
CFLAGS+= -mcpu=somecoolcpu
.endif


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/config/config.5
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/config/defs.h
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/config/gram.y
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/config/main.c
cvs rdiff -u -r1.71 -r1.72 src/usr.bin/config/mkmakefile.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/config/scan.l
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/config/util.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/config/config.5
diff -u src/usr.bin/config/config.5:1.47 src/usr.bin/config/config.5:1.48
--- src/usr.bin/config/config.5:1.47	Mon Oct  4 14:35:20 2021
+++ src/usr.bin/config/config.5	Thu Jan 18 04:41:37 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.47 2021/10/04 14:35:20 andvar Exp $
+.\" $NetBSD: config.5,v 1.48 2024/01/18 04:41:37 thorpej Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  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 19, 2016
+.Dd January 17, 2024
 .Dt CONFIG 5
 .Os
 .Sh NAME
@@ -459,6 +459,24 @@ The optional
 argument should match the original definition of the option.
 .\"
 .Pp
+.It Ic mkflagvar \
+Ar option ...
+Specifes that an option previously defined with
+.Ic defflag
+should have a variable created in the kernel Makefile if the option
+is selection with an
+.Ic options
+statement.
+No variable is created if the option is not selected.
+The Makefile variable will have the name
+.Li KERNEL_OPT_ Ns Aq Ar option
+and, because options defined with
+.Ic defflag
+are boolean, 
+the variable will have the value
+.Dq 1 .
+.\"
+.Pp
 .It Ic define \
 Ar attribute \
 Oo Ic \&{ Ar locators Ic \&} Oc \

Index: src/usr.bin/config/defs.h
diff -u src/usr.bin/config/defs.h:1.106 src/usr.bin/config/defs.h:1.107
--- src/usr.bin/config/defs.h:1.106	Fri Apr  3 19:53:41 2020
+++ src/usr.bin/config/defs.h	Thu Jan 18 04:41:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.106 2020/04/03 19:53:41 joerg Exp $	*/
+/*	$NetBSD: defs.h,v 1.107 2024/01/18 04:41:37 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -151,6 +151,7 @@ struct defoptlist {
 	const char *dl_value;
 	const char *dl_lintvalue;
 	int dl_obsolete;
+	int dl_mkvar;
 	struct nvlist *dl_depends;
 	struct where	dl_where;
 };
@@ -591,10 +592,12 @@ void	delfsoption(const char *, int);
 void	delmkoption(const char *, int);
 int	devbase_has_instances(struct devbase *, int);
 struct where *find_declared_option(const char *);
+struct defoptlist *find_declared_option_option(const char *name);
 int	deva_has_instances(struct deva *, int);
 void	setupdirs(void);
 void	fixmaxusers(void);
 void	fixmkoption(void);
+void	mkflagvar(struct defoptlist *);
 const char *strtolower(const char *);
 
 /* tests on option types */

Index: src/usr.bin/config/gram.y
diff -u src/usr.bin/config/gram.y:1.56 src/usr.bin/config/gram.y:1.57
--- src/usr.bin/config/gram.y:1.56	Sun Jul 26 22:40:52 2020
+++ src/usr.bin/config/gram.y	Thu Jan 18 04:41:37 2024
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: gram.y,v 1.56 2020/07/26 22:40:52 uwe Exp $	*/
+/*	$NetBSD: gram.y,v 1.57 2024/01/18 04:41:37 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: gram.y,v 1.56 

CVS commit: src/usr.bin/config

2024-01-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jan 18 04:41:38 UTC 2024

Modified Files:
src/usr.bin/config: config.5 defs.h gram.y main.c mkmakefile.c scan.l
util.c

Log Message:
With config(1) as it exists today, a kernel Makefile is able to implement
logic on kernel options so long as those options are not defflag'd or
defparam'd.  This works because such options are automatally added to the
IDENT var in the kernel Makefile as a preprocessor define, and the Makefile
can then do an operation like:

.if !empty(IDENT:M-DSOMECOOLCPUOPTION)
CFLAGS+= -mcpu=somecoolcpu
.endif

Unfortunately, this precludes making it possible to generate a compile-time
dependency on SOMECOOLCPUOPTION, or having SOMECOOLCPUOPTION imply another
kernel config option using the normal config(1) option dependency function.

Fix this by introducing a new option description keyword: mkflagvar.  This
keyword marks an already defflag'd option as wanting a kernel Makefile var
defined if that option is selected in the kernel config file.  So:

defflag opt_coolcpu.h SOMECOOLCPUOPTION ANOTHERCOOLCPUOPTION
mkflagvar SOMECOOLCPUOPTION ANOTHERCOOLCPUOPTION

will cause:

KERNEL_OPT_SOMECOOLCPUOPTION="1"
KERNEL_OPT_ANOTHERCOOLCPUOPTION="1"

...to be emitted into the kernel Makefile if those options are, in fact,
selected with "options ..." in the kernel config file, thus allowing for
a compile-time dependency on the option to be generated in addition to
Makefile logic, which now looks like:

.if !empty(KERNEL_OPT_SOMECOOLCPUOPTION)
CFLAGS+= -mcpu=somecoolcpu
.endif


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/config/config.5
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/config/defs.h
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/config/gram.y
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/config/main.c
cvs rdiff -u -r1.71 -r1.72 src/usr.bin/config/mkmakefile.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/config/scan.l
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/config/util.c

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



CVS commit: src/usr.bin/config

2021-10-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct 12 17:14:10 UTC 2021

Modified Files:
src/usr.bin/config: lint.c

Log Message:
PR/56453: Wataru Ashihara: config(1): Assertion fails in config -L
Only compare pointers when one is found.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/config/lint.c

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



CVS commit: src/usr.bin/config

2021-10-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct 12 17:14:10 UTC 2021

Modified Files:
src/usr.bin/config: lint.c

Log Message:
PR/56453: Wataru Ashihara: config(1): Assertion fails in config -L
Only compare pointers when one is found.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/config/lint.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/config/lint.c
diff -u src/usr.bin/config/lint.c:1.15 src/usr.bin/config/lint.c:1.16
--- src/usr.bin/config/lint.c:1.15	Wed Oct 29 13:14:50 2014
+++ src/usr.bin/config/lint.c	Tue Oct 12 13:14:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lint.c,v 1.15 2014/10/29 17:14:50 christos Exp $	*/
+/*	$NetBSD: lint.c,v 1.16 2021/10/12 17:14:10 christos Exp $	*/
 
 /*
  *  Copyright (c) 2007 The NetBSD Foundation.
@@ -31,7 +31,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: lint.c,v 1.15 2014/10/29 17:14:50 christos Exp $");
+__RCSID("$NetBSD: lint.c,v 1.16 2021/10/12 17:14:10 christos Exp $");
 
 #include 
 #include 
@@ -80,11 +80,11 @@ do_emit_option(const char *name, struct 
 	printf("%s\t%s", ot->ot_name, dl->dl_name);
 	if (ot->ot_type == OT_PARAM) {
 		struct defoptlist *dl2 = dlhash_lookup(defoptlint, dl->dl_name);
-		if (dl2 != NULL)
+		if (dl2 != NULL) {
+			assert(dl2 == dl);
 			value = dl2->dl_lintvalue;
-		else
+		} else
 			value = dl->dl_value;
-		assert(dl2 == dl);
 		printf("=\"%s\"", value ? value : "1");
 	}
 	printf("\n");



CVS commit: src/usr.bin/config

2021-08-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 25 23:07:34 UTC 2021

Modified Files:
src/usr.bin/config: sem.c

Log Message:
config: remove unused local variable


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/usr.bin/config/sem.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/config/sem.c
diff -u src/usr.bin/config/sem.c:1.85 src/usr.bin/config/sem.c:1.86
--- src/usr.bin/config/sem.c:1.85	Tue Apr 13 03:09:42 2021
+++ src/usr.bin/config/sem.c	Wed Aug 25 23:07:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.85 2021/04/13 03:09:42 mrg Exp $	*/
+/*	$NetBSD: sem.c,v 1.86 2021/08/25 23:07:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.85 2021/04/13 03:09:42 mrg Exp $");
+__RCSID("$NetBSD: sem.c,v 1.86 2021/08/25 23:07:34 rillig Exp $");
 
 #include 
 #include 
@@ -950,7 +950,7 @@ resolve(struct nvlist **nvp, const char 
 	const char *cp;
 	devmajor_t maj;
 	devminor_t min;
-	size_t i, l;
+	size_t l;
 	int unit;
 	char buf[NAMESIZE];
 
@@ -1000,7 +1000,7 @@ resolve(struct nvlist **nvp, const char 
 	 * suffix, remove it if there, and split into name ("ra") and
 	 * unit (2).
 	 */
-	l = i = strlen(nv->nv_str);
+	l = strlen(nv->nv_str);
 	cp = >nv_str[l];
 	if (l > 1 && *--cp >= 'a' && *cp < 'a' + maxpartitions &&
 	isdigit((unsigned char)cp[-1])) {



CVS commit: src/usr.bin/config

2021-08-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 25 23:07:34 UTC 2021

Modified Files:
src/usr.bin/config: sem.c

Log Message:
config: remove unused local variable


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2021-04-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Apr 13 03:09:42 UTC 2021

Modified Files:
src/usr.bin/config: sem.c

Log Message:
ensure that pointer is filled in when used upon return.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2021-04-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Apr 13 03:09:42 UTC 2021

Modified Files:
src/usr.bin/config: sem.c

Log Message:
ensure that pointer is filled in when used upon return.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/usr.bin/config/sem.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/config/sem.c
diff -u src/usr.bin/config/sem.c:1.84 src/usr.bin/config/sem.c:1.85
--- src/usr.bin/config/sem.c:1.84	Sat Mar  7 19:26:13 2020
+++ src/usr.bin/config/sem.c	Tue Apr 13 03:09:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.84 2020/03/07 19:26:13 christos Exp $	*/
+/*	$NetBSD: sem.c,v 1.85 2021/04/13 03:09:42 mrg Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.84 2020/03/07 19:26:13 christos Exp $");
+__RCSID("$NetBSD: sem.c,v 1.85 2021/04/13 03:09:42 mrg Exp $");
 
 #include 
 #include 
@@ -828,10 +828,10 @@ getrefattr(const char *name, struct attr
 	/*
 	 * Check if the existing attr is only referenced, not really defined.
 	 */
+	*ra = a;
 	if (a->a_deps == NULL &&
 	a->a_iattr == 0 &&
 	a->a_devclass == 0) {
-		*ra = a;
 		return (0);
 	}
 	return (1);



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Aug  1 00:35:36 UTC 2020

Modified Files:
src/usr.bin/config: config.samples.5

Log Message:
Minor formatting tweaks.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/config/config.samples.5

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/config/config.samples.5
diff -u src/usr.bin/config/config.samples.5:1.6 src/usr.bin/config/config.samples.5:1.7
--- src/usr.bin/config/config.samples.5:1.6	Thu Mar  6 15:00:21 2014
+++ src/usr.bin/config/config.samples.5	Sat Aug  1 00:35:36 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.samples.5,v 1.6 2014/03/06 15:00:21 riastradh Exp $
+.\" $NetBSD: config.samples.5,v 1.7 2020/08/01 00:35:36 uwe Exp $
 .\"
 .\"  Copyright (c) 2006 The NetBSD Foundation.
 .\"  All rights reserved.
@@ -40,23 +40,27 @@ The following lines from the
 kernel configuration file of
 .Nx Ns / Ns i386
 are examples of instances of drivers:
-.Bd -literal
-pchb*	at pci? dev ? function ?	# PCI-Host bridges
-pcib*	at pci? dev ? function ?	# PCI-ISA bridges
-ppb*	at pci? dev ? function ?	# PCI-PCI bridges
+.Bd -literal -offset indent
+pchb*	at pci? dev ? function ?# PCI-Host bridges
+pcib*	at pci? dev ? function ?# PCI-ISA bridges
+ppb*	at pci? dev ? function ?# PCI-PCI bridges
 
-siop*	at pci? dev ? function ?	# Symbios 53c8xx SCSI
-esiop*	at pci? dev ? function ?	# Symbios 53c875 SCSI and newer
+siop*	at pci? dev ? function ?# Symbios 53c8xx SCSI
+esiop*	at pci? dev ? function ?# Symbios 53c875 SCSI and newer
 
-ix0	at isa? port 0x300 irq 10	# EtherExpress/16
+ix0	at isa? port 0x300 irq 10   # EtherExpress/16
 .Ed
 .Pp
 The first three instances allow three different drivers to attach to all the
-matching devices found on any PCI bus.
+matching devices found on any
+.Tn PCI
+bus.
 This is the most generic case.
 .Pp
 The next two lines allow two distinct drivers to attach to any matching device
-found on any PCI bus, but those two drivers are special because they both
+found on any
+.Tn PCI
+bus, but those two drivers are special because they both
 support some of the same devices.
 Each of the driver has a matching function that returns their score for the
 device that is being considered.
@@ -66,12 +70,19 @@ Of course, it is deterministic so if the
 attaches to the device, the instance of the other driver will have to be
 removed, e.g. by commenting it out.
 .Pp
-The last line configures an instance of an ISA device.
-Unlike the PCI bus, the ISA bus cannot discover the devices that are present on
-the bus.
+The last line configures an instance of an
+.Tn ISA
+device.
+Unlike the
+.Tn PCI
+bus, the
+.Tn ISA
+bus cannot discover the devices that are present on the bus.
 The driver has to try accessing the device in order to discover it.
 That implies locators must be specified to some extent: a driver would
-usually need the base address of the device, some need the IRQ line that the
+usually need the base address of the device, some need the
+.Tn IRQ
+line that the
 device is configured to use, though some others would just try a set of known
 values, at the risk of badly interacting with other devices on the bus.
 .Ss Hard-wiring kernel configuration
@@ -84,7 +95,7 @@ changes, even slightly.
 Let's consider the following excerpt of
 .Xr dmesg 8
 output:
-.Bd -literal
+.Bd -literal -offset indent
 auich0 at pci0 dev 31 function 5: i82801DB/DBM (ICH4/ICH4M) AC-97 Audio
 .Ed
 .Pp
@@ -93,17 +104,17 @@ The
 driver (which controls Intel's AC-97 audio chips) attached there because of the
 following instance of
 .Pa GENERIC :
-.Bd -literal
+.Bd -literal -offset indent
 auich* at pci? dev ? function ?
 .Ed
 .Pp
 Hard-wiring that instance means re-writing it to the following:
-.Bd -literal
+.Bd -literal -offset indent
 auich0 at pci0 dev 31 function 5
 .Ed
 .Pp
 and that way,
-.Ar auich0
+.Li auich0
 will attach to that specific location, or will not attach.
 .Ss Removing options and drivers
 When two kernel configurations differ by a very small number of changes, it is
@@ -121,14 +132,16 @@ Additions to
 .Pa GENERIC
 will then automatically be followed and used in case they are relevant.
 .Pp
-While negating an options (with
-.Ic no options )
+While negating an
+.Ic options
+with
+.Ic no options
 is unambiguous, it is not as clear for devices instances.
 .Pp
 The
-.Ic no Ar instance definition
+.Ic no Ar instance-definition
 statements of
-.Xr config 1
+.Xr config 5
 syntax only apply on the current state of the configuration file, not on the
 resulting kernel binary.
 .Xr autoconf 9
@@ -142,7 +155,7 @@ attaching at
 but I do not want any instance of
 .Xr ath 4
 attaching at
-.Ar pci3 .
+.Li pci3 .
 .Dc
 .Ed
 .Pp
@@ -162,11 +175,11 @@ no device at isa0
 .Ed
 .Pp
 One could actually live without the
-.Ar isa0
+.Li isa0
 instance, as all the legacy devices are attached at
-.Ar acpi0 .
+.Li acpi0 .
 But 

CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Aug  1 00:35:36 UTC 2020

Modified Files:
src/usr.bin/config: config.samples.5

Log Message:
Minor formatting tweaks.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/config/config.samples.5

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



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 23:55:57 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
Swtich from -ohang to -tag lists.

-ohang lists are hard to read b/c long config directives are almost
impossible to tell from the following text.  Occasional multi-paragraph
descriptions were quite confusing too.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/config/config.5

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/config/config.5
diff -u src/usr.bin/config/config.5:1.43 src/usr.bin/config/config.5:1.44
--- src/usr.bin/config/config.5:1.43	Fri Jul 31 23:44:04 2020
+++ src/usr.bin/config/config.5	Fri Jul 31 23:55:57 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.43 2020/07/31 23:44:04 uwe Exp $
+.\" $NetBSD: config.5,v 1.44 2020/07/31 23:55:57 uwe Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  All rights reserved.
@@ -249,7 +249,7 @@ to combine options and attributes .
 .\"
 .Ss CONTEXT NEUTRAL STATEMENTS
 .\"
-.Bl -ohang -compact
+.Bl -tag -width Ic -compact
 .\"
 .Pp
 .It Ic version Ar mmdd
@@ -337,7 +337,7 @@ In addition to
 and
 .Ic prefix ,
 the preamble may contain the following optional statements:
-.Bl -ohang
+.Bl -tag -width Ic
 .\"
 .It Ic build Ar path
 Defines the build directory for the compilation of the kernel.
@@ -368,7 +368,7 @@ and the logic that binds them to the
 .Nx
 kernel will have to be added to the user-edited configuration file.
 .Pp
-.Bl -ohang -compact
+.Bl -tag -width Ic -compact
 .\"
 .Pp
 .It Ic devclass Ar class
@@ -691,7 +691,7 @@ used in the selections section.
 .\"
 .Ss OPTIONS SELECTION
 .\"
-.Bl -ohang
+.Bl -tag -width Ic
 .\"
 .It Ic machine Ar machine Op Ar arch Op Ar subarch Op Ar ...
 The
@@ -701,7 +701,7 @@ exception of context-neutral statements.
 It makes
 .Xr config 1
 include, in that order, the following files:
-.Bl -enum -offset indent -compact
+.Bl -enum
 .It
 .Pa conf/files
 .It
@@ -713,6 +713,7 @@ for each defined sub-architecture
 .It
 .Pa arch/${MACHINE}/conf/files.${MACHINE}
 .El
+.Pp
 It also defines an attribute for the
 .Ar machine ,
 the



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 23:55:57 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
Swtich from -ohang to -tag lists.

-ohang lists are hard to read b/c long config directives are almost
impossible to tell from the following text.  Occasional multi-paragraph
descriptions were quite confusing too.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/config/config.5

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



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 23:44:04 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
Missed formatting fixes for "no makeoptions".


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/config/config.5

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/config/config.5
diff -u src/usr.bin/config/config.5:1.42 src/usr.bin/config/config.5:1.43
--- src/usr.bin/config/config.5:1.42	Fri Jul 31 23:42:21 2020
+++ src/usr.bin/config/config.5	Fri Jul 31 23:44:04 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.42 2020/07/31 23:42:21 uwe Exp $
+.\" $NetBSD: config.5,v 1.43 2020/07/31 23:44:04 uwe Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  All rights reserved.
@@ -901,7 +901,10 @@ Not to be confused with the confusingly 
 .Ic makeoptions
 used in the descriptions section.
 .\"
-.It Ic no makeoptions Ar name Op , Ar name Op , Ar ...
+.It Ic no makeoptions \
+Ar name \
+Ns Op Ic \&, Ar name \
+Ns Op Ic \&, Ar ...
 Removes one or more definitions from the generated
 .Pa Makefile .
 .\"



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 23:44:04 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
Missed formatting fixes for "no makeoptions".


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/config/config.5

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



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 23:42:21 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
The tale of two makeoptions.

There are two forms that were both documented in the selections
section, but the form with the condition (and only that form) can be
used only in the descriptions section.  Move it to the appropriate .Ss
and add prominent notice to both.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/config/config.5

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



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 23:42:21 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
The tale of two makeoptions.

There are two forms that were both documented in the selections
section, but the form with the condition (and only that form) can be
used only in the descriptions section.  Move it to the appropriate .Ss
and add prominent notice to both.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/config/config.5

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/config/config.5
diff -u src/usr.bin/config/config.5:1.41 src/usr.bin/config/config.5:1.42
--- src/usr.bin/config/config.5:1.41	Fri Jul 31 23:30:23 2020
+++ src/usr.bin/config/config.5	Fri Jul 31 23:42:21 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.41 2020/07/31 23:30:23 uwe Exp $
+.\" $NetBSD: config.5,v 1.42 2020/07/31 23:42:21 uwe Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  All rights reserved.
@@ -666,6 +666,26 @@ indicates when the relevant line should 
 and works just like the
 .Ic file
 statement.
+.\"
+.Pp
+.It Ic makeoptions \
+Ar condition name Ns Ic += Ns Ar value \
+Ns Op Ic \&, Ar condition name Ns Ic += Ns Ar value \
+Ns Op Ic \&, Ar ...
+Appends to a definition in the generated
+.Pa Makefile .
+.Pp
+This variant of
+.Ic makeoptions
+belongs to the options description section.
+The
+.Ar condition
+is mandatory and only
+.Ic +=
+can be used.
+Not to be confused with the the confusingly similar variant of
+.Ic makeoptions
+used in the selections section.
 .El
 .\"
 .\"
@@ -868,14 +888,18 @@ is defined with
 the
 .Ar value
 is defined as an option too.
-.\"
-.\" XXX: This variant of makeoptions can only be specified in the descriptions.
-.It Ic makeoptions \
-Ar condition name Ns Ic += Ns Ar value \
-Ns Op Ic \&, Ar condition name Ns Ic += Ns Ar value \
-Ns Op Ic \&, Ar ...
-Appends to a definition in the generated
-.Pa Makefile .
+.Pp
+This variant of
+.Ic makeoptions
+belongs to the options selection section.
+Both
+.Ic =
+and
+.Ic +=
+can be used.
+Not to be confused with the confusingly similar variant of
+.Ic makeoptions
+used in the descriptions section.
 .\"
 .It Ic no makeoptions Ar name Op , Ar name Op , Ar ...
 Removes one or more definitions from the generated



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 23:30:23 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
Formatting improvements.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/config/config.5

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/config/config.5
diff -u src/usr.bin/config/config.5:1.40 src/usr.bin/config/config.5:1.41
--- src/usr.bin/config/config.5:1.40	Fri Jul 31 21:25:34 2020
+++ src/usr.bin/config/config.5	Fri Jul 31 23:30:23 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.40 2020/07/31 21:25:34 uwe Exp $
+.\" $NetBSD: config.5,v 1.41 2020/07/31 23:30:23 uwe Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  All rights reserved.
@@ -342,7 +342,7 @@ the preamble may contain the following o
 .It Ic build Ar path
 Defines the build directory for the compilation of the kernel.
 It replaces the default of
-.Pa ../compile/
+.Pa ../compile/ Ns Aq Ar config-file
 and is superseded by the
 .Fl b
 parameter of
@@ -381,10 +381,14 @@ one device class, and will properly fill
 generates according to that value.
 .\"
 .Pp
-.It Ic defflag Oo Ar file Oc Ar option Oo Ar option Oo Ar ... Oc Oc \
-Op : Ar dependencies
-Defines a boolean option, that can either be selected or be un-selected by the
-user with the
+.It Ic defflag \
+Oo Ar file Oc \
+Ar option \
+Oo Ar option Oo Ar ... Oc Oc \
+Op Ic \&: Ar dependencies
+Defines a boolean
+.Ar option ,
+that can either be selected or be un-selected by the user with the
 .Ic options
 statement.
 The optional
@@ -392,7 +396,7 @@ The optional
 argument names a header file that will contain the C pre-processor definition
 for the option.
 If no file name is given, it will default to
-.Ar opt_.h .
+.Li opt_ Ns Ao Ar option Ac Ns Li \&.h .
 .Xr config 1
 will always create the header file, but if the user choose not to select the
 option, it will be empty.
@@ -401,8 +405,12 @@ The header file is created in the compil
 accessible by source files.
 .\"
 .Pp
-.It Ic defparam Oo Ar file Oc Ar option Oo = Ar value Oc \
-Oo := Ar lint-value Oc Oo Ar option Oo Ar ... Oc Oc Op : Ar dependencies
+.It Ic defparam \
+Oo Ar file Oc \
+Ar option Ns Oo Ns Ic = Ns Ar value\^ Oc \
+Oo Ns Ic \&:= Ns Ar lint-value Oc \
+Oo Ar option Oo Ar ... Oc Oc \
+Op Ic \&:\~ Ns Ar dependencies
 Behaves like
 .Ic defflag ,
 except the defined option must have a value.
@@ -421,8 +429,9 @@ will use it as a value when generating a
 and ignore it in all other cases.
 .\"
 .Pp
-.It Ic deffs Ar name Op Ar name Op Ar ...
-Defines a file-system name.
+.It Ic deffs Ar name ...
+Defines a file-system
+.Ar name .
 It is no more than a regular option, as defined by
 .Ic defflag ,
 but it allows the user to select the
@@ -433,8 +442,12 @@ statement instead of the
 statement.
 .\"
 .Pp
-.It Ic obsolete defflag Oo Ar file Oc Ar option Op Ar option Op Ar ...
-.It Ic obsolete defparam Oo Ar file Oc Ar option Op Ar option Op Ar ...
+.It Ic obsolete defflag \
+Oo Ar file Oc \
+Ar option ...
+.It Ic obsolete defparam \
+Oo Ar file Oc \
+Ar option ...
 Those two statements are identical and mark the listed option names as
 obsolete.
 If the user selects one of the listed options in the kernel configuration
@@ -446,13 +459,16 @@ The optional
 argument should match the original definition of the option.
 .\"
 .Pp
-.It Ic define Ar attribute Oo Bro Ar locators Brc Oc Oo : Ar dependencies Oc
+.It Ic define \
+Ar attribute \
+Oo Ic \&{ Ar locators Ic \&} Oc \
+Op Ic \&: Ar dependencies
 Defines an
 .Ar attribute .
 The
 .Ar locators
 list is optional, and can be empty.
-If the pair of brackets are present, the locator list is defined and the
+If the pair of braces are present, the locator list is defined and the
 declared attribute becomes an
 .Em interface attribute ,
 on which devices can attach.
@@ -462,7 +478,7 @@ on which devices can attach.
 Defines the maximum number of partitions the disklabels for the considered
 architecture can hold.
 This statement cannot be repeated and should only appear in the
-.Pa std\&.$\&{ARCH\&}
+.Pa "std.${ARCH}"
 file.
 .\"
 .Pp
@@ -479,7 +495,10 @@ statement in the configuration file, the
 is used instead.
 .\"
 .Pp
-.It Ic device Ar base Oo Bro Ar locators Brc Oc Oo : dependencies Oc
+.It Ic device \
+Ar base \
+Oo Ic \&{ Ar locators Ic \&} Oc \
+Op Ic \&: Ar dependencies
 Declares a device of name
 .Ar base .
 The optional list of
@@ -489,7 +508,7 @@ directly to it.
 Internally, that means
 .Ar base
 becomes an
-.Ar interface attribute .
+.Em interface attribute .
 For every device the user selects,
 .Xr config 1
 will add the matching
@@ -501,17 +520,20 @@ However, it is the responsibility of the
 line to the source of the device's driver.
 .\"
 .Pp
-.It Ic attach Ar base Ic at Ar attr Oo , Ar attr Oo , Ar 

CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 23:30:23 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
Formatting improvements.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/config/config.5

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



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 21:25:34 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
Minor tweak to list formatting.

Where necessary, use .Bl -ohang -compact and explicit .Pp to be able
to group multiple config directives (separate .It) by omitting .Pp
between them.

While here, add a .|" comment before .It to make them more visible
when editing.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/config/config.5

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



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 21:25:34 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
Minor tweak to list formatting.

Where necessary, use .Bl -ohang -compact and explicit .Pp to be able
to group multiple config directives (separate .It) by omitting .Pp
between them.

While here, add a .|" comment before .It to make them more visible
when editing.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/config/config.5

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/config/config.5
diff -u src/usr.bin/config/config.5:1.39 src/usr.bin/config/config.5:1.40
--- src/usr.bin/config/config.5:1.39	Fri Jul 31 20:01:42 2020
+++ src/usr.bin/config/config.5	Fri Jul 31 21:25:34 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.39 2020/07/31 20:01:42 uwe Exp $
+.\" $NetBSD: config.5,v 1.40 2020/07/31 21:25:34 uwe Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  All rights reserved.
@@ -249,7 +249,9 @@ to combine options and attributes .
 .\"
 .Ss CONTEXT NEUTRAL STATEMENTS
 .\"
-.Bl -ohang
+.Bl -ohang -compact
+.\"
+.Pp
 .It Ic version Ar mmdd
 Indicates the syntax version used by the rest of the file, or until the next
 .Ic version
@@ -258,11 +260,15 @@ The argument is an ISO date.
 A given
 .Xr config 1
 binary might only be compatible with a limited range of version numbers.
+.\"
+.Pp
 .It Ic include Ar path
 Includes a file.
 The path is relative to the top of the kernel source tree, or the inner-most
 defined
 .Ic prefix .
+.\"
+.Pp
 .It Ic cinclude Ar path
 Conditionally includes a file.
 Contrary to
@@ -270,6 +276,8 @@ Contrary to
 it will not produce an error if the file does not exist.
 The argument obeys the same rules as for
 .Ic include .
+.\"
+.Pp
 .It Ic prefix Op Ar path
 If
 .Ar path
@@ -286,6 +294,8 @@ The
 .Ar path
 argument is either absolute or relative to the current defined prefix, which
 defaults to the top of the kernel source tree.
+.\"
+.Pp
 .It Ic buildprefix Op Ar path
 If
 .Ar path
@@ -299,8 +309,11 @@ The
 .Ar path
 argument is relative to the current defined buildprefix, which
 defaults to the top of the kernel build directory.
-When prefix is either absolute or relative out of the kernel source tree (../),
+When prefix is either absolute or relative out of the kernel source tree
+.Pq Pa \&../ ,
 buildprefix must be defined.
+.\"
+.Pp
 .It Ic ifdef Ar attribute
 .It Ic ifndef Ar attribute
 .It Ic elifdef Ar attribute
@@ -325,6 +338,7 @@ and
 .Ic prefix ,
 the preamble may contain the following optional statements:
 .Bl -ohang
+.\"
 .It Ic build Ar path
 Defines the build directory for the compilation of the kernel.
 It replaces the default of
@@ -333,6 +347,7 @@ and is superseded by the
 .Fl b
 parameter of
 .Xr config 1 .
+.\"
 .It Ic source Ar path
 Defines the directory in which the source of the kernel lives.
 It replaces the default of
@@ -352,7 +367,10 @@ However, third parties may provide sourc
 and the logic that binds them to the
 .Nx
 kernel will have to be added to the user-edited configuration file.
-.Bl -ohang
+.Pp
+.Bl -ohang -compact
+.\"
+.Pp
 .It Ic devclass Ar class
 Defines a special attribute, named
 .Em device class .
@@ -361,6 +379,8 @@ A given device cannot belong to more tha
 translates that property by the rule that a device cannot depend on more than
 one device class, and will properly fill the configuration information file it
 generates according to that value.
+.\"
+.Pp
 .It Ic defflag Oo Ar file Oc Ar option Oo Ar option Oo Ar ... Oc Oc \
 Op : Ar dependencies
 Defines a boolean option, that can either be selected or be un-selected by the
@@ -379,6 +399,8 @@ option, it will be empty.
 Several options can be combined in one header file, for convenience.
 The header file is created in the compilation directory, making them directly
 accessible by source files.
+.\"
+.Pp
 .It Ic defparam Oo Ar file Oc Ar option Oo = Ar value Oc \
 Oo := Ar lint-value Oc Oo Ar option Oo Ar ... Oc Oc Op : Ar dependencies
 Behaves like
@@ -397,6 +419,8 @@ is specified,
 will use it as a value when generating a lint configuration with
 .Fl L ,
 and ignore it in all other cases.
+.\"
+.Pp
 .It Ic deffs Ar name Op Ar name Op Ar ...
 Defines a file-system name.
 It is no more than a regular option, as defined by
@@ -407,6 +431,8 @@ file-systems to be compiled in the kerne
 statement instead of the
 .Ic options
 statement.
+.\"
+.Pp
 .It Ic obsolete defflag Oo Ar file Oc Ar option Op Ar option Op Ar ...
 .It Ic obsolete defparam Oo Ar file Oc Ar option Op Ar option Op Ar ...
 Those two statements are identical and mark the listed option names as
@@ -418,6 +444,8 @@ will emit a warning and ignore the optio
 The optional
 .Ar file
 argument should match the original definition of the option.
+.\"
+.Pp
 .It Ic define Ar attribute Oo Bro Ar locators Brc Oc Oo : Ar 

CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 20:01:42 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
Formatting improvements.

Only comb through the first few pages (OBJECTS AND NAMES) for now.

Use .Em for emphasis, not .Ar (both look the same in text output, but
.Ar is very confusing in PostScript).  Reduce emphasis - don't
highlight every usage of a term.  Where everything is emphasized
nothing is.

Fix PS formatting of locator syntax examples so that square brackets
are literal and don't look meta-syntactic.  Explicitly show optional
locator syntax (in literal square brackets).


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/config/config.5

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



CVS commit: src/usr.bin/config

2020-07-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jul 31 20:01:42 UTC 2020

Modified Files:
src/usr.bin/config: config.5

Log Message:
Formatting improvements.

Only comb through the first few pages (OBJECTS AND NAMES) for now.

Use .Em for emphasis, not .Ar (both look the same in text output, but
.Ar is very confusing in PostScript).  Reduce emphasis - don't
highlight every usage of a term.  Where everything is emphasized
nothing is.

Fix PS formatting of locator syntax examples so that square brackets
are literal and don't look meta-syntactic.  Explicitly show optional
locator syntax (in literal square brackets).


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/config/config.5

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/config/config.5
diff -u src/usr.bin/config/config.5:1.38 src/usr.bin/config/config.5:1.39
--- src/usr.bin/config/config.5:1.38	Mon Jul  3 21:34:18 2017
+++ src/usr.bin/config/config.5	Fri Jul 31 20:01:42 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.38 2017/07/03 21:34:18 wiz Exp $
+.\" $NetBSD: config.5,v 1.39 2020/07/31 20:01:42 uwe Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  All rights reserved.
@@ -76,20 +76,25 @@ from the kernel source tree.
 Statements are separated by new-line characters.
 However, new-line characters can appear in the middle of a given statement,
 with the value of a space character.
+.\"
+.\"
 .Ss OBJECTS AND NAMES
+.\"
 .Xr config 1
 is a rather complicated piece of software that tries to comply with any
 configuration the user might think of.
 Quite a few different objects are manipulated through the kernel configuration
 file, therefore some definitions are needed.
+.\"
+.\"
 .Ss Options and attributes
+.\"
 The basic objects driving the kernel compilation are
 .Em options ,
 and are called
-.Ar attributes
+.Em attributes
 in some contexts.
-An
-.Ar attribute
+An attribute
 usually refers to a feature a given piece of hardware might have.
 However, the scope of an attribute is rather wide and can just be a place
 holder to group some source files together.
@@ -98,104 +103,118 @@ There is a special class of attribute, n
 .Em interface attribute ,
 which represents a hook that allows a device to attach to (i.e., be a child of)
 another device.
-An
-.Em interface attribute
+An interface attribute
 has a (possibly empty) list of
-.Ar locators
+.Em locators
 to match the actual location of a device.
-For example, on a PCI bus, devices are located by a
-.Em device number
+For example, on a PCI bus, devices are located by a device number
 that is fixed by the wiring of the motherboard.
 Additionally, each of those devices can appear through several interfaces named
-.Em functions .
+functions.
 A single PCI device entity is a unique function number of a given device from
 the considered PCI bus.
 Therefore, the locators for a
 .Xr pci 4
 device are
-.Ar dev
+.Ql dev
 (for device), and
-.Ar function .
+.Ql function .
 .Pp
 A
-.Ar locator
+.Em locator
 can either be a single integer value, or an array of integer values.
 It can have a default value, in which case it can be wildcarded with a
-.Dq \&?
+.Ql \&?
 in the options selection section of the configuration file.
-A single
-.Ar locator
+A single locator
 definition can take one of the following forms:
-.Bl -enum -offset indent -compact
+.Pp
+.Bl -bullet -offset indent -compact
 .It
 .Ar locator
 .It
-.Ar locator
-=
-.Ar value
+.Ar locator\| Ns Li =\| Ns Ar value
+.It
+.Li "\&[" Ns Ar locator\| Ns Li =\| Ns Ar value\| Ns Li "\&]"
 .It
-.Ar locator Ns Oo Ar length Oc
+.Ar locator Ns Li "\&[" Ns Ar length Ns Li "\&]"
 .It
-.Ar locator Ns Oo Ar length Oc = Brq Ar value , ...
+.Ar locator Ns Li "\&[" Ns Ar length Ns Li "\&]={" \
+Ns Ar value\| Ns Li \&, Ar ... Ns Li "\&}"
+.It
+.Li "\&[" Ns Ar locator Ns Li "\&[" Ns Ar length Ns Li "\&]={" \
+Ns Ar value\| Ns Li \&, Ar ... Ns Li "\&}]"
 .El
+.Pp
 The variants that specify a default value can be enclosed into square brackets,
 in which case the locator will not have to be specified later in the options
 selection section of the configuration file.
 .Pp
 In the options selection section, the locators are specified when declaring an
 instance as a space-separated list of
-.Dq Ao Ar locator Ac Ao Ar value Ac
+.Dq Ao Ar locator\| Ac \~ Ao Ar value\| Ac
 where value can be the
-.Dq \&?
+.Ql \&?
 wildcard if the locator allows it.
+.\"
+.\"
 .Ss Devices, instances and attachments
+.\"
 The main benefit of the kernel configuration file is to allow the user to avoid
 compiling some drivers, and wire down the configuration of some others.
 We have already seen that devices attach to each other through
-.Em interface attributes ,
+interface attributes,
 but not everything can attach to anything.
 Furthermore, the user has the ability to define precise instances for the
 devices.
-An
-.Ar 

CVS commit: src/usr.bin/config

2020-07-26 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Jul 26 22:40:52 UTC 2020

Modified Files:
src/usr.bin/config: gram.y

Log Message:
Add debug output for ENDDEFS.

This makes it more clear in the debug output where config switched
from definitions to selections.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/config/gram.y

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



CVS commit: src/usr.bin/config

2020-07-26 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Jul 26 22:40:52 UTC 2020

Modified Files:
src/usr.bin/config: gram.y

Log Message:
Add debug output for ENDDEFS.

This makes it more clear in the debug output where config switched
from definitions to selections.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/config/gram.y

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/config/gram.y
diff -u src/usr.bin/config/gram.y:1.55 src/usr.bin/config/gram.y:1.56
--- src/usr.bin/config/gram.y:1.55	Sat Mar  7 19:26:13 2020
+++ src/usr.bin/config/gram.y	Sun Jul 26 22:40:52 2020
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: gram.y,v 1.55 2020/03/07 19:26:13 christos Exp $	*/
+/*	$NetBSD: gram.y,v 1.56 2020/07/26 22:40:52 uwe Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: gram.y,v 1.55 2020/03/07 19:26:13 christos Exp $");
+__RCSID("$NetBSD: gram.y,v 1.56 2020/07/26 22:40:52 uwe Exp $");
 
 #include 
 #include 
@@ -306,7 +306,11 @@ no:
 
 /* Complete definition part: the contents of all files.* files. */
 definition_part:
-	definitions ENDDEFS		{ check_maxpart(); check_version(); }
+	definitions ENDDEFS		{
+		CFGDBG(1, "ENDDEFS");
+		check_maxpart();
+		check_version();
+	}
 ;
 
 /* Zero or more definitions. Trap errors. */



CVS commit: src/usr.bin/config

2020-07-26 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Jul 26 22:25:47 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
Don't print the location of the include directive twice.

cfgdbg() already prints the current file and line number, so don't
print the same information ourselves in the message too.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/config/scan.l

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

Modified files:

Index: src/usr.bin/config/scan.l
diff -u src/usr.bin/config/scan.l:1.32 src/usr.bin/config/scan.l:1.33
--- src/usr.bin/config/scan.l:1.32	Fri Apr  3 19:53:41 2020
+++ src/usr.bin/config/scan.l	Sun Jul 26 22:25:47 2020
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: scan.l,v 1.32 2020/04/03 19:53:41 joerg Exp $	*/
+/*	$NetBSD: scan.l,v 1.33 2020/07/26 22:25:47 uwe Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: scan.l,v 1.32 2020/04/03 19:53:41 joerg Exp $");
+__RCSID("$NetBSD: scan.l,v 1.33 2020/07/26 22:25:47 uwe Exp $");
 
 #include 
 #include 
@@ -555,7 +555,7 @@ include(const char *fname, int ateof, in
 	if (interesting)
 		logconfig_include(fp, fname);
 	incl = in;
-	CFGDBG(1, "include `%s' from `%s' line %d", fname, yyfile, yyline);
+	CFGDBG(1, "include `%s'", fname);
 	yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE));
 	yyfile = intern(s);
 	yyline = 1;



CVS commit: src/usr.bin/config

2020-07-26 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Jul 26 22:25:47 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
Don't print the location of the include directive twice.

cfgdbg() already prints the current file and line number, so don't
print the same information ourselves in the message too.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/config/scan.l

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



CVS commit: src/usr.bin/config

2020-04-03 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Apr  3 19:53:41 UTC 2020

Modified Files:
src/usr.bin/config: defs.h main.c scan.l

Log Message:
Avoid depending on common symbols.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/usr.bin/config/defs.h
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/config/main.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/config/scan.l

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



CVS commit: src/usr.bin/config

2020-04-03 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Apr  3 19:53:41 UTC 2020

Modified Files:
src/usr.bin/config: defs.h main.c scan.l

Log Message:
Avoid depending on common symbols.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/usr.bin/config/defs.h
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/config/main.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/config/scan.l

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

Modified files:

Index: src/usr.bin/config/defs.h
diff -u src/usr.bin/config/defs.h:1.105 src/usr.bin/config/defs.h:1.106
--- src/usr.bin/config/defs.h:1.105	Sat Mar  7 19:26:13 2020
+++ src/usr.bin/config/defs.h	Fri Apr  3 19:53:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.105 2020/03/07 19:26:13 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.106 2020/04/03 19:53:41 joerg Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -437,80 +437,88 @@ struct devm {
  */
 struct hashtab;
 
-int lkmmode;
-const char *conffile;		/* source file, e.g., "GENERIC.sparc" */
-const char *machine;		/* machine type, e.g., "sparc" or "sun3" */
-const char *machinearch;	/* machine arch, e.g., "sparc" or "m68k" */
-struct	nvlist *machinesubarches;
+extern int lkmmode;
+extern const char *conffile;		/* source file, e.g., "GENERIC.sparc" */
+extern const char *machine;		/* machine type, e.g., "sparc" or "sun3" */
+extern const char *machinearch;	/* machine arch, e.g., "sparc" or "m68k" */
+extern struct	nvlist *machinesubarches;
 /* machine subarches, e.g., "sun68k" or "hpc" */
-const char *ioconfname;		/* ioconf name, mutually exclusive to machine */
-const char *srcdir;		/* path to source directory (rel. to build) */
-const char *builddir;		/* path to build directory */
-const char *defbuilddir;	/* default build directory */
-const char *ident;		/* kernel "ident"ification string */
-int	errors;			/* counts calls to error() */
-int	minmaxusers;		/* minimum "maxusers" parameter */
-int	defmaxusers;		/* default "maxusers" parameter */
-int	maxmaxusers;		/* default "maxusers" parameter */
-int	maxusers;		/* configuration's "maxusers" parameter */
-int	maxpartitions;		/* configuration's "maxpartitions" parameter */
-int	version;		/* version of the configuration file */
-struct	nvlist *options;	/* options */
-struct	nvlist *fsoptions;	/* filesystems */
-struct	nvlist *mkoptions;	/* makeoptions */
-struct	nvlist *appmkoptions;	/* appending mkoptions */
-struct	nvlist *condmkoptions;	/* conditional makeoption table */
-struct	hashtab *devbasetab;	/* devbase lookup */
-struct	hashtab *devroottab;	/* attach at root lookup */
-struct	hashtab *devatab;	/* devbase attachment lookup */
-struct	hashtab *devitab;	/* device instance lookup */
-struct	hashtab *deaddevitab;	/* removed instances lookup */
-struct	hashtab *selecttab;	/* selects things that are "optional foo" */
-struct	hashtab *needcnttab;	/* retains names marked "needs-count" */
-struct	hashtab *opttab;	/* table of configured options */
-struct	hashtab *fsopttab;	/* table of configured file systems */
-struct	dlhash *defopttab;	/* options that have been "defopt"'d */
-struct	dlhash *defflagtab;	/* options that have been "defflag"'d */
-struct	dlhash *defparamtab;	/* options that have been "defparam"'d */
-struct	dlhash *defoptlint;	/* lint values for options */
-struct	nvhash *deffstab;	/* defined file systems */
-struct	dlhash *optfiletab;	/* "defopt"'d option .h files */
-struct	hashtab *attrtab;	/* attributes (locators, etc.) */
-struct	hashtab *attrdeptab;	/* attribute dependencies */
-struct	hashtab *bdevmtab;	/* block devm lookup */
-struct	hashtab *cdevmtab;	/* character devm lookup */
-
-TAILQ_HEAD(, devbase)	allbases;	/* list of all devbase structures */
-TAILQ_HEAD(, deva)	alldevas;	/* list of all devbase attachments */
-TAILQ_HEAD(conftq, config) allcf;	/* list of configured kernels */
-TAILQ_HEAD(, devi)	alldevi,	/* list of all instances */
-			allpseudo;	/* list of all pseudo-devices */
-TAILQ_HEAD(, devm)	alldevms;	/* list of all device-majors */
-TAILQ_HEAD(, pspec)	allpspecs;	/* list of all parent specs */
-int	ndevi;/* number of devi's (before packing) */
-int	npspecs;			/* number of parent specs */
-devmajor_t maxbdevm;			/* max number of block major */
-devmajor_t maxcdevm;			/* max number of character major */
-int	do_devsw;			/* 0 if pre-devsw config */
-int	oktopackage;			/* 0 before setmachine() */
-int	devilevel;			/* used for devi->i_level */
-
-struct filelist		allfiles;	/* list of all kernel source files */
-struct filelist		allcfiles;	/* list of all .c files */
-struct filelist		allsfiles;	/* list of all .S files */
-struct filelist		allofiles;	/* list of all .o files */
-
-struct prefixlist	prefixes,	/* prefix stack */
-			allprefixes;	/* all prefixes used (after popped) */
-struct prefixlist	buildprefixes,	/* build prefix stack */
-			allbuildprefixes;/* all build prefixes used (after popped) */
-SLIST_HEAD(, prefix)	curdirs;	/* curdir stack */

CVS commit: src/usr.bin/config

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  9 17:27:03 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
Add an enabled bit to keep track of the parent state (if we are ignoring
or parsing). Idea from uwe.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/config/scan.l

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



CVS commit: src/usr.bin/config

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  9 17:27:03 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
Add an enabled bit to keep track of the parent state (if we are ignoring
or parsing). Idea from uwe.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/config/scan.l

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

Modified files:

Index: src/usr.bin/config/scan.l
diff -u src/usr.bin/config/scan.l:1.30 src/usr.bin/config/scan.l:1.31
--- src/usr.bin/config/scan.l:1.30	Sun Mar  8 13:38:37 2020
+++ src/usr.bin/config/scan.l	Mon Mar  9 13:27:03 2020
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: scan.l,v 1.30 2020/03/08 17:38:37 christos Exp $	*/
+/*	$NetBSD: scan.l,v 1.31 2020/03/09 17:27:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: scan.l,v 1.30 2020/03/08 17:38:37 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.31 2020/03/09 17:27:03 christos Exp $");
 
 #include 
 #include 
@@ -68,19 +68,21 @@ int	 ifdefshift = -1;
 /*
  * The state is represented by 3 bits.
  */
-#define IDS_MATCH	1ll
-#define IDS_ELIF	2ll
-#define	IDS_ELSE	4ll
-
-#define IDS_BITS	7
-#define IDS_SHIFT	3
-
-#define IDS_ISMATCH(st) (((st) & IDS_MATCH) != 0)
-#define IDS_PARENT_DISABLED \
-	(ifdefshift > 0 && !IDS_ISMATCH(ifdefstate >> IDS_SHIFT))
-#define IDS_MAX_DEPTH	21 /* 64 / 3 */
+#define	IDS_ENABLED	1ll
+#define	IDS_MATCH	2ll
+#define	IDS_ELIF	4ll
+#define	IDS_ELSE	8ll
+
+#define	IDS_BITS	0xf
+#define	IDS_SHIFT	4
+
+#define	IDS_ISMATCH(st) (((st) & IDS_MATCH) != 0)
+#define	IDS_ISENABLED(st) (((st) & IDS_ENABLED) != 0)
+#define	IDS_PARENT_DISABLED \
+	(ifdefshift > 0 && !IDS_ISENABLED(ifdefstate >> IDS_SHIFT))
+#define IDS_MAX_DEPTH	16 /* 64 / 4 */
 
-#ifdef IDS_DEBUG
+#ifdef	IDS_DEBUG
 # define IDS_PRINT(s, st, x) \
 	do { \
 		for (int i = 0; i < ifdefshift + 1; i++) \
@@ -90,12 +92,12 @@ int	 ifdefshift = -1;
 		ifdefstate); \
 	} while (/*CONSTCOND*/0)
 #else
-# define IDS_PRINT(s, st, x) __nothing
+# define IDS_PRINT(s, st, x) ((void)0)
 #endif
 
-#define IDS_ENTER(s, st) \
+#define	IDS_ENTER(s, st) \
 	IDS_PRINT(s, st, ">")
-#define IDS_EXIT(s, st) \
+#define	IDS_EXIT(s, st) \
 	IDS_PRINT(s, st, "<")
 
 /*
@@ -195,9 +197,10 @@ with		return WITH;
 		}
 		IDS_ENTER(ifdef, 0);
 		if (IDS_PARENT_DISABLED || !getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		IDS_EXIT(ifdef, 0);
@@ -211,9 +214,10 @@ with		return WITH;
 		}
 		IDS_ENTER(ifndef, 0);
 		if (IDS_PARENT_DISABLED || getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		IDS_EXIT(ifndef, 0);
@@ -228,9 +232,10 @@ with		return WITH;
 			yyerror("mismatched elifdef");
 		}
 		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st) || !getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELIF;
@@ -245,9 +250,10 @@ with		return WITH;
 			yyerror("mismatched elifndef");
 		}
 		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st) || getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELIF;
@@ -262,9 +268,10 @@ with		return WITH;
 			yyerror("mismatched else");
 		}
 		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st)) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELSE;



CVS commit: src/usr.bin/config

2020-03-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  8 17:38:37 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
Add debugging, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/config/scan.l

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

Modified files:

Index: src/usr.bin/config/scan.l
diff -u src/usr.bin/config/scan.l:1.29 src/usr.bin/config/scan.l:1.30
--- src/usr.bin/config/scan.l:1.29	Sat Mar  7 19:04:11 2020
+++ src/usr.bin/config/scan.l	Sun Mar  8 13:38:37 2020
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: scan.l,v 1.29 2020/03/08 00:04:11 christos Exp $	*/
+/*	$NetBSD: scan.l,v 1.30 2020/03/08 17:38:37 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: scan.l,v 1.29 2020/03/08 00:04:11 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.30 2020/03/08 17:38:37 christos Exp $");
 
 #include 
 #include 
@@ -79,7 +79,25 @@ int	 ifdefshift = -1;
 #define IDS_PARENT_DISABLED \
 	(ifdefshift > 0 && !IDS_ISMATCH(ifdefstate >> IDS_SHIFT))
 #define IDS_MAX_DEPTH	21 /* 64 / 3 */
- 
+
+#ifdef IDS_DEBUG
+# define IDS_PRINT(s, st, x) \
+	do { \
+		for (int i = 0; i < ifdefshift + 1; i++) \
+			fprintf(stderr, " "); \
+		printf("%s%s [%d,%d,%d] %#" PRIx64 "\n", x, # s, \
+		IDS_PARENT_DISABLED, IDS_ISMATCH(st), getcurifdef(), \
+		ifdefstate); \
+	} while (/*CONSTCOND*/0)
+#else
+# define IDS_PRINT(s, st, x) __nothing
+#endif
+
+#define IDS_ENTER(s, st) \
+	IDS_PRINT(s, st, ">")
+#define IDS_EXIT(s, st) \
+	IDS_PRINT(s, st, "<")
+
 /*
  * Data for returning to previous files from include files.
  */
@@ -175,12 +193,14 @@ with		return WITH;
 		if (++ifdefshift >= IDS_MAX_DEPTH) {
 			yyerror("too many levels of conditional");
 		}
+		IDS_ENTER(ifdef, 0);
 		if (IDS_PARENT_DISABLED || !getcurifdef()) {
 			BEGIN(IGNORED);
 		} else {
 			ifdefstate |= IDS_MATCH;
 			BEGIN(INITIAL);
 		}
+		IDS_EXIT(ifdef, 0);
 		yyline++;
 	}
 
@@ -189,18 +209,21 @@ with		return WITH;
 		if (++ifdefshift >= IDS_MAX_DEPTH) {
 			yyerror("too many levels of conditional");
 		}
+		IDS_ENTER(ifndef, 0);
 		if (IDS_PARENT_DISABLED || getcurifdef()) {
 			BEGIN(IGNORED);
 		} else {
 			ifdefstate |= IDS_MATCH;
 			BEGIN(INITIAL);
 		}
+		IDS_EXIT(ifndef, 0);
 		yyline++;
 	}
 
 
 <*>{WS}elifdef[ \t]+{WORD}{RESTOFLINE} {
 		int st = ifdefstate & IDS_BITS;
+		IDS_ENTER(elifdef, st);
 		if (ifdefshift == -1 || (st & IDS_ELSE) != 0) {
 			yyerror("mismatched elifdef");
 		}
@@ -211,11 +234,13 @@ with		return WITH;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELIF;
+		IDS_EXIT(elifdef, st);
 		yyline++;
 	}
 
 <*>{WS}elifndef[ \t]+{WORD}{RESTOFLINE} {
 		int st = ifdefstate & IDS_BITS;
+		IDS_ENTER(elifndef, st);
 		if (ifdefshift == -1 || (st & IDS_ELSE) != 0) {
 			yyerror("mismatched elifndef");
 		}
@@ -226,11 +251,13 @@ with		return WITH;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELIF;
+		IDS_EXIT(elifndef, st);
 		yyline++;
 	}
 
 <*>{WS}else{RESTOFLINE} {
 		int st = ifdefstate & IDS_BITS;
+		IDS_ENTER(else, st);
 		if (ifdefshift == -1 || (st & IDS_ELSE) != 0) {
 			yyerror("mismatched else");
 		}
@@ -241,16 +268,19 @@ with		return WITH;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELSE;
+		IDS_ENTER(else, st);
 		yyline++;
 	}
 
 <*>{WS}endif{RESTOFLINE} {
+		IDS_ENTER(endif, 0);
 		if (ifdefshift == -1) {
 			yyerror("mismatched endif");
 		}
 		if (!IDS_PARENT_DISABLED) {
 			BEGIN(INITIAL);
 		}
+		IDS_EXIT(endif, 0);
 		ifdefshift--;
 		ifdefstate >>= IDS_SHIFT;
 		yyline++;



CVS commit: src/usr.bin/config

2020-03-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  8 17:38:37 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
Add debugging, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/config/scan.l

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



CVS commit: src/usr.bin/config

2020-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  8 00:04:12 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
Recognize {if{,n}def,elfif{,n}def,else,endif} only at the beginning of the
line or after whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/config/scan.l

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

Modified files:

Index: src/usr.bin/config/scan.l
diff -u src/usr.bin/config/scan.l:1.28 src/usr.bin/config/scan.l:1.29
--- src/usr.bin/config/scan.l:1.28	Sat Mar  7 17:35:16 2020
+++ src/usr.bin/config/scan.l	Sat Mar  7 19:04:11 2020
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: scan.l,v 1.28 2020/03/07 22:35:16 christos Exp $	*/
+/*	$NetBSD: scan.l,v 1.29 2020/03/08 00:04:11 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: scan.l,v 1.28 2020/03/07 22:35:16 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.29 2020/03/08 00:04:11 christos Exp $");
 
 #include 
 #include 
@@ -107,6 +107,7 @@ QCHARS	\"(\\.|[^\\"])*\" 
 WORD	[A-Za-z_][-A-Za-z_0-9]*
 FILENAME	({PATH}|{QCHARS})
 RESTOFLINE	[ \t]*(#[^\n]*)?\n
+WS	^[ \t]*
 
 %x	IGNORED
 
@@ -169,7 +170,7 @@ with		return WITH;
 \+=		return PLUSEQ;
 :=		return COLONEQ;
 
-<*>ifdef[ \t]+{WORD}{RESTOFLINE} {
+<*>{WS}ifdef[ \t]+{WORD}{RESTOFLINE} {
 		ifdefstate <<= IDS_SHIFT;
 		if (++ifdefshift >= IDS_MAX_DEPTH) {
 			yyerror("too many levels of conditional");
@@ -183,7 +184,7 @@ with		return WITH;
 		yyline++;
 	}
 
-<*>ifndef[ \t]+{WORD}{RESTOFLINE} {
+<*>{WS}ifndef[ \t]+{WORD}{RESTOFLINE} {
 		ifdefstate <<= IDS_SHIFT;
 		if (++ifdefshift >= IDS_MAX_DEPTH) {
 			yyerror("too many levels of conditional");
@@ -198,7 +199,7 @@ with		return WITH;
 	}
 
 
-<*>elifdef[ \t]+{WORD}{RESTOFLINE} {
+<*>{WS}elifdef[ \t]+{WORD}{RESTOFLINE} {
 		int st = ifdefstate & IDS_BITS;
 		if (ifdefshift == -1 || (st & IDS_ELSE) != 0) {
 			yyerror("mismatched elifdef");
@@ -213,7 +214,7 @@ with		return WITH;
 		yyline++;
 	}
 
-<*>elifndef[ \t]+{WORD}{RESTOFLINE} {
+<*>{WS}elifndef[ \t]+{WORD}{RESTOFLINE} {
 		int st = ifdefstate & IDS_BITS;
 		if (ifdefshift == -1 || (st & IDS_ELSE) != 0) {
 			yyerror("mismatched elifndef");
@@ -228,7 +229,7 @@ with		return WITH;
 		yyline++;
 	}
 
-<*>else{RESTOFLINE} {
+<*>{WS}else{RESTOFLINE} {
 		int st = ifdefstate & IDS_BITS;
 		if (ifdefshift == -1 || (st & IDS_ELSE) != 0) {
 			yyerror("mismatched else");
@@ -243,7 +244,7 @@ with		return WITH;
 		yyline++;
 	}
 
-<*>endif{RESTOFLINE} {
+<*>{WS}endif{RESTOFLINE} {
 		if (ifdefshift == -1) {
 			yyerror("mismatched endif");
 		}



CVS commit: src/usr.bin/config

2020-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  8 00:04:12 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
Recognize {if{,n}def,elfif{,n}def,else,endif} only at the beginning of the
line or after whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/config/scan.l

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



CVS commit: src/usr.bin/config

2020-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  7 22:35:16 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
PR/55057: Paul Goyette: Don't use % 6 arithmetic that hurts the brain for
the ifdef state machine, use bits and shifts instead. Also don't forget to
restore the state once an include file ends.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/config/scan.l

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

Modified files:

Index: src/usr.bin/config/scan.l
diff -u src/usr.bin/config/scan.l:1.27 src/usr.bin/config/scan.l:1.28
--- src/usr.bin/config/scan.l:1.27	Sat Mar  7 14:26:13 2020
+++ src/usr.bin/config/scan.l	Sat Mar  7 17:35:16 2020
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: scan.l,v 1.27 2020/03/07 19:26:13 christos Exp $	*/
+/*	$NetBSD: scan.l,v 1.28 2020/03/07 22:35:16 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: scan.l,v 1.27 2020/03/07 19:26:13 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.28 2020/03/07 22:35:16 christos Exp $");
 
 #include 
 #include 
@@ -62,34 +62,23 @@ int	yyline;
 const char *yyfile;
 const char *lastfile;
 char curinclpath[PATH_MAX];
-int ifdefstate = -1;
-int st;
-#define IDS_PARENT_DISABLED \
-((ifdefstate > 6) && ifdefstate/6)-1) & 1) == 1))
-#define IDS_MAX_DEPTH		362797056 /* 6^11 */
-/* States for ifdefstate:
-
-  0  -> matched ifdef
-  1  -> unmatched ifdef
-  2  -> matched elifdef
-  3  -> unmatched elifdef
-  4  -> matched else
-  5  -> unmatched else
-
-  Upon "ifdef", add one and multiply by 6.
-  Upon "endif", divide by 6, remove 1.
-
-  ifdef -> MATCH => continue
-   MISMATCH => set to 1
-  elifdef -> if (!1) -> MISMATCH
- MATCH => set to 2
- MISMATCH => if (2 || 3) set to 3, else set to 1
-  else -> if (1) -> MATCH
-  MATCH => set to 4
-  MISMATCH => set to 5
+uint64_t ifdefstate;
+int	 ifdefshift = -1;
+
+/*
+ * The state is represented by 3 bits.
+ */
+#define IDS_MATCH	1ll
+#define IDS_ELIF	2ll
+#define	IDS_ELSE	4ll
+
+#define IDS_BITS	7
+#define IDS_SHIFT	3
 
-  in each case, if parent & 1 == 1, MISMATCH
-*/
+#define IDS_ISMATCH(st) (((st) & IDS_MATCH) != 0)
+#define IDS_PARENT_DISABLED \
+	(ifdefshift > 0 && !IDS_ISMATCH(ifdefstate >> IDS_SHIFT))
+#define IDS_MAX_DEPTH	21 /* 64 / 3 */
  
 /*
  * Data for returning to previous files from include files.
@@ -100,7 +89,8 @@ struct incl {
 	struct where in_where;
 	int	in_ateof;	/* token to insert at EOF */
 	int	in_interesting;	/* previous value for "interesting" */
-	int	in_ifdefstate;	/* conditional level */
+	uint64_t	in_ifdefstate;	/* conditional level */
+	int	in_ifdefshift;	/* conditional level */
 };
 static struct incl *incl;
 static int endinclude(void);
@@ -180,97 +170,88 @@ with		return WITH;
 :=		return COLONEQ;
 
 <*>ifdef[ \t]+{WORD}{RESTOFLINE} {
-		ifdefstate = (ifdefstate + 1) * 6;
-		if (ifdefstate >= IDS_MAX_DEPTH) {
+		ifdefstate <<= IDS_SHIFT;
+		if (++ifdefshift >= IDS_MAX_DEPTH) {
 			yyerror("too many levels of conditional");
 		}
-		if (!IDS_PARENT_DISABLED && getcurifdef()) {
-			BEGIN(INITIAL);
-		} else {
-			ifdefstate++;
+		if (IDS_PARENT_DISABLED || !getcurifdef()) {
 			BEGIN(IGNORED);
+		} else {
+			ifdefstate |= IDS_MATCH;
+			BEGIN(INITIAL);
 		}
 		yyline++;
 	}
 
 <*>ifndef[ \t]+{WORD}{RESTOFLINE} {
-		ifdefstate = (ifdefstate + 1) * 6;
-		if (ifdefstate >= IDS_MAX_DEPTH) {
+		ifdefstate <<= IDS_SHIFT;
+		if (++ifdefshift >= IDS_MAX_DEPTH) {
 			yyerror("too many levels of conditional");
 		}
-		if (!IDS_PARENT_DISABLED && !getcurifdef()) {
-			BEGIN(INITIAL);
-		} else {
-			ifdefstate++;
+		if (IDS_PARENT_DISABLED || getcurifdef()) {
 			BEGIN(IGNORED);
+		} else {
+			ifdefstate |= IDS_MATCH;
+			BEGIN(INITIAL);
 		}
 		yyline++;
 	}
 
 
 <*>elifdef[ \t]+{WORD}{RESTOFLINE} {
-		st = ifdefstate % 6;
-		if (ifdefstate < 0 || st > 3) {
+		int st = ifdefstate & IDS_BITS;
+		if (ifdefshift == -1 || (st & IDS_ELSE) != 0) {
 			yyerror("mismatched elifdef");
 		}
-		if (IDS_PARENT_DISABLED ||
-		st != 1 || !getcurifdef()) {
-			if (st == 2 || st == 3) {
-ifdefstate += 3 - st;
-			} else {
-ifdefstate += 1 - st;
-			}
+		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st) || !getcurifdef()) {
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate++;
+			ifdefstate |= IDS_MATCH;
 			BEGIN(INITIAL);
 		}
+		ifdefstate |= IDS_ELIF;
 		yyline++;
 	}
 
 <*>elifndef[ \t]+{WORD}{RESTOFLINE} {
-		st = ifdefstate % 6;
-		if (ifdefstate < 0 || st > 3) {
+		int st = ifdefstate & IDS_BITS;
+		if (ifdefshift == -1 || (st & IDS_ELSE) != 0) {
 			yyerror("mismatched elifndef");
 		}
-		if (IDS_PARENT_DISABLED ||
-		st != 1 || getcurifdef()) {
-			if (st == 2 || st == 3) {
-ifdefstate += 3 - st;
-			} else {
-ifdefstate += 1 - st;
-			}
+		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st) || getcurifdef()) {
 			BEGIN(IGNORED);
 		} else {
-			

CVS commit: src/usr.bin/config

2020-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  7 22:35:16 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
PR/55057: Paul Goyette: Don't use % 6 arithmetic that hurts the brain for
the ifdef state machine, use bits and shifts instead. Also don't forget to
restore the state once an include file ends.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/config/scan.l

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



CVS commit: src/usr.bin/config

2020-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  7 19:26:13 UTC 2020

Modified Files:
src/usr.bin/config: defs.h files.c gram.y main.c scan.l sem.c util.c

Log Message:
Keep track where more objects are declared so that we can print where things
have been redefined.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/usr.bin/config/defs.h
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/config/files.c
cvs rdiff -u -r1.54 -r1.55 src/usr.bin/config/gram.y
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/config/main.c
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/config/scan.l
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/config/sem.c
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/config/util.c

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



CVS commit: src/usr.bin/config

2020-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  7 19:26:13 UTC 2020

Modified Files:
src/usr.bin/config: defs.h files.c gram.y main.c scan.l sem.c util.c

Log Message:
Keep track where more objects are declared so that we can print where things
have been redefined.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/usr.bin/config/defs.h
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/config/files.c
cvs rdiff -u -r1.54 -r1.55 src/usr.bin/config/gram.y
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/config/main.c
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/config/scan.l
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/config/sem.c
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/config/util.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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.104 src/usr.bin/config/defs.h:1.105
--- src/usr.bin/config/defs.h:1.104	Mon Aug 27 12:04:45 2018
+++ src/usr.bin/config/defs.h	Sat Mar  7 14:26:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.104 2018/08/27 16:04:45 riastradh Exp $	*/
+/*	$NetBSD: defs.h,v 1.105 2020/03/07 19:26:13 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -110,6 +110,10 @@ extern const char *progname;
 #define CONFIG_VERSION		20180827
 #define CONFIG_MINVERSION	0
 
+struct where {
+	const char *w_srcfile;		/* file name where we are defined */
+	u_short	w_srcline;		/* line number where we are defined */
+};
 /*
  * Name/value lists.  Values can be strings or pointers and/or can carry
  * integers.  The names can be NULL, resulting in simple value lists.
@@ -123,6 +127,7 @@ struct nvlist {
 	int		nv_ifunit;		/* XXX XXX XXX */
 	int		nv_flags;
 #define	NV_DEPENDED	1
+	struct where	nv_where;
 };
 
 /*
@@ -131,10 +136,10 @@ struct nvlist {
 struct config {
 	TAILQ_ENTRY(config) cf_next;
 	const char *cf_name;		/* "netbsd" */
-	int	cf_lineno;		/* source line */
 	const char *cf_fstype;		/* file system type */
 	struct	nvlist *cf_root;	/* "root on ra0a" */
 	struct	nvlist *cf_dump;	/* "dumps on ra0b" */
+	struct where	cf_where;
 };
 
 /*
@@ -147,6 +152,7 @@ struct defoptlist {
 	const char *dl_lintvalue;
 	int dl_obsolete;
 	struct nvlist *dl_depends;
+	struct where	dl_where;
 };
 
 struct files;
@@ -199,6 +205,7 @@ struct attr {
 
 	/* "device class" */
 	const char *a_devclass;		/* device class described */
+	struct where a_where;
 };
 
 /*
@@ -277,8 +284,7 @@ struct devbase {
 	struct	deva *d_ahead;		/* first attachment, if any */
 	struct	deva **d_app;		/* used for tacking on attachments */
 	struct	attr *d_classattr;	/* device class attribute (if any) */
-	const char *d_srcfile;		/* file name where we are defined */
-	u_short	d_srcline;		/* line number where we are defined */
+	struct	where d_where;
 };
 
 struct deva {
@@ -291,8 +297,7 @@ struct deva {
 	struct	attrlist *d_attrs;	/* attributes, if any */
 	struct	devi *d_ihead;		/* first instance, if any */
 	struct	devi **d_ipp;		/* used for tacking on more instances */
-	const char *d_srcfile;		/* file name where we are defined */
-	u_short	d_srcline;		/* line number where we are defined */
+	struct	where d_where;
 };
 
 /*
@@ -319,8 +324,6 @@ struct devi {
 	struct	deva *i_atdeva;
 	const char **i_locs;	/* locators (as given by pspec's iattr) */
 	int	i_cfflags;	/* flags from config line */
-	int	i_lineno;	/* line # in config, for later errors */
-	const char *i_srcfile;	/* file it appears in */
 	int	i_level;	/* position between negated instances */
 	int	i_active;
 #define	DEVI_ORPHAN	0	/* instance has no active parent */
@@ -333,7 +336,7 @@ struct devi {
 	short	i_collapsed;	/* set => this alias no longer needed */
 	u_short	i_cfindex;	/* our index in cfdata */
 	int	i_locoff;	/* offset in locators.vec */
-
+	struct	where i_where;
 };
 /* special units */
 #define	STAR	(-1)		/* unit number for, e.g., "sd*" */
@@ -346,8 +349,7 @@ struct devi {
 struct files {
 	TAILQ_ENTRY(files) fi_next;
 	TAILQ_ENTRY(files) fi_snext;	/* per-suffix list */
-	const char *fi_srcfile;	/* the name of the "files" file that got us */
-	u_short	fi_srcline;	/* and the line number */
+	struct	where fi_where;
 	u_char fi_flags;	/* as below */
 	const char *fi_tail;	/* name, i.e., strrchr(fi_path, '/') + 1 */
 	const char *fi_base;	/* tail minus ".c" (or whatever) */
@@ -418,13 +420,12 @@ struct prefix {
  */
 struct devm {
 	TAILQ_ENTRY(devm) dm_next;
-	const char	*dm_srcfile;	/* the name of the "majors" file */
-	u_short		dm_srcline;	/* the line number */
 	const char	*dm_name;	/* [bc]devsw name */
 	devmajor_t	dm_cmajor;	/* character major */
 	devmajor_t	dm_bmajor;	/* block major */
 	struct condexpr	*dm_opts;	/* options */
 	struct nvlist	*dm_devnodes;	/* information on /dev nodes */
+	struct where dm_where;
 };
 
 /*
@@ -581,7 +582,7 @@ void	deloption(const char *, int);
 void	delfsoption(const char *, int);
 void	delmkoption(const char *, int);
 int	devbase_has_instances(struct devbase *, int);
-int	

CVS commit: src/usr.bin/config

2020-02-07 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Fri Feb  7 20:17:48 UTC 2020

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

Log Message:
usr.bin/config: Suppress -Werror=stringop-truncation error.

Add GCC_NO_STRINGOP_TRUNCATION to scan.c to prevent build failure.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.
gcc version 8.3.0

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/config/Makefile

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



CVS commit: src/usr.bin/config

2020-02-07 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Fri Feb  7 20:17:48 UTC 2020

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

Log Message:
usr.bin/config: Suppress -Werror=stringop-truncation error.

Add GCC_NO_STRINGOP_TRUNCATION to scan.c to prevent build failure.

Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag.
gcc version 8.3.0

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/config/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/config/Makefile
diff -u src/usr.bin/config/Makefile:1.11 src/usr.bin/config/Makefile:1.12
--- src/usr.bin/config/Makefile:1.11	Sun Oct 13 07:28:14 2019
+++ src/usr.bin/config/Makefile	Fri Feb  7 20:17:48 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.11 2019/10/13 07:28:14 mrg Exp $
+#	$NetBSD: Makefile,v 1.12 2020/02/07 20:17:48 fox Exp $
 #	from: @(#)Makefile	8.2 (Berkeley) 4/19/94
 
 .include 
@@ -17,6 +17,8 @@ YHEADER=1
 CPPFLAGS+=-I${.CURDIR} -I.
 CPPFLAGS+= -I${NETBSDSRCDIR}/usr.bin/cksum
 
+COPTS.scan.c+=		${GCC_NO_STRINGOP_TRUNCATION}
+
 .ifndef HOSTPROG
 LDADD+=-lutil
 DPADD+=${LIBUTIL}



CVS commit: src/usr.bin/config

2018-12-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 24 02:07:44 UTC 2018

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

Log Message:
yydebug is now defined only if YYDEBUG is


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/config/main.c

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

Modified files:

Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.97 src/usr.bin/config/main.c:1.98
--- src/usr.bin/config/main.c:1.97	Tue Nov 28 10:31:33 2017
+++ src/usr.bin/config/main.c	Sun Dec 23 21:07:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.97 2017/11/28 15:31:33 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.98 2018/12/24 02:07:44 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: main.c,v 1.97 2017/11/28 15:31:33 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.98 2018/12/24 02:07:44 christos Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include 
@@ -95,7 +95,7 @@ int	handling_cmdlineopts;		/* currently 
 
 int	yyparse(void);
 
-#ifndef MAKE_BOOTSTRAP
+#if !defined(MAKE_BOOTSTRAP) && defined(YYDEBUG)
 extern int yydebug;
 #endif
 int	dflag;
@@ -172,7 +172,7 @@ main(int argc, char **argv)
 		switch (ch) {
 
 		case 'd':
-#ifndef MAKE_BOOTSTRAP
+#if !defined(MAKE_BOOTSTRAP) && defined(YYDEBUG)
 			yydebug = 1;
 #endif
 			dflag++;



CVS commit: src/usr.bin/config

2018-12-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 24 02:07:44 UTC 2018

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

Log Message:
yydebug is now defined only if YYDEBUG is


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/config/main.c

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



CVS commit: src/usr.bin/config

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 16:04:45 UTC 2018

Modified Files:
src/usr.bin/config: defs.h

Log Message:
Bump config(5) version for OPT.foo.c variables.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/usr.bin/config/defs.h

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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.103 src/usr.bin/config/defs.h:1.104
--- src/usr.bin/config/defs.h:1.103	Mon Apr  9 17:46:56 2018
+++ src/usr.bin/config/defs.h	Mon Aug 27 16:04:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.103 2018/04/09 17:46:56 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.104 2018/08/27 16:04:45 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -107,7 +107,7 @@ extern const char *progname;
  * The next two lines define the current version of the config(1) binary,
  * and the minimum version of the configuration files it supports.
  */
-#define CONFIG_VERSION		20171118
+#define CONFIG_VERSION		20180827
 #define CONFIG_MINVERSION	0
 
 /*



CVS commit: src/usr.bin/config

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 16:04:45 UTC 2018

Modified Files:
src/usr.bin/config: defs.h

Log Message:
Bump config(5) version for OPT.foo.c variables.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/usr.bin/config/defs.h

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



CVS commit: src/usr.bin/config

2018-08-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 05:35:00 UTC 2018

Modified Files:
src/usr.bin/config: mkmakefile.c

Log Message:
Tag each .c file with the options that might have brought it in.


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

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



CVS commit: src/usr.bin/config

2018-08-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 05:35:00 UTC 2018

Modified Files:
src/usr.bin/config: mkmakefile.c

Log Message:
Tag each .c file with the options that might have brought it in.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/config/mkmakefile.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/config/mkmakefile.c
diff -u src/usr.bin/config/mkmakefile.c:1.70 src/usr.bin/config/mkmakefile.c:1.71
--- src/usr.bin/config/mkmakefile.c:1.70	Fri Jun 16 02:01:10 2017
+++ src/usr.bin/config/mkmakefile.c	Mon Aug 27 05:35:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkmakefile.c,v 1.70 2017/06/16 02:01:10 christos Exp $	*/
+/*	$NetBSD: mkmakefile.c,v 1.71 2018/08/27 05:35:00 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: mkmakefile.c,v 1.70 2017/06/16 02:01:10 christos Exp $");
+__RCSID("$NetBSD: mkmakefile.c,v 1.71 2018/08/27 05:35:00 riastradh Exp $");
 
 #include 
 #include 
@@ -584,6 +584,34 @@ emitincludes(FILE *fp)
 }
 
 /*
+ * Emit all options included in a conditional expression
+ */
+static void
+emitopts(FILE *fp, struct condexpr *cond, int include)
+{
+
+	switch (cond->cx_type) {
+	case CX_ATOM:
+		if (include && selectopt(cond->cx_u.atom, NULL))
+			fprintf(fp, " %s", cond->cx_u.atom);
+		break;
+	case CX_NOT:
+		emitopts(fp, cond->cx_u.not, !include);
+		break;
+	case CX_AND:
+		emitopts(fp, cond->cx_u.and.left, include);
+		emitopts(fp, cond->cx_u.and.right, include);
+		break;
+	case CX_OR:
+		emitopts(fp, cond->cx_u.and.left, include);
+		emitopts(fp, cond->cx_u.and.right, include);
+		break;
+	default:
+		cfgerror("bug");
+	}
+}
+
+/*
  * Emit appending makeoptions.
  */
 static void
@@ -591,6 +619,17 @@ emitappmkoptions(FILE *fp)
 {
 	struct nvlist *nv;
 	struct condexpr *cond;
+	size_t i;
+
+	for (i = 0; i < nselfiles; i++) {
+		struct files *const fi = selfiles[i];
+
+		if (fi->fi_optx) {
+			fprintf(fp, "OPT.%s.c+=", fi->fi_base);
+			emitopts(fp, fi->fi_optx, 1);
+			fprintf(fp, "\n");
+		}
+	}
 
 	for (nv = appmkoptions; nv != NULL; nv = nv->nv_next)
 		fprintf(fp, "%s+=%s\n", nv->nv_name, nv->nv_str);



CVS commit: src/usr.bin/config

2018-04-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr  9 17:46:57 UTC 2018

Modified Files:
src/usr.bin/config: defs.h sem.c

Log Message:
Keep previous location of device definitions so we can print them in error
messages.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/config/defs.h
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/config/sem.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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.102 src/usr.bin/config/defs.h:1.103
--- src/usr.bin/config/defs.h:1.102	Sun Nov 26 19:25:46 2017
+++ src/usr.bin/config/defs.h	Mon Apr  9 13:46:56 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.102 2017/11/27 00:25:46 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.103 2018/04/09 17:46:56 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -277,6 +277,8 @@ struct devbase {
 	struct	deva *d_ahead;		/* first attachment, if any */
 	struct	deva **d_app;		/* used for tacking on attachments */
 	struct	attr *d_classattr;	/* device class attribute (if any) */
+	const char *d_srcfile;		/* file name where we are defined */
+	u_short	d_srcline;		/* line number where we are defined */
 };
 
 struct deva {
@@ -289,6 +291,8 @@ struct deva {
 	struct	attrlist *d_attrs;	/* attributes, if any */
 	struct	devi *d_ihead;		/* first instance, if any */
 	struct	devi **d_ipp;		/* used for tacking on more instances */
+	const char *d_srcfile;		/* file name where we are defined */
+	u_short	d_srcline;		/* line number where we are defined */
 };
 
 /*

Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.82 src/usr.bin/config/sem.c:1.83
--- src/usr.bin/config/sem.c:1.82	Sun Nov 26 19:25:46 2017
+++ src/usr.bin/config/sem.c	Mon Apr  9 13:46:56 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.82 2017/11/27 00:25:46 christos Exp $	*/
+/*	$NetBSD: sem.c,v 1.83 2018/04/09 17:46:56 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.82 2017/11/27 00:25:46 christos Exp $");
+__RCSID("$NetBSD: sem.c,v 1.83 2018/04/09 17:46:56 christos Exp $");
 
 #include 
 #include 
@@ -509,7 +509,8 @@ defdev(struct devbase *dev, struct locli
 	if (dev == )
 		goto bad;
 	if (dev->d_isdef) {
-		cfgerror("redefinition of `%s'", dev->d_name);
+		cfgerror("redefinition of `%s' (previously defined at %s:%d)",
+		dev->d_name, dev->d_srcfile, dev->d_srcline);
 		goto bad;
 	}
 
@@ -624,6 +625,8 @@ getdevbase(const char *name)
 		dev->d_ahead = NULL;
 		dev->d_app = >d_ahead;
 		dev->d_umax = 0;
+		dev->d_srcfile = yyfile;
+		dev->d_srcline = currentline();
 		TAILQ_INSERT_TAIL(, dev, d_next);
 		if (ht_insert(devbasetab, name, dev))
 			panic("%s: Can't insert %s", __func__, name);
@@ -655,7 +658,8 @@ defdevattach(struct deva *deva, struct d
 		goto bad;
 	}
 	if (deva->d_isdef) {
-		cfgerror("redefinition of `%s'", deva->d_name);
+		cfgerror("redefinition of `%s' (previously defined at %s:%d)",
+		deva->d_name, deva->d_srcfile, deva->d_srcline);
 		goto bad;
 	}
 	if (dev->d_ispseudo) {
@@ -764,6 +768,8 @@ getdevattach(const char *name)
 		deva->d_attrs = NULL;
 		deva->d_ihead = NULL;
 		deva->d_ipp = >d_ihead;
+		deva->d_srcfile = yyfile;
+		deva->d_srcline = currentline();
 		TAILQ_INSERT_TAIL(, deva, d_next);
 		if (ht_insert(devatab, name, deva))
 			panic("%s: Can't insert %s", __func__, name);



CVS commit: src/usr.bin/config

2018-04-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr  9 17:46:57 UTC 2018

Modified Files:
src/usr.bin/config: defs.h sem.c

Log Message:
Keep previous location of device definitions so we can print them in error
messages.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/config/defs.h
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2017-11-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 28 15:31:33 UTC 2017

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

Log Message:
- make the level computation consistent
- keep going only if things changed.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/config/main.c

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

Modified files:

Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.96 src/usr.bin/config/main.c:1.97
--- src/usr.bin/config/main.c:1.96	Sun Nov 26 19:25:46 2017
+++ src/usr.bin/config/main.c	Tue Nov 28 10:31:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.96 2017/11/27 00:25:46 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.97 2017/11/28 15:31:33 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: main.c,v 1.96 2017/11/27 00:25:46 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.97 2017/11/28 15:31:33 christos Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include 
@@ -1876,21 +1876,22 @@ addlevelparent(struct devbase *d, struct
 	struct devbase *p;
 
 	if (d == parent) {
-		if (d->d_level++ > 1)
+		if (d->d_level > 1)
 			return 0;
 		return 1;
 	}
 
 	if (d->d_levelparent) {
-		if (d->d_level++ > 1)
+		if (d->d_level > 1)
 			return 0;
 		return 1;
 	}
 
 	for (p = parent; p != NULL; p = p->d_levelparent)
-		if (d == p && d->d_level++ > 1)
+		if (d == p && d->d_level > 1)
 			return 0;
 	d->d_levelparent = p ? p :  
+	d->d_level++;
 	return 1;
 }
 
@@ -1926,6 +1927,7 @@ do_kill_orphans(struct devbase *d, struc
 		}
 	} else {
 		int seen = 0;
+		int changed = 0;
 
 		for (i = d->d_ihead; i != NULL; i = i->i_bsame) {
 			for (j = i; j != NULL; j = j->i_alias) {
@@ -1958,6 +1960,7 @@ do_kill_orphans(struct devbase *d, struc
 		seen = 1;
 		continue;
 	}
+	changed |= j->i_active != state;
 	j->i_active = active = state;
 	if (p != NULL) {
 		if (state == DEVI_ACTIVE ||
@@ -1997,8 +2000,9 @@ do_kill_orphans(struct devbase *d, struc
 CFGDBG(5, "`%s' at '%s' ignored", d->d_name,
 parent ? parent->d_name : "(root)");
 
-			}
-		}
+			} else if (!changed)
+goto out;
+		} 
 	}
 
 	for (al = d->d_attrs; al != NULL; al = al->al_next) {



CVS commit: src/usr.bin/config

2017-11-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 28 15:31:33 UTC 2017

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

Log Message:
- make the level computation consistent
- keep going only if things changed.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/config/main.c

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



CVS commit: src/usr.bin/config

2017-11-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov 27 00:25:46 UTC 2017

Modified Files:
src/usr.bin/config: defs.h main.c sem.c

Log Message:
use a reference count to avoid deleting psrefs still in use.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/config/defs.h
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/config/main.c
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2017-11-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov 27 00:25:46 UTC 2017

Modified Files:
src/usr.bin/config: defs.h main.c sem.c

Log Message:
use a reference count to avoid deleting psrefs still in use.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/config/defs.h
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/config/main.c
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/config/sem.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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.101 src/usr.bin/config/defs.h:1.102
--- src/usr.bin/config/defs.h:1.101	Sat Nov 18 13:44:20 2017
+++ src/usr.bin/config/defs.h	Sun Nov 26 19:25:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.101 2017/11/18 18:44:20 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.102 2017/11/27 00:25:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -234,9 +234,9 @@ struct pspec {
 	struct	devbase *p_atdev;	/* optional parent device base */
 	int	p_atunit;		/* optional parent device unit */
 	struct	nvlist *p_devs;		/* children using it */
-	struct	deva *p_deva;		/* attribute */
 	int	p_inst;			/* parent spec instance */
 	int	p_active;		/* parent spec is actively used */
+	int	p_ref;			/* refcount */
 };
 
 /*

Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.95 src/usr.bin/config/main.c:1.96
--- src/usr.bin/config/main.c:1.95	Fri Nov 24 18:42:36 2017
+++ src/usr.bin/config/main.c	Sun Nov 26 19:25:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.95 2017/11/24 23:42:36 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.96 2017/11/27 00:25:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: main.c,v 1.95 2017/11/24 23:42:36 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.96 2017/11/27 00:25:46 christos Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include 
@@ -1959,8 +1959,11 @@ do_kill_orphans(struct devbase *d, struc
 		continue;
 	}
 	j->i_active = active = state;
-	if (p != NULL)
-		p->p_active = state;
+	if (p != NULL) {
+		if (state == DEVI_ACTIVE ||
+		--p->p_ref == 0)
+			p->p_active = state;
+	}
 	if (state == DEVI_IGNORED) {
 		CFGDBG(5,
 		"`%s' at '%s' ignored",

Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.81 src/usr.bin/config/sem.c:1.82
--- src/usr.bin/config/sem.c:1.81	Fri Nov 24 13:45:59 2017
+++ src/usr.bin/config/sem.c	Sun Nov 26 19:25:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.81 2017/11/24 18:45:59 christos Exp $	*/
+/*	$NetBSD: sem.c,v 1.82 2017/11/27 00:25:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.81 2017/11/24 18:45:59 christos Exp $");
+__RCSID("$NetBSD: sem.c,v 1.82 2017/11/27 00:25:46 christos Exp $");
 
 #include 
 #include 
@@ -79,8 +79,7 @@ static int has_errobj(struct attrlist *,
 static struct nvlist *addtoattr(struct nvlist *, struct devbase *);
 static int resolve(struct nvlist **, const char *, const char *,
 		   struct nvlist *, int);
-static struct pspec *getpspec(struct attr *, struct devbase *, int,
-struct deva *);
+static struct pspec *getpspec(struct attr *, struct devbase *, int, int);
 static struct devi *newdevi(const char *, int, struct devbase *d);
 static struct devi *getdevi(const char *);
 static void remove_devi(struct devi *);
@@ -1296,7 +1295,7 @@ adddev(const char *name, const char *at,
 			 * XXX: This creates multiple pspecs that look the
 			 * same in the config file and could be merged.
 			 */
-			p = getpspec(attr, ab, atunit, iba);
+			p = getpspec(attr, ab, atunit, first);
 			p->p_devs = newnv(NULL, NULL, i, 0, p->p_devs);
 		} else
 			p = NULL;
@@ -1907,17 +1906,23 @@ fixdevis(void)
  * Look up a parent spec, creating a new one if it does not exist.
  */
 static struct pspec *
-getpspec(struct attr *attr, struct devbase *ab, int atunit, struct deva *da)
+getpspec(struct attr *attr, struct devbase *ab, int atunit, int first)
 {
 	struct pspec *p;
 	int inst = npspecs;
+	int ref = 1;
 
 	TAILQ_FOREACH(p, , p_list) {
 		if (p->p_iattr == attr && p->p_atdev == ab &&
 		p->p_atunit == atunit) {
-			if (p->p_deva == da)
-return (p);
-		   	inst = p->p_inst; 
+			p->p_ref++;
+			if (first)
+return p;
+			else {
+inst = p->p_inst;
+ref = p->p_ref;
+			}
+
 		}
 	}
 
@@ -1929,8 +1934,8 @@ getpspec(struct attr *attr, struct devba
 	p->p_inst = inst;
 	if (inst == npspecs)
 		npspecs++;
-	p->p_deva = da;
 	p->p_active = 0;
+	p->p_ref = ref;
 
 	TAILQ_INSERT_TAIL(, p, p_list);
 



CVS commit: src/usr.bin/config

2017-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 24 23:42:36 UTC 2017

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

Log Message:
- Instead of checking the recursion level before we recurse, check in on
  function entry.
- Always decrement the level and reset levelparent on exit.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/config/main.c

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

Modified files:

Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.94 src/usr.bin/config/main.c:1.95
--- src/usr.bin/config/main.c:1.94	Sat Nov 18 13:39:16 2017
+++ src/usr.bin/config/main.c	Fri Nov 24 18:42:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.94 2017/11/18 18:39:16 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.95 2017/11/24 23:42:36 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: main.c,v 1.94 2017/11/18 18:39:16 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.95 2017/11/24 23:42:36 christos Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include 
@@ -1868,27 +1868,30 @@ check_dead_devi(const char *key, void *v
 	return 0;
 }
 
-static int
-is_orphan_loop(const struct devbase *d, const struct devbase *p)
-{
-
-	for (; p && d != p; p = p->d_levelparent)
-		continue;
-	return d == p;
-}
+static struct devbase root;
 
-static void
+static int
 addlevelparent(struct devbase *d, struct devbase *parent)
 {
 	struct devbase *p;
 
-	if (d->d_levelparent)
-		return;
+	if (d == parent) {
+		if (d->d_level++ > 1)
+			return 0;
+		return 1;
+	}
+
+	if (d->d_levelparent) {
+		if (d->d_level++ > 1)
+			return 0;
+		return 1;
+	}
 
 	for (p = parent; p != NULL; p = p->d_levelparent)
-		if (d == p)
-			return;
-	d->d_levelparent = p;
+		if (d == p && d->d_level++ > 1)
+			return 0;
+	d->d_levelparent = p ? p :  
+	return 1;
 }
 
 static void
@@ -1902,7 +1905,8 @@ do_kill_orphans(struct devbase *d, struc
 	struct pspec *p;
 	int active = 0;
 
-	addlevelparent(d, parent);
+	if (!addlevelparent(d, parent))
+		return;
 
 	/*
 	 * A pseudo-device will always attach at root, and if it has an
@@ -1970,7 +1974,7 @@ do_kill_orphans(struct devbase *d, struc
 		 * If we've been there but have made no change, stop.
 		 */
 		if (seen && active != DEVI_ACTIVE)
-			return;
+			goto out;
 		if (active != DEVI_ACTIVE) {
 			struct cdd_params cdd = { d, at, parent };
 			/* Look for a matching dead devi */
@@ -1990,22 +1994,19 @@ do_kill_orphans(struct devbase *d, struc
 CFGDBG(5, "`%s' at '%s' ignored", d->d_name,
 parent ? parent->d_name : "(root)");
 
-			} else
-return;
+			}
 		}
 	}
 
 	for (al = d->d_attrs; al != NULL; al = al->al_next) {
 		a = al->al_this;
 		for (nv1 = a->a_devs; nv1 != NULL; nv1 = nv1->nv_next) {
-			if (is_orphan_loop(nv1->nv_ptr, d)) {
-if (d->d_level++ > 1)
-	continue;
-			}
 			do_kill_orphans(nv1->nv_ptr, a, d, active);
 		}
 	}
+out:
 	d->d_levelparent = NULL;
+	d->d_level--;
 }
 
 static int



CVS commit: src/usr.bin/config

2017-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 24 23:42:36 UTC 2017

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

Log Message:
- Instead of checking the recursion level before we recurse, check in on
  function entry.
- Always decrement the level and reset levelparent on exit.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/config/main.c

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



CVS commit: src/usr.bin/config

2017-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 24 18:45:59 UTC 2017

Modified Files:
src/usr.bin/config: sem.c

Log Message:
Tidy up error messages, line wraps, initialization. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2017-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 24 18:45:59 UTC 2017

Modified Files:
src/usr.bin/config: sem.c

Log Message:
Tidy up error messages, line wraps, initialization. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/config/sem.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/config/sem.c
diff -u src/usr.bin/config/sem.c:1.80 src/usr.bin/config/sem.c:1.81
--- src/usr.bin/config/sem.c:1.80	Sat Nov 18 19:41:10 2017
+++ src/usr.bin/config/sem.c	Fri Nov 24 13:45:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.80 2017/11/19 00:41:10 kre Exp $	*/
+/*	$NetBSD: sem.c,v 1.81 2017/11/24 18:45:59 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.80 2017/11/19 00:41:10 kre Exp $");
+__RCSID("$NetBSD: sem.c,v 1.81 2017/11/24 18:45:59 christos Exp $");
 
 #include 
 #include 
@@ -214,7 +214,8 @@ fixdev(struct devbase *dev)
 	CFGDBG(4, "fixing devbase `%s'", dev->d_name);
 	for (al = dev->d_attrs; al != NULL; al = al->al_next) {
 		a = al->al_this;
-		CFGDBG(4, "fixing devbase `%s' attr `%s'", dev->d_name, a->a_name);
+		CFGDBG(4, "fixing devbase `%s' attr `%s'", dev->d_name,
+		a->a_name);
 		if (a->a_iattr) {
 			a->a_refs = addtoattr(a->a_refs, dev);
 			CFGDBG(3, "device `%s' has iattr `%s'", dev->d_name,
@@ -228,8 +229,8 @@ fixdev(struct devbase *dev)
 			}
 			if (dev->d_classattr == NULL) {
 dev->d_classattr = a;
-CFGDBG(3, "device `%s' is devclass `%s'", dev->d_name,
-a->a_name);
+CFGDBG(3, "device `%s' is devclass `%s'",
+dev->d_name, a->a_name);
 			}
 		} else {
 			if (strcmp(dev->d_name, a->a_name) != 0) {
@@ -396,7 +397,7 @@ defiattr(const char *name, struct loclis
 	struct loclist *ll;
 
 	if (devclass)
-		panic("defattr(%s): locators and devclass", name);
+		panic("%s: %s has both locators and devclass", __func__, name);
 
 	if (defattr(name, locs, deps, devclass) != 0)
 		return (1);
@@ -426,7 +427,8 @@ defdevclass(const char *name, struct loc
 	int errored = 0;
 
 	if (deps)
-		panic("defattr(%s): dependencies and devclass", name);
+		panic("%s: %s has both dependencies and devclass", __func__,
+		name);
 
 	if (defattr(name, locs, deps, devclass) != 0)
 		return (1);
@@ -434,9 +436,9 @@ defdevclass(const char *name, struct loc
 	a = getattr(name);
 	(void)snprintf(classenum, sizeof(classenum), "DV_%s", name);
 	for (cp = classenum + 3; *cp; cp++) {
-		if (!errored &&
-		(!isalnum((unsigned char)*cp) ||
-		  (isalpha((unsigned char)*cp) && !islower((unsigned char)*cp {
+		if (!errored && (!isalnum((unsigned char)*cp) ||
+		  (isalpha((unsigned char)*cp)
+		  && !islower((unsigned char)*cp {
 			cfgerror("device class names must be "
 			"lower-case alphanumeric characters");
 			errored = 1;
@@ -625,7 +627,7 @@ getdevbase(const char *name)
 		dev->d_umax = 0;
 		TAILQ_INSERT_TAIL(, dev, d_next);
 		if (ht_insert(devbasetab, name, dev))
-			panic("getdevbase(%s)", name);
+			panic("%s: Can't insert %s", __func__, name);
 		CFGDBG(3, "devbase defined `%s'", dev->d_name);
 	}
 	return (dev);
@@ -765,7 +767,7 @@ getdevattach(const char *name)
 		deva->d_ipp = >d_ihead;
 		TAILQ_INSERT_TAIL(, deva, d_next);
 		if (ht_insert(devatab, name, deva))
-			panic("getdeva(%s)", name);
+			panic("%s: Can't insert %s", __func__, name);
 	}
 	return (deva);
 }
@@ -938,7 +940,7 @@ resolve(struct nvlist **nvp, const char 
 	char buf[NAMESIZE];
 
 	if ((part -= 'a') >= maxpartitions || part < 0)
-		panic("resolve");
+		panic("%s: Bad partition %c", __func__, part);
 	if ((nv = *nvp) == NULL) {
 		dev_t	d = NODEV;
 		/*
@@ -,7 +1113,7 @@ delconf(const char *name, int nowarn)
 		if (!strcmp(cf->cf_name, name))
 			break;
 	if (cf == NULL)
-		panic("lost configuration `%s'", name);
+		panic("%s: lost configuration for %s", __func__, name);
 
 	TAILQ_REMOVE(, cf, cf_next);
 }
@@ -1251,14 +1253,12 @@ adddev(const char *name, const char *at,
 	struct devbase *ab;	/* not NULL => at another dev */
 	struct deva *iba;	/* devbase attachment used */
 	struct deva *lastiba;
-	int atunit;
+	int atunit, first;
 
 	lastiba = NULL;
 	if ((i = getdevi(name)) == NULL)
 		goto bad;
 	ib = i->i_base;
-	iba = NULL;
-	p = NULL;
 	attr = finddevattr(name, at, ib, , );
 	if (attr == NULL) {
 		i->i_active = DEVI_BROKEN;
@@ -1271,11 +1271,13 @@ adddev(const char *name, const char *at,
 			attr ==  ? NULL : attr))
 break;
 
+		first = lastiba == ib->d_ahead;
 		if (iba == NULL) {
-			if (lastiba != ib->d_ahead)
+			if (!first)
 goto bad;
 			if (attr != ) {
-panic("adddev: can't figure out attachment");
+panic("%s: can't figure out attachment",
+__func__);
 			} else {
 cfgerror("`%s' cannot attach to the root",
 ib->d_name);
@@ -1283,7 +1285,7 @@ adddev(const char *name, const char *at,
 			}
 		}
 		

CVS commit: src/usr.bin/config

2017-11-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 19 01:46:29 UTC 2017

Modified Files:
src/usr.bin/config: mkioconf.c

Log Message:
Don't print instances we've already printed.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/config/mkioconf.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/config/mkioconf.c
diff -u src/usr.bin/config/mkioconf.c:1.34 src/usr.bin/config/mkioconf.c:1.35
--- src/usr.bin/config/mkioconf.c:1.34	Sat Nov 18 13:44:20 2017
+++ src/usr.bin/config/mkioconf.c	Sat Nov 18 20:46:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkioconf.c,v 1.34 2017/11/18 18:44:20 christos Exp $	*/
+/*	$NetBSD: mkioconf.c,v 1.35 2017/11/19 01:46:29 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: mkioconf.c,v 1.34 2017/11/18 18:44:20 christos Exp $");
+__RCSID("$NetBSD: mkioconf.c,v 1.35 2017/11/19 01:46:29 christos Exp $");
 
 #include 
 #include 
@@ -344,7 +344,7 @@ emitparents(FILE *fp)
 	TAILQ_FOREACH(p, , p_list) {
 		if (p->p_devs == NULL || p->p_active != DEVI_ACTIVE)
 			continue;
-		if (inst == p->p_inst)
+		if (inst >= p->p_inst)
 			continue;
 		inst = p->p_inst;
 		fprintf(fp,



CVS commit: src/usr.bin/config

2017-11-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 19 01:46:29 UTC 2017

Modified Files:
src/usr.bin/config: mkioconf.c

Log Message:
Don't print instances we've already printed.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/config/mkioconf.c

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



CVS commit: src/usr.bin/config

2017-11-18 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Nov 19 00:41:10 UTC 2017

Modified Files:
src/usr.bin/config: sem.c

Log Message:
Remove a stray left over debug printf that crashes the builds (ab==NULL).


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/config/sem.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/config/sem.c
diff -u src/usr.bin/config/sem.c:1.79 src/usr.bin/config/sem.c:1.80
--- src/usr.bin/config/sem.c:1.79	Sat Nov 18 18:44:20 2017
+++ src/usr.bin/config/sem.c	Sun Nov 19 00:41:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.79 2017/11/18 18:44:20 christos Exp $	*/
+/*	$NetBSD: sem.c,v 1.80 2017/11/19 00:41:10 kre Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.79 2017/11/18 18:44:20 christos Exp $");
+__RCSID("$NetBSD: sem.c,v 1.80 2017/11/19 00:41:10 kre Exp $");
 
 #include 
 #include 
@@ -1915,7 +1915,6 @@ getpspec(struct attr *attr, struct devba
 		   	inst = p->p_inst; 
 		}
 	}
-printf("2. %d %p %s %d %s\n", npspecs, attr, ab->d_name, atunit, da->d_name);
 
 	p = ecalloc(1, sizeof(*p));
 



CVS commit: src/usr.bin/config

2017-11-18 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Nov 19 00:41:10 UTC 2017

Modified Files:
src/usr.bin/config: sem.c

Log Message:
Remove a stray left over debug printf that crashes the builds (ab==NULL).


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2017-11-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 18 18:44:20 UTC 2017

Modified Files:
src/usr.bin/config: defs.h mkioconf.c sem.c

Log Message:
Allow multiple attachments methods to the same child+parent combination:

foo* at bar? with baz
foo* at bar? with barf

Do this by scanning the list of iba's and allocating a new cfparent for
each. Keep track of the shared parent+child combinations by using the
same id for them.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/config/defs.h
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/config/mkioconf.c
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/config/sem.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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.100 src/usr.bin/config/defs.h:1.101
--- src/usr.bin/config/defs.h:1.100	Thu Nov 16 12:08:07 2017
+++ src/usr.bin/config/defs.h	Sat Nov 18 13:44:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.100 2017/11/16 17:08:07 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.101 2017/11/18 18:44:20 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -107,7 +107,7 @@ extern const char *progname;
  * The next two lines define the current version of the config(1) binary,
  * and the minimum version of the configuration files it supports.
  */
-#define CONFIG_VERSION		20170615
+#define CONFIG_VERSION		20171118
 #define CONFIG_MINVERSION	0
 
 /*
@@ -234,6 +234,7 @@ struct pspec {
 	struct	devbase *p_atdev;	/* optional parent device base */
 	int	p_atunit;		/* optional parent device unit */
 	struct	nvlist *p_devs;		/* children using it */
+	struct	deva *p_deva;		/* attribute */
 	int	p_inst;			/* parent spec instance */
 	int	p_active;		/* parent spec is actively used */
 };

Index: src/usr.bin/config/mkioconf.c
diff -u src/usr.bin/config/mkioconf.c:1.33 src/usr.bin/config/mkioconf.c:1.34
--- src/usr.bin/config/mkioconf.c:1.33	Thu Nov 12 09:38:21 2015
+++ src/usr.bin/config/mkioconf.c	Sat Nov 18 13:44:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkioconf.c,v 1.33 2015/11/12 14:38:21 pooka Exp $	*/
+/*	$NetBSD: mkioconf.c,v 1.34 2017/11/18 18:44:20 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: mkioconf.c,v 1.33 2015/11/12 14:38:21 pooka Exp $");
+__RCSID("$NetBSD: mkioconf.c,v 1.34 2017/11/18 18:44:20 christos Exp $");
 
 #include 
 #include 
@@ -338,11 +338,15 @@ static void
 emitparents(FILE *fp)
 {
 	struct pspec *p;
+	int inst = -1;
 
 	NEWLINE;
 	TAILQ_FOREACH(p, , p_list) {
 		if (p->p_devs == NULL || p->p_active != DEVI_ACTIVE)
 			continue;
+		if (inst == p->p_inst)
+			continue;
+		inst = p->p_inst;
 		fprintf(fp,
 		"static const struct cfparent pspec%d = {\n", p->p_inst);
 		fprintf(fp, "\t\"%s\", ", p->p_iattr->a_name);

Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.78 src/usr.bin/config/sem.c:1.79
--- src/usr.bin/config/sem.c:1.78	Sat Nov 18 13:41:44 2017
+++ src/usr.bin/config/sem.c	Sat Nov 18 13:44:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.78 2017/11/18 18:41:44 christos Exp $	*/
+/*	$NetBSD: sem.c,v 1.79 2017/11/18 18:44:20 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.78 2017/11/18 18:41:44 christos Exp $");
+__RCSID("$NetBSD: sem.c,v 1.79 2017/11/18 18:44:20 christos Exp $");
 
 #include 
 #include 
@@ -79,7 +79,8 @@ static int has_errobj(struct attrlist *,
 static struct nvlist *addtoattr(struct nvlist *, struct devbase *);
 static int resolve(struct nvlist **, const char *, const char *,
 		   struct nvlist *, int);
-static struct pspec *getpspec(struct attr *, struct devbase *, int);
+static struct pspec *getpspec(struct attr *, struct devbase *, int,
+struct deva *);
 static struct devi *newdevi(const char *, int, struct devbase *d);
 static struct devi *getdevi(const char *);
 static void remove_devi(struct devi *);
@@ -641,7 +642,6 @@ defdevattach(struct deva *deva, struct d
 	struct nvlist *nv;
 	struct attrlist *al;
 	struct attr *a;
-	struct deva *da;
 
 	if (dev == )
 		goto bad;
@@ -699,14 +699,16 @@ defdevattach(struct deva *deva, struct d
 		if (a == )
 			continue;		/* already complained */
 
+#if 0
 		/*
 		 * Make sure that an attachment spec doesn't
 		 * already say how to attach to this attribute.
 		 */
-		for (da = dev->d_ahead; da != NULL; da = da->d_bsame)
+		for (struct deva *da = dev->d_ahead; da; da = da->d_bsame)
 			if (onlist(da->d_atlist, a))
 cfgerror("attach at `%s' already done by `%s'",
  a ? a->a_name : "root", da->d_name);
+#endif
 
 		if (a == NULL) {
 			ht_insert(devroottab, dev->d_name, dev);
@@ -1158,6 +1160,83 @@ newdevi(const char *name, int unit, stru
 	return (i);
 }
 
+static struct attr *
+finddevattr(const char *name, const char *at, struct devbase *ib,
+struct devbase **ab, int *atunit)
+{
+	const char *cp;
+	char atbuf[NAMESIZE];
+	

CVS commit: src/usr.bin/config

2017-11-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 18 18:44:20 UTC 2017

Modified Files:
src/usr.bin/config: defs.h mkioconf.c sem.c

Log Message:
Allow multiple attachments methods to the same child+parent combination:

foo* at bar? with baz
foo* at bar? with barf

Do this by scanning the list of iba's and allocating a new cfparent for
each. Keep track of the shared parent+child combinations by using the
same id for them.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/config/defs.h
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/config/mkioconf.c
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2017-11-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 18 18:41:44 UTC 2017

Modified Files:
src/usr.bin/config: sem.c

Log Message:
- Factor out the remove_pspec code into a function.
- Avoid NULL pointer when printing an error.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.bin/config/sem.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/config/sem.c
diff -u src/usr.bin/config/sem.c:1.77 src/usr.bin/config/sem.c:1.78
--- src/usr.bin/config/sem.c:1.77	Tue Sep 13 12:06:59 2016
+++ src/usr.bin/config/sem.c	Sat Nov 18 13:41:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.77 2016/09/13 16:06:59 christos Exp $	*/
+/*	$NetBSD: sem.c,v 1.78 2017/11/18 18:41:44 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.77 2016/09/13 16:06:59 christos Exp $");
+__RCSID("$NetBSD: sem.c,v 1.78 2017/11/18 18:41:44 christos Exp $");
 
 #include 
 #include 
@@ -1352,6 +1352,34 @@ deldevi(const char *name, const char *at
 }
 
 static void
+remove_pspec(struct devi *i)
+{
+	struct pspec *p = i->i_pspec;
+	struct nvlist *nv, *onv;
+
+	if (p == NULL)
+		return;
+
+	/* Double-linked nvlist anyone? */
+	for (nv = p->p_devs; nv->nv_next != NULL; nv = nv->nv_next) {
+		if (nv->nv_next && nv->nv_next->nv_ptr == i) {
+			onv = nv->nv_next;
+			nv->nv_next = onv->nv_next;
+			nvfree(onv);
+			break;
+		}
+		if (nv->nv_ptr == i) {
+			/* nv is p->p_devs in that case */
+			p->p_devs = nv->nv_next;
+			nvfree(nv);
+			break;
+		}
+	}
+	if (p->p_devs == NULL)
+		TAILQ_REMOVE(, p, p_list);
+}
+
+static void
 remove_devi(struct devi *i)
 {
 	struct devbase *d = i->i_base;
@@ -1453,28 +1481,8 @@ remove_devi(struct devi *i)
 	/*
 	 *   - delete the pspec
 	 */
-	if (i->i_pspec) {
-		struct pspec *p = i->i_pspec;
-		struct nvlist *nv, *onv;
-
-		/* Double-linked nvlist anyone? */
-		for (nv = p->p_devs; nv->nv_next != NULL; nv = nv->nv_next) {
-			if (nv->nv_next && nv->nv_next->nv_ptr == i) {
-onv = nv->nv_next;
-nv->nv_next = onv->nv_next;
-nvfree(onv);
-break;
-			}
-			if (nv->nv_ptr == i) {
-/* nv is p->p_devs in that case */
-p->p_devs = nv->nv_next;
-nvfree(nv);
-break;
-			}
-		}
-		if (p->p_devs == NULL)
-			TAILQ_REMOVE(, p, p_list);
-	}
+	remove_pspec(i);
+
 	/*
 	 *   - delete the alldevi entry
 	 */
@@ -1846,6 +1854,7 @@ int
 fixdevis(void)
 {
 	struct devi *i;
+	struct pspec *p;
 	int error = 0;
 
 	TAILQ_FOREACH(i, , i_next) {
@@ -1858,9 +1867,11 @@ fixdevis(void)
 			 * i_at or i_pspec are NULL.
 			 */
 			++error;
+			p = i->i_pspec;
 			cfgxerror(i->i_srcfile, i->i_lineno,
 			"`%s at %s' is orphaned (%s `%s' found)", 
-			i->i_name, i->i_at, i->i_pspec->p_atunit == WILD ?
+			i->i_name, i->i_at,
+			p == NULL || p->p_atunit == WILD ?
 			"nothing matching" : "no", i->i_at);
 		} else if (vflag && i->i_active == DEVI_IGNORED)
 			cfgxwarn(i->i_srcfile, i->i_lineno, "ignoring "



CVS commit: src/usr.bin/config

2017-11-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 18 18:41:44 UTC 2017

Modified Files:
src/usr.bin/config: sem.c

Log Message:
- Factor out the remove_pspec code into a function.
- Avoid NULL pointer when printing an error.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2017-11-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 18 18:39:16 UTC 2017

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

Log Message:
add more debugging, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/config/main.c

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



CVS commit: src/usr.bin/config

2017-11-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 18 18:39:16 UTC 2017

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

Log Message:
add more debugging, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/config/main.c

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

Modified files:

Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.93 src/usr.bin/config/main.c:1.94
--- src/usr.bin/config/main.c:1.93	Fri Nov 17 20:11:05 2017
+++ src/usr.bin/config/main.c	Sat Nov 18 13:39:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.93 2017/11/18 01:11:05 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.94 2017/11/18 18:39:16 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: main.c,v 1.93 2017/11/18 01:11:05 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.94 2017/11/18 18:39:16 christos Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include 
@@ -1957,6 +1957,12 @@ do_kill_orphans(struct devbase *d, struc
 	j->i_active = active = state;
 	if (p != NULL)
 		p->p_active = state;
+	if (state == DEVI_IGNORED) {
+		CFGDBG(5,
+		"`%s' at '%s' ignored",
+		d->d_name, parent ?
+		parent->d_name : "(root)");
+	}
 }
 			}
 		}
@@ -1969,7 +1975,7 @@ do_kill_orphans(struct devbase *d, struc
 			struct cdd_params cdd = { d, at, parent };
 			/* Look for a matching dead devi */
 			if (ht_enumerate(deaddevitab, check_dead_devi, ) &&
-			d != parent)
+			d != parent) {
 /*
  * That device had its instances removed.
  * Continue the loop marking descendants
@@ -1981,7 +1987,10 @@ do_kill_orphans(struct devbase *d, struc
  * have to continue looping.
  */
 active = DEVI_IGNORED;
-			else
+CFGDBG(5, "`%s' at '%s' ignored", d->d_name,
+parent ? parent->d_name : "(root)");
+
+			} else
 return;
 		}
 	}



CVS commit: src/usr.bin/config

2017-11-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 18 01:11:05 UTC 2017

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

Log Message:
avoid creating infinite loops.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/config/main.c

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



CVS commit: src/usr.bin/config

2017-11-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 18 01:11:05 UTC 2017

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

Log Message:
avoid creating infinite loops.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/config/main.c

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

Modified files:

Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.92 src/usr.bin/config/main.c:1.93
--- src/usr.bin/config/main.c:1.92	Thu Nov 16 12:08:07 2017
+++ src/usr.bin/config/main.c	Fri Nov 17 20:11:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.92 2017/11/16 17:08:07 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.93 2017/11/18 01:11:05 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: main.c,v 1.92 2017/11/16 17:08:07 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.93 2017/11/18 01:11:05 christos Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include 
@@ -1878,6 +1878,20 @@ is_orphan_loop(const struct devbase *d, 
 }
 
 static void
+addlevelparent(struct devbase *d, struct devbase *parent)
+{
+	struct devbase *p;
+
+	if (d->d_levelparent)
+		return;
+
+	for (p = parent; p != NULL; p = p->d_levelparent)
+		if (d == p)
+			return;
+	d->d_levelparent = p;
+}
+
+static void
 do_kill_orphans(struct devbase *d, struct attr *at, struct devbase *parent,
 int state)
 {
@@ -1888,8 +1902,7 @@ do_kill_orphans(struct devbase *d, struc
 	struct pspec *p;
 	int active = 0;
 
-	if (d->d_levelparent == NULL)
-		d->d_levelparent = parent;
+	addlevelparent(d, parent);
 
 	/*
 	 * A pseudo-device will always attach at root, and if it has an



CVS commit: src/usr.bin/config

2017-11-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 16 17:08:07 UTC 2017

Modified Files:
src/usr.bin/config: defs.h main.c

Log Message:
When deleting orphans detect parent<->child loops and break them.
"active" is not a boolean, use the right comparison.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/config/defs.h
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/config/main.c

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



CVS commit: src/usr.bin/config

2017-11-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 16 17:08:07 UTC 2017

Modified Files:
src/usr.bin/config: defs.h main.c

Log Message:
When deleting orphans detect parent<->child loops and break them.
"active" is not a boolean, use the right comparison.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/config/defs.h
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/config/main.c

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

Modified files:

Index: src/usr.bin/config/defs.h
diff -u src/usr.bin/config/defs.h:1.99 src/usr.bin/config/defs.h:1.100
--- src/usr.bin/config/defs.h:1.99	Thu Jun 15 20:10:09 2017
+++ src/usr.bin/config/defs.h	Thu Nov 16 12:08:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.99 2017/06/16 00:10:09 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.100 2017/11/16 17:08:07 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -264,6 +264,8 @@ struct pspec {
 struct devbase {
 	const char *d_name;		/* e.g., "sd" */
 	TAILQ_ENTRY(devbase) d_next;
+	int 	d_level;
+	struct devbase *d_levelparent;
 	int	d_isdef;		/* set once properly defined */
 	int	d_ispseudo;		/* is a pseudo-device */
 	devmajor_t d_major;		/* used for "root on sd0", e.g. */

Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.91 src/usr.bin/config/main.c:1.92
--- src/usr.bin/config/main.c:1.91	Sun Sep  4 20:40:28 2016
+++ src/usr.bin/config/main.c	Thu Nov 16 12:08:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.91 2016/09/05 00:40:28 sevan Exp $	*/
+/*	$NetBSD: main.c,v 1.92 2017/11/16 17:08:07 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: main.c,v 1.91 2016/09/05 00:40:28 sevan Exp $");
+__RCSID("$NetBSD: main.c,v 1.92 2017/11/16 17:08:07 christos Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include 
@@ -1868,6 +1868,15 @@ check_dead_devi(const char *key, void *v
 	return 0;
 }
 
+static int
+is_orphan_loop(const struct devbase *d, const struct devbase *p)
+{
+
+	for (; p && d != p; p = p->d_levelparent)
+		continue;
+	return d == p;
+}
+
 static void
 do_kill_orphans(struct devbase *d, struct attr *at, struct devbase *parent,
 int state)
@@ -1879,6 +1888,9 @@ do_kill_orphans(struct devbase *d, struc
 	struct pspec *p;
 	int active = 0;
 
+	if (d->d_levelparent == NULL)
+		d->d_levelparent = parent;
+
 	/*
 	 * A pseudo-device will always attach at root, and if it has an
 	 * instance (it cannot have more than one), it is enough to consider
@@ -1938,9 +1950,9 @@ do_kill_orphans(struct devbase *d, struc
 		/*
 		 * If we've been there but have made no change, stop.
 		 */
-		if (seen && !active)
+		if (seen && active != DEVI_ACTIVE)
 			return;
-		if (!active) {
+		if (active != DEVI_ACTIVE) {
 			struct cdd_params cdd = { d, at, parent };
 			/* Look for a matching dead devi */
 			if (ht_enumerate(deaddevitab, check_dead_devi, ) &&
@@ -1963,9 +1975,15 @@ do_kill_orphans(struct devbase *d, struc
 
 	for (al = d->d_attrs; al != NULL; al = al->al_next) {
 		a = al->al_this;
-		for (nv1 = a->a_devs; nv1 != NULL; nv1 = nv1->nv_next)
+		for (nv1 = a->a_devs; nv1 != NULL; nv1 = nv1->nv_next) {
+			if (is_orphan_loop(nv1->nv_ptr, d)) {
+if (d->d_level++ > 1)
+	continue;
+			}
 			do_kill_orphans(nv1->nv_ptr, a, d, active);
+		}
 	}
+	d->d_levelparent = NULL;
 }
 
 static int



CVS commit: src/usr.bin/config

2017-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun 16 02:01:10 UTC 2017

Modified Files:
src/usr.bin/config: mkmakefile.c

Log Message:
un-c99


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/config/mkmakefile.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/config/mkmakefile.c
diff -u src/usr.bin/config/mkmakefile.c:1.69 src/usr.bin/config/mkmakefile.c:1.70
--- src/usr.bin/config/mkmakefile.c:1.69	Thu Jun 15 19:52:15 2017
+++ src/usr.bin/config/mkmakefile.c	Thu Jun 15 22:01:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkmakefile.c,v 1.69 2017/06/15 23:52:15 christos Exp $	*/
+/*	$NetBSD: mkmakefile.c,v 1.70 2017/06/16 02:01:10 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: mkmakefile.c,v 1.69 2017/06/15 23:52:15 christos Exp $");
+__RCSID("$NetBSD: mkmakefile.c,v 1.70 2017/06/16 02:01:10 christos Exp $");
 
 #include 
 #include 
@@ -214,15 +214,14 @@ mkmakefile(void)
 static void
 emitmkoption(FILE *fp, const char *ass, const struct nvlist *nv)
 {
+	const char *p;
 
 	fprintf(fp, "%s%s", nv->nv_name, ass);
-
-	for (const char *p = nv->nv_str; *p; p++) {
+	for (p = nv->nv_str; *p; p++) {
 		if (*p == '\n')
 			fputs(" \\", fp);
 		fputc(*p, fp);
 	}
-
 	fputc('\n', fp);
 }
 



CVS commit: src/usr.bin/config

2017-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun 16 02:01:10 UTC 2017

Modified Files:
src/usr.bin/config: mkmakefile.c

Log Message:
un-c99


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

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



CVS commit: src/usr.bin/config

2017-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun 16 00:10:10 UTC 2017

Modified Files:
src/usr.bin/config: defs.h

Log Message:
Bump for quoting makeoptions with multiple lines.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/config/defs.h

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



CVS commit: src/usr.bin/config

2017-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun 16 00:10:10 UTC 2017

Modified Files:
src/usr.bin/config: defs.h

Log Message:
Bump for quoting makeoptions with multiple lines.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/config/defs.h

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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.98 src/usr.bin/config/defs.h:1.99
--- src/usr.bin/config/defs.h:1.98	Fri Sep  9 17:09:11 2016
+++ src/usr.bin/config/defs.h	Thu Jun 15 20:10:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.98 2016/09/09 21:09:11 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.99 2017/06/16 00:10:09 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -107,7 +107,7 @@ extern const char *progname;
  * The next two lines define the current version of the config(1) binary,
  * and the minimum version of the configuration files it supports.
  */
-#define CONFIG_VERSION		20160808
+#define CONFIG_VERSION		20170615
 #define CONFIG_MINVERSION	0
 
 /*



CVS commit: src/usr.bin/config

2017-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jun 15 23:52:15 UTC 2017

Modified Files:
src/usr.bin/config: mkmakefile.c

Log Message:
Allow multiline makeoptions to work by quoting the newline..


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/config/mkmakefile.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/config/mkmakefile.c
diff -u src/usr.bin/config/mkmakefile.c:1.68 src/usr.bin/config/mkmakefile.c:1.69
--- src/usr.bin/config/mkmakefile.c:1.68	Fri Sep  4 06:16:35 2015
+++ src/usr.bin/config/mkmakefile.c	Thu Jun 15 19:52:15 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkmakefile.c,v 1.68 2015/09/04 10:16:35 uebayasi Exp $	*/
+/*	$NetBSD: mkmakefile.c,v 1.69 2017/06/15 23:52:15 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: mkmakefile.c,v 1.68 2015/09/04 10:16:35 uebayasi Exp $");
+__RCSID("$NetBSD: mkmakefile.c,v 1.69 2017/06/15 23:52:15 christos Exp $");
 
 #include 
 #include 
@@ -77,6 +77,7 @@ static void emitrules(FILE *);
 static void emitload(FILE *);
 static void emitincludes(FILE *);
 static void emitappmkoptions(FILE *);
+static void emitmkoption(FILE *, const char *, const struct nvlist *);
 static void emitsubs(FILE *, const char *, const char *, int);
 static int  selectopt(const char *, void *);
 
@@ -211,6 +212,21 @@ mkmakefile(void)
 }
 
 static void
+emitmkoption(FILE *fp, const char *ass, const struct nvlist *nv)
+{
+
+	fprintf(fp, "%s%s", nv->nv_name, ass);
+
+	for (const char *p = nv->nv_str; *p; p++) {
+		if (*p == '\n')
+			fputs(" \\", fp);
+		fputc(*p, fp);
+	}
+
+	fputc('\n', fp);
+}
+
+static void
 emitsubs(FILE *fp, const char *line, const char *file, int lineno)
 {
 	char *nextpct;
@@ -292,7 +308,7 @@ emitdefs(FILE *fp)
 		fprintf(fp, "___USE_SUFFIX_RULES___=1\n");
 	}
 	for (nv = mkoptions; nv != NULL; nv = nv->nv_next)
-		fprintf(fp, "%s=%s\n", nv->nv_name, nv->nv_str);
+		emitmkoption(fp, "=", nv);
 }
 
 static void
@@ -583,7 +599,7 @@ emitappmkoptions(FILE *fp)
 	for (nv = condmkoptions; nv != NULL; nv = nv->nv_next) {
 		cond = nv->nv_ptr;
 		if (expr_eval(cond, selectopt, NULL))
-			fprintf(fp, "%s+=%s\n", nv->nv_name, nv->nv_str);
+			emitmkoption(fp, "+=", nv);
 		condexpr_destroy(cond);
 		nv->nv_ptr = NULL;
 	}



CVS commit: src/usr.bin/config

2017-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jun 15 23:52:15 UTC 2017

Modified Files:
src/usr.bin/config: mkmakefile.c

Log Message:
Allow multiline makeoptions to work by quoting the newline..


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/config/mkmakefile.c

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



CVS commit: src/usr.bin/config

2016-09-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 13 16:06:59 UTC 2016

Modified Files:
src/usr.bin/config: sem.c

Log Message:
define the attribute first.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2016-09-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 13 16:06:59 UTC 2016

Modified Files:
src/usr.bin/config: sem.c

Log Message:
define the attribute first.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/usr.bin/config/sem.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/config/sem.c
diff -u src/usr.bin/config/sem.c:1.76 src/usr.bin/config/sem.c:1.77
--- src/usr.bin/config/sem.c:1.76	Fri Sep  9 17:09:11 2016
+++ src/usr.bin/config/sem.c	Tue Sep 13 12:06:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.76 2016/09/09 21:09:11 christos Exp $	*/
+/*	$NetBSD: sem.c,v 1.77 2016/09/13 16:06:59 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.76 2016/09/09 21:09:11 christos Exp $");
+__RCSID("$NetBSD: sem.c,v 1.77 2016/09/13 16:06:59 christos Exp $");
 
 #include 
 #include 
@@ -336,6 +336,14 @@ defattr(const char *name, struct loclist
 	struct attr *a, *dep;
 	struct attrlist *al;
 
+	if (getrefattr(name, )) {
+		cfgerror("attribute `%s' already defined", name);
+		loclist_destroy(locs);
+		return (1);
+	}
+	if (a == NULL)
+		a = mkattr(name);
+
 	/*
 	 * If this attribute depends on any others, make sure none of
 	 * the dependencies are interface attributes.
@@ -352,13 +360,6 @@ defattr(const char *name, struct loclist
 		CFGDBG(2, "attr `%s' depends on attr `%s'", name, dep->a_name);
 	}
 
-	if (getrefattr(name, )) {
-		cfgerror("attribute `%s' already defined", name);
-		loclist_destroy(locs);
-		return (1);
-	}
-	if (a == NULL)
-		a = mkattr(name);
 
 	a->a_deps = deps;
 	expandattr(a, NULL);



Re: CVS commit: src/usr.bin/config

2016-09-13 Thread Roy Marples
On 09/09/2016 22:09, Christos Zoulas wrote:
> Module Name:  src
> Committed By: christos
> Date: Fri Sep  9 21:09:11 UTC 2016
> 
> Modified Files:
>   src/usr.bin/config: defs.h files.c sem.c
> 
> Log Message:
> Make attribute deselection work:
> - when deselecting attributes, remove files that depend on them
> - when deselecting attributes, remove devices that depend on them
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.97 -r1.98 src/usr.bin/config/defs.h
> cvs rdiff -u -r1.35 -r1.36 src/usr.bin/config/files.c
> cvs rdiff -u -r1.75 -r1.76 src/usr.bin/config/sem.c

#   compile  config/sem.o
/home/roy/tools/amd64/bin/x86_64--netbsd-clang -O2 -g -fPIE
-fstack-protector -Wstack-protector  --param ssp-buffer-size=1
-std=gnu99 -Wno-sign-compare -Wno-pointer-sign  -Wall
-Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
-Wno-sign-compare  -Wa,--fatal-warnings -Wreturn-type -Wswitch -Wshadow
-Wcast-
qual -Wwrite-strings -Wextra -Wno-unused-parameter -Wno-sign-compare
-Wold-style-definition -Wconversion -Wsign-compare -Wformat=2
-Wpointer-sign -Wmissing-no
return  -Werror -Wno-format-y2k  -pipe
--sysroot=/home/roy/src/src/obj/destdir.amd64
-I/home/roy/src/src/usr.bin/config -I. -I/home/roy/src/src/usr.bin/cksum
-D_FORTIFY_SOURCE=2 -c/home/roy/src/src/usr.bin/config/sem.c
/home/roy/src/src/usr.bin/config/sem.c:351:29: error: variable 'a' is
uninitialized when used here [-Werror,-Wuninitialized]
addvalue(V_ATTRIBUTE, a, dep));
  ^
/home/roy/src/src/usr.bin/config/defs.h:528:68: note: expanded from
macro 'ht_insert2'
#define ht_insert2(ht, nam1, nam2, val) ht_insrep2(ht, nam1, nam2, val, 0)
   ^~~
/home/roy/src/src/usr.bin/config/sem.c:336:16: note: initialize the
variable 'a' to silence this warning
struct attr *a, *dep;
  ^
   = NULL
1 error generated.
*** [sem.o] Error code 1


CVS commit: src/usr.bin/config

2016-09-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep  9 21:09:11 UTC 2016

Modified Files:
src/usr.bin/config: defs.h files.c sem.c

Log Message:
Make attribute deselection work:
- when deselecting attributes, remove files that depend on them
- when deselecting attributes, remove devices that depend on them


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/config/defs.h
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/config/files.c
cvs rdiff -u -r1.75 -r1.76 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2016-09-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep  9 21:09:11 UTC 2016

Modified Files:
src/usr.bin/config: defs.h files.c sem.c

Log Message:
Make attribute deselection work:
- when deselecting attributes, remove files that depend on them
- when deselecting attributes, remove devices that depend on them


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/config/defs.h
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/config/files.c
cvs rdiff -u -r1.75 -r1.76 src/usr.bin/config/sem.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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.97 src/usr.bin/config/defs.h:1.98
--- src/usr.bin/config/defs.h:1.97	Sun Aug  7 17:11:55 2016
+++ src/usr.bin/config/defs.h	Fri Sep  9 17:09:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.97 2016/08/07 21:11:55 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.98 2016/09/09 21:09:11 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -190,7 +190,8 @@ struct attr {
 #define	a_weight	a_m.m_weight
 
 	/* "interface attribute" */
-	int	a_iattr;		/* true => allows children */
+	uint8_t	a_iattr;		/* true => allows children */
+	uint8_t a_deselected;		/* deselected */	
 	struct	loclist *a_locs;	/* locators required */
 	int	a_loclen;		/* length of above list */
 	struct	nvlist *a_devs;		/* children */

Index: src/usr.bin/config/files.c
diff -u src/usr.bin/config/files.c:1.35 src/usr.bin/config/files.c:1.36
--- src/usr.bin/config/files.c:1.35	Fri Sep  4 17:32:54 2015
+++ src/usr.bin/config/files.c	Fri Sep  9 17:09:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: files.c,v 1.35 2015/09/04 21:32:54 uebayasi Exp $	*/
+/*	$NetBSD: files.c,v 1.36 2016/09/09 21:09:11 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: files.c,v 1.35 2015/09/04 21:32:54 uebayasi Exp $");
+__RCSID("$NetBSD: files.c,v 1.36 2016/09/09 21:09:11 christos Exp $");
 
 #include 
 #include 
@@ -335,6 +335,11 @@ fixfiles(void)
 			if (!sel)
 continue;
 		}
+		if (fi->fi_attr && fi->fi_attr->a_deselected) {
+			CFGDBG(5, "file `%s' deselected because attr `%s' was",
+			fi->fi_path, fi->fi_attr->a_name);
+			continue;
+		}
 
 		/* We like this file.  Make sure it generates a unique .o. */
 		if (ht_insert(basetab, fi->fi_base, fi)) {

Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.75 src/usr.bin/config/sem.c:1.76
--- src/usr.bin/config/sem.c:1.75	Sun Aug  7 06:37:24 2016
+++ src/usr.bin/config/sem.c	Fri Sep  9 17:09:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.75 2016/08/07 10:37:24 christos Exp $	*/
+/*	$NetBSD: sem.c,v 1.76 2016/09/09 21:09:11 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.75 2016/08/07 10:37:24 christos Exp $");
+__RCSID("$NetBSD: sem.c,v 1.76 2016/09/09 21:09:11 christos Exp $");
 
 #include 
 #include 
@@ -95,6 +95,45 @@ static devmajor_t dev2major(struct devba
 extern const char *yyfile;
 extern int vflag;
 
+#define V_ATTRIBUTE	0
+#define V_DEVICE	1
+struct vtype {
+	int type;
+	struct attr *attr;
+	void *value;
+};
+
+static struct nvlist *
+makedevstack(struct devbase *d)
+{
+	struct devi *firsti, *i;
+	struct nvlist *stack = NULL;
+
+	for (firsti = d->d_ihead; firsti != NULL; firsti = firsti->i_bsame)
+		for (i = firsti; i != NULL; i = i->i_alias)
+			stack = newnv(NULL, NULL, i, 0, stack);
+	return stack;
+}
+
+static void
+devcleanup(struct nvlist *stack)
+{
+	struct nvlist *nv;
+	for (nv = stack; nv != NULL; nv = nv->nv_next)
+		remove_devi(nv->nv_ptr);
+	nvfreel(stack);
+}
+
+static void *
+addvalue(int type, struct attr *a, void *value)
+{
+	struct vtype *vt = emalloc(sizeof(*vt));
+	vt->type = type;
+	vt->attr = a;
+	vt->value = value;
+	return vt;
+}
+
 void
 initsem(void)
 {
@@ -308,7 +347,8 @@ defattr(const char *name, struct loclist
 			"attribute", name, dep->a_name);
 			return (1);
 		}
-		(void)ht_insert2(attrdeptab, name, dep->a_name, NULL);
+		(void)ht_insert2(attrdeptab, name, dep->a_name,
+		addvalue(V_ATTRIBUTE, a, dep));
 		CFGDBG(2, "attr `%s' depends on attr `%s'", name, dep->a_name);
 	}
 
@@ -536,7 +576,8 @@ defdev(struct devbase *dev, struct locli
 		 * Implicit attribute definition for device dependencies.
 		 */
 		refattr(al->al_this->a_name);
-		(void)ht_insert2(attrdeptab, dev->d_name, al->al_this->a_name, NULL);
+		(void)ht_insert2(attrdeptab, dev->d_name, al->al_this->a_name, 
+			addvalue(V_DEVICE, al->al_this, dev));
 		CFGDBG(2, "device `%s' depends on attr `%s'", dev->d_name,
 		al->al_this->a_name);
 	}
@@ -1563,9 +1604,7 @@ out:
 		}
 	}
 
-	for (nv = stack; nv != NULL; nv = nv->nv_next)
-		remove_devi(nv->nv_ptr);
-	nvfreel(stack);
+	devcleanup(stack);
 }
 
 void
@@ -1573,7 +1612,7 @@ deldev(const char *name, int nowarn)
 {
 	size_t l;
 	struct devi *firsti, *i;
-	struct nvlist *nv, *stack = NULL;
+	struct 

CVS commit: src/usr.bin/config

2016-08-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug  7 21:11:55 UTC 2016

Modified Files:
src/usr.bin/config: defs.h

Log Message:
Bump version for -no


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/config/defs.h

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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.96 src/usr.bin/config/defs.h:1.97
--- src/usr.bin/config/defs.h:1.96	Sun Aug  7 06:37:24 2016
+++ src/usr.bin/config/defs.h	Sun Aug  7 17:11:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.96 2016/08/07 10:37:24 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.97 2016/08/07 21:11:55 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -107,7 +107,7 @@ extern const char *progname;
  * The next two lines define the current version of the config(1) binary,
  * and the minimum version of the configuration files it supports.
  */
-#define CONFIG_VERSION		20151112
+#define CONFIG_VERSION		20160808
 #define CONFIG_MINVERSION	0
 
 /*



CVS commit: src/usr.bin/config

2016-08-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug  7 21:11:55 UTC 2016

Modified Files:
src/usr.bin/config: defs.h

Log Message:
Bump version for -no


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/config/defs.h

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



CVS commit: src/usr.bin/config

2016-08-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug  7 10:37:24 UTC 2016

Modified Files:
src/usr.bin/config: defs.h gram.y main.c scan.l sem.c sem.h

Log Message:
Accept "-no" as a "no" that does not cause errors if the object deleted
does not exist.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/config/defs.h
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/config/gram.y
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/config/main.c
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/config/scan.l
cvs rdiff -u -r1.74 -r1.75 src/usr.bin/config/sem.c
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/config/sem.h

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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.95 src/usr.bin/config/defs.h:1.96
--- src/usr.bin/config/defs.h:1.95	Fri Mar 18 11:05:49 2016
+++ src/usr.bin/config/defs.h	Sun Aug  7 06:37:24 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.95 2016/03/18 15:05:49 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.96 2016/08/07 10:37:24 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -569,9 +569,9 @@ void	deffilesystem(struct nvlist *, stru
 void	defoption(const char *, struct defoptlist *, struct nvlist *);
 void	defflag(const char *, struct defoptlist *, struct nvlist *, int);
 void	defparam(const char *, struct defoptlist *, struct nvlist *, int);
-void	deloption(const char *);
-void	delfsoption(const char *);
-void	delmkoption(const char *);
+void	deloption(const char *, int);
+void	delfsoption(const char *, int);
+void	delmkoption(const char *, int);
 int	devbase_has_instances(struct devbase *, int);
 int	is_declared_option(const char *);
 int	deva_has_instances(struct deva *, int);

Index: src/usr.bin/config/gram.y
diff -u src/usr.bin/config/gram.y:1.53 src/usr.bin/config/gram.y:1.54
--- src/usr.bin/config/gram.y:1.53	Fri Apr 29 14:18:22 2016
+++ src/usr.bin/config/gram.y	Sun Aug  7 06:37:24 2016
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: gram.y,v 1.53 2016/04/29 18:18:22 mlelstv Exp $	*/
+/*	$NetBSD: gram.y,v 1.54 2016/08/07 10:37:24 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: gram.y,v 1.53 2016/04/29 18:18:22 mlelstv Exp $");
+__RCSID("$NetBSD: gram.y,v 1.54 2016/08/07 10:37:24 christos Exp $");
 
 #include 
 #include 
@@ -60,6 +60,7 @@ __RCSID("$NetBSD: gram.y,v 1.53 2016/04/
 #define	stop(s)	cfgerror(s), exit(1)
 
 static	struct	config conf;	/* at most one active at a time */
+static	int	nowarn;		/* if warning suppression is on */
 
 
 /*
@@ -178,7 +179,7 @@ static struct loclist *namelocvals(const
 %token	IDENT IOCONF
 %token	LINKZERO
 %token	XMACHINE MAJOR MAKEOPTIONS MAXUSERS MAXPARTITIONS MINOR
-%token	NEEDS_COUNT NEEDS_FLAG NO
+%token	NEEDS_COUNT NEEDS_FLAG NO CNO
 %token	XOBJECT OBSOLETE ON OPTIONS
 %token	PACKAGE PLUSEQ PREFIX BUILDPREFIX PSEUDO_DEVICE PSEUDO_ROOT
 %token	ROOT
@@ -213,7 +214,7 @@ static struct loclist *namelocvals(const
 %type		value
 %type		major_minor
 %type		signed_number
-%type		int32 npseudo device_flags
+%type		int32 npseudo device_flags no
 %type		deffs
 %type		deffses
 %type		defopt
@@ -292,6 +293,11 @@ subarches:
 	| subarches WORD		{ $$ = new_nx($2, $1); }
 ;
 
+no:
+	  NO	{ $$ = 0; }
+	| CNO	{ $$ = 1; }
+;
+
 //
 
 /*
@@ -740,11 +746,11 @@ select_attr:
 ;
 
 select_no_attr:
-	NO SELECT WORD			{ delattr($3); }
+	no SELECT WORD			{ delattr($3, $1); }
 ;
 
 select_no_filesystems:
-	NO FILE_SYSTEM no_fs_list
+	no FILE_SYSTEM { nowarn = $1; } no_fs_list { nowarn = 0; }
 ;
 
 select_filesystems:
@@ -752,7 +758,7 @@ select_filesystems:
 ;
 
 select_no_makeoptions:
-	NO MAKEOPTIONS no_mkopt_list
+	no MAKEOPTIONS { nowarn = $1; } no_mkopt_list { nowarn = 0; }
 ;
 
 select_makeoptions:
@@ -760,7 +766,7 @@ select_makeoptions:
 ;
 
 select_no_options:
-	NO OPTIONS no_opt_list
+	no OPTIONS { nowarn = $1; } no_opt_list { nowarn = 0; }
 ;
 
 select_options:
@@ -776,7 +782,7 @@ select_ident:
 ;
 
 select_no_ident:
-	NO IDENT			{ setident(NULL); }
+	no IDENT			{ setident(NULL); }
 ;
 
 select_config:
@@ -785,11 +791,11 @@ select_config:
 ;
 
 select_no_config:
-	NO CONFIG WORD			{ delconf($3); }
+	no CONFIG WORD			{ delconf($3, $1); }
 ;
 
 select_no_pseudodev:
-	NO PSEUDO_DEVICE WORD		{ delpseudo($3); }
+	no PSEUDO_DEVICE WORD		{ delpseudo($3, $1); }
 ;
 
 select_pseudodev:
@@ -801,16 +807,16 @@ select_pseudoroot:
 ;
 
 select_no_device_instance_attachment:
-	NO device_instance AT attachment
-	{ deldevi($2, $4); }
+	no device_instance AT attachment
+	{ deldevi($2, $4, $1); }
 ;
 
 select_no_device_attachment:
-	NO DEVICE AT attachment		{ deldeva($4); }
+	no DEVICE AT attachment		{ deldeva($4, $1); }
 ;
 
 select_no_device_instance:
-	NO device_instance		{ deldev($2); }
+	no device_instance		{ deldev($2, $1); }
 ;
 
 select_device_instance:
@@ -837,7 +843,7 @@ no_fs_list:
 
 /* one filesystem that 

CVS commit: src/usr.bin/config

2016-08-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug  7 10:37:24 UTC 2016

Modified Files:
src/usr.bin/config: defs.h gram.y main.c scan.l sem.c sem.h

Log Message:
Accept "-no" as a "no" that does not cause errors if the object deleted
does not exist.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/config/defs.h
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/config/gram.y
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/config/main.c
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/config/scan.l
cvs rdiff -u -r1.74 -r1.75 src/usr.bin/config/sem.c
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/config/sem.h

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



CVS commit: src/usr.bin/config

2016-07-19 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Jul 19 17:01:04 UTC 2016

Modified Files:
src/usr.bin/config: config.5

Log Message:
Don't reference older CFATTACH_DECL


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/config/config.5

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



CVS commit: src/usr.bin/config

2016-07-19 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Jul 19 17:01:04 UTC 2016

Modified Files:
src/usr.bin/config: config.5

Log Message:
Don't reference older CFATTACH_DECL


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/config/config.5

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/config/config.5
diff -u src/usr.bin/config/config.5:1.36 src/usr.bin/config/config.5:1.37
--- src/usr.bin/config/config.5:1.36	Mon May  2 09:33:15 2016
+++ src/usr.bin/config/config.5	Tue Jul 19 17:01:04 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.36 2016/05/02 09:33:15 wiz Exp $
+.\" $NetBSD: config.5,v 1.37 2016/07/19 17:01:04 maya Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  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 April 29, 2016
+.Dd July 19, 2016
 .Dt CONFIG 5
 .Os
 .Sh NAME
@@ -437,7 +437,7 @@ will add the matching
 statement to
 .Pa ioconf.c .
 However, it is the responsibility of the developer to add the relevant
-.Fn CFATTACH_DECL
+.Fn CFATTACH_DECL_NEW
 line to the source of the device's driver.
 .It Ic attach Ar base Ic at Ar attr Oo , Ar attr Oo , Ar ... Oc Oc Oo Ic with \
 Ar name Oc Oo : dependencies Oc



CVS commit: src/usr.bin/config

2016-07-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jul 16 07:13:26 UTC 2016

Modified Files:
src/usr.bin/config: mkdevsw.c

Log Message:
Only emit bdevsw externs for entries in the bdev table, rather than for
entries in the cdev table.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/config/mkdevsw.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/config/mkdevsw.c
diff -u src/usr.bin/config/mkdevsw.c:1.14 src/usr.bin/config/mkdevsw.c:1.15
--- src/usr.bin/config/mkdevsw.c:1.14	Thu Sep  3 13:53:36 2015
+++ src/usr.bin/config/mkdevsw.c	Sat Jul 16 07:13:26 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkdevsw.c,v 1.14 2015/09/03 13:53:36 uebayasi Exp $	*/
+/*	$NetBSD: mkdevsw.c,v 1.15 2016/07/16 07:13:26 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: mkdevsw.c,v 1.14 2015/09/03 13:53:36 uebayasi Exp $");
+__RCSID("$NetBSD: mkdevsw.c,v 1.15 2016/07/16 07:13:26 pgoyette Exp $");
 
 #include 
 #include 
@@ -131,7 +131,7 @@ emitdevm(FILE *fp)
 	fputs("\n/* device switch table for block device */\n", fp);
 
 	for (i = 0; i <= maxbdevm ; i++)
-		dentry(fp, cdevmtab, i, 'b');
+		dentry(fp, bdevmtab, i, 'b');
 
 	fputs("\nconst struct bdevsw *bdevsw0[] = {\n", fp);
 



CVS commit: src/usr.bin/config

2016-07-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jul 16 07:13:26 UTC 2016

Modified Files:
src/usr.bin/config: mkdevsw.c

Log Message:
Only emit bdevsw externs for entries in the bdev table, rather than for
entries in the cdev table.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/config/mkdevsw.c

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



CVS commit: src/usr.bin/config

2016-05-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon May  2 09:33:15 UTC 2016

Modified Files:
src/usr.bin/config: config.5

Log Message:
New sentence, new line. Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/config/config.5

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/config/config.5
diff -u src/usr.bin/config/config.5:1.35 src/usr.bin/config/config.5:1.36
--- src/usr.bin/config/config.5:1.35	Fri Apr 29 18:18:22 2016
+++ src/usr.bin/config/config.5	Mon May  2 09:33:15 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.35 2016/04/29 18:18:22 mlelstv Exp $
+.\" $NetBSD: config.5,v 1.36 2016/05/02 09:33:15 wiz Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  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 September 1, 2015
+.Dd April 29, 2016
 .Dt CONFIG 5
 .Os
 .Sh NAME
@@ -666,7 +666,9 @@ The
 .Ar device
 can also be specified as a quoted specification string.
 The kernel interprets this string like the console input
-when prompting for a root device. E.g. "wedge:NAME"
+when prompting for a root device.
+E.g.,
+.Dq wedge:NAME
 specifies a named disk wedge.
 .Pp
 At least one



CVS commit: src/usr.bin/config

2016-05-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon May  2 09:33:15 UTC 2016

Modified Files:
src/usr.bin/config: config.5

Log Message:
New sentence, new line. Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/config/config.5

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



CVS commit: src/usr.bin/config

2016-04-29 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Apr 29 18:18:22 UTC 2016

Modified Files:
src/usr.bin/config: config.5 gram.y sem.c

Log Message:
Extend syntax of config phrase, a quoted string instead of a device name
is passed as root specification string. This can be used to specify a
wedge by name.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/config/config.5
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/config/gram.y
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/config/sem.c

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



CVS commit: src/usr.bin/config

2016-04-29 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Apr 29 18:18:22 UTC 2016

Modified Files:
src/usr.bin/config: config.5 gram.y sem.c

Log Message:
Extend syntax of config phrase, a quoted string instead of a device name
is passed as root specification string. This can be used to specify a
wedge by name.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/config/config.5
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/config/gram.y
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/config/sem.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/config/config.5
diff -u src/usr.bin/config/config.5:1.34 src/usr.bin/config/config.5:1.35
--- src/usr.bin/config/config.5:1.34	Tue Sep  1 13:42:48 2015
+++ src/usr.bin/config/config.5	Fri Apr 29 18:18:22 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.34 2015/09/01 13:42:48 uebayasi Exp $
+.\" $NetBSD: config.5,v 1.35 2016/04/29 18:18:22 mlelstv Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  All rights reserved.
@@ -662,6 +662,12 @@ and
 parameters can be wildcarded with
 .Dq \&?
 to let the kernel automatically discover those values.
+The
+.Ar device
+can also be specified as a quoted specification string.
+The kernel interprets this string like the console input
+when prompting for a root device. E.g. "wedge:NAME"
+specifies a named disk wedge.
 .Pp
 At least one
 .Ic config

Index: src/usr.bin/config/gram.y
diff -u src/usr.bin/config/gram.y:1.52 src/usr.bin/config/gram.y:1.53
--- src/usr.bin/config/gram.y:1.52	Tue Sep  1 13:42:48 2015
+++ src/usr.bin/config/gram.y	Fri Apr 29 18:18:22 2016
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: gram.y,v 1.52 2015/09/01 13:42:48 uebayasi Exp $	*/
+/*	$NetBSD: gram.y,v 1.53 2016/04/29 18:18:22 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: gram.y,v 1.52 2015/09/01 13:42:48 uebayasi Exp $");
+__RCSID("$NetBSD: gram.y,v 1.53 2016/04/29 18:18:22 mlelstv Exp $");
 
 #include 
 #include 
@@ -103,6 +103,7 @@ DECL_ALLOCWRAP(condexpr);
 #define	new_nx(n, x)	new0(n, NULL, NULL, 0, x)
 #define	new_ns(n, s)	new0(n, s, NULL, 0, NULL)
 #define	new_si(s, i)	new0(NULL, s, NULL, i, NULL)
+#define	new_spi(s, p, i)	new0(NULL, s, p, i, NULL)
 #define	new_nsi(n,s,i)	new0(n, s, NULL, i, NULL)
 #define	new_np(n, p)	new0(n, NULL, p, 0, NULL)
 #define	new_s(s)	new0(NULL, s, NULL, 0, NULL)
@@ -906,9 +907,14 @@ root_spec:
 
 /* device for root fs or dump */
 dev_spec:
-	  '?'{ $$ = new_si(intern("?"),
+	  '?'{ $$ = new_spi(intern("?"),
+	NULL,
 	(long long)NODEV); }
-	| WORD{ $$ = new_si($1,
+	| QSTRING			{ $$ = new_spi($1,
+	__UNCONST("spec"),
+	(long long)NODEV); }
+	| WORD{ $$ = new_spi($1,
+	NULL,
 	(long long)NODEV); }
 	| major_minor			{ $$ = new_si(NULL, $1); }
 ;

Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.73 src/usr.bin/config/sem.c:1.74
--- src/usr.bin/config/sem.c:1.73	Sat Aug 29 07:24:49 2015
+++ src/usr.bin/config/sem.c	Fri Apr 29 18:18:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.73 2015/08/29 07:24:49 uebayasi Exp $	*/
+/*	$NetBSD: sem.c,v 1.74 2016/04/29 18:18:22 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: sem.c,v 1.73 2015/08/29 07:24:49 uebayasi Exp $");
+__RCSID("$NetBSD: sem.c,v 1.74 2016/04/29 18:18:22 mlelstv Exp $");
 
 #include 
 #include 
@@ -928,6 +928,12 @@ resolve(struct nvlist **nvp, const char 
 		 */
 		return (0);
 
+	if (nv->nv_ptr != NULL && strcmp(nv->nv_ptr, "spec") == 0)
+		/*
+		 * spec string, interpreted by kernel
+		 */
+		return (0);
+
 	/*
 	 * The normal case: things like "ra2b".  Check for partition
 	 * suffix, remove it if there, and split into name ("ra") and



CVS commit: src/usr.bin/config

2016-03-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Mar 18 15:05:49 UTC 2016

Modified Files:
src/usr.bin/config: defs.h

Log Message:
match the updated  definition


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/config/defs.h

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



CVS commit: src/usr.bin/config

2016-03-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Mar 18 15:05:49 UTC 2016

Modified Files:
src/usr.bin/config: defs.h

Log Message:
match the updated  definition


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/config/defs.h

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/config/defs.h
diff -u src/usr.bin/config/defs.h:1.94 src/usr.bin/config/defs.h:1.95
--- src/usr.bin/config/defs.h:1.94	Thu Nov 12 09:38:21 2015
+++ src/usr.bin/config/defs.h	Fri Mar 18 11:05:49 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.94 2015/11/12 14:38:21 pooka Exp $	*/
+/*	$NetBSD: defs.h,v 1.95 2016/03/18 15:05:49 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -89,9 +89,9 @@
 #define major(x)((devmajor_t)x) & 0x000fff00) >>  8)))
 #define minor(x)((devminor_t)x) & 0xfff0) >> 12) | \
 			   (((x) & 0x00ff) >>  0)))
-#define makedev(x,y)((dev_t)x) <<  8) & 0x000fff00) | \
- (((y) << 12) & 0xfff0) | \
- (((y) <<  0) & 0x00ff)))
+#define makedev(x,y)((dev_t)dev_t)(x) <<  8) & 0x000fff00U) | \
+ (((dev_t)(y) << 12) & 0xfff0U) | \
+ (((dev_t)(y) <<  0) & 0x00ffU)))
 #define __attribute__(x)
 #endif	/* MAKE_BOOTSTRAP */
 



CVS commit: src/usr.bin/config

2015-11-21 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Sun Nov 22 01:20:36 UTC 2015

Modified Files:
src/usr.bin/config: TODO

Log Message:
A few more.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/config/TODO

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



  1   2   3   4   5   6   >