Module Name: src
Committed By: uebayasi
Date: Sat Oct 18 06:36:40 UTC 2014
Modified Files:
src/usr.bin/config: defs.h main.c sem.c sem.h
Log Message:
Keep track of attribute (module) dependency using hash2.
To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/config/defs.h
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/config/main.c
cvs rdiff -u -r1.63 -r1.64 src/usr.bin/config/sem.c
cvs rdiff -u -r1.14 -r1.15 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.57 src/usr.bin/config/defs.h:1.58
--- src/usr.bin/config/defs.h:1.57 Sun Oct 12 05:20:54 2014
+++ src/usr.bin/config/defs.h Sat Oct 18 06:36:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.57 2014/10/12 05:20:54 uebayasi Exp $ */
+/* $NetBSD: defs.h,v 1.58 2014/10/18 06:36:40 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -483,6 +483,7 @@ struct dlhash *defoptlint; /* lint value
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 */
Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.68 src/usr.bin/config/main.c:1.69
--- src/usr.bin/config/main.c:1.68 Tue Oct 14 08:00:27 2014
+++ src/usr.bin/config/main.c Sat Oct 18 06:36:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.68 2014/10/14 08:00:27 uebayasi Exp $ */
+/* $NetBSD: main.c,v 1.69 2014/10/18 06:36:40 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -439,6 +439,9 @@ main(int argc, char **argv)
return 0;
}
+ yyfile = "dependattrs";
+ dependattrs();
+
/*
* Deal with option dependencies.
*/
Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.63 src/usr.bin/config/sem.c:1.64
--- src/usr.bin/config/sem.c:1.63 Sun Oct 12 15:35:40 2014
+++ src/usr.bin/config/sem.c Sat Oct 18 06:36:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.c,v 1.63 2014/10/12 15:35:40 uebayasi Exp $ */
+/* $NetBSD: sem.c,v 1.64 2014/10/18 06:36:40 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -96,6 +96,7 @@ initsem(void)
{
attrtab = ht_new();
+ attrdeptab = ht_new();
allattr.a_name = "netbsd";
TAILQ_INIT(&allattr.a_files);
@@ -303,6 +304,7 @@ defattr(const char *name, struct loclist
"attribute", name, dep->a_name);
return (1);
}
+ (void)ht_insert2(attrdeptab, name, dep->a_name, NULL);
CFGDBG(2, "attr `%s' depends on attr `%s'", name, dep->a_name);
}
@@ -530,6 +532,7 @@ 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);
CFGDBG(2, "device `%s' depends on attr `%s'", dev->d_name,
al->al_this->a_name);
}
@@ -1947,6 +1950,21 @@ selectattr(struct attr *a)
CFGDBG(3, "attr selected `%s'", a->a_name);
}
+static int
+dumpattrdepcb2(const char *name1, const char *name2, void *v, void *arg)
+{
+
+ CFGDBG(3, "attr `%s' depends on attr `%s'", name1, name2);
+ return 0;
+}
+
+void
+dependattrs(void)
+{
+
+ ht_enumerate2(attrdeptab, dumpattrdepcb2, NULL);
+}
+
/*
* We have an instance of the base foo, so select it and all its
* attributes for "optional foo".
@@ -1959,6 +1977,7 @@ selectbase(struct devbase *d, struct dev
(void)ht_insert(selecttab, d->d_name, __UNCONST(d->d_name));
CFGDBG(3, "devbase selected `%s'", d->d_name);
+ CFGDBG(5, "selecting dependencies of devbase `%s'", d->d_name);
for (al = d->d_attrs; al != NULL; al = al->al_next) {
a = al->al_this;
expandattr(a, selectattr);
Index: src/usr.bin/config/sem.h
diff -u src/usr.bin/config/sem.h:1.14 src/usr.bin/config/sem.h:1.15
--- src/usr.bin/config/sem.h:1.14 Fri Oct 10 11:09:50 2014
+++ src/usr.bin/config/sem.h Sat Oct 18 06:36:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.h,v 1.14 2014/10/10 11:09:50 uebayasi Exp $ */
+/* $NetBSD: sem.h,v 1.15 2014/10/18 06:36:40 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -61,6 +61,7 @@ struct attr *refattr(const char *);
int getrefattr(const char *, struct attr **);
void expandattr(struct attr *, void (*)(struct attr *));
void selectattr(struct attr *);
+void dependattrs(void);
void setmajor(struct devbase *, int);
void addconf(struct config *);
void setconf(struct nvlist **, const char *, struct nvlist *);