diff options
author | Peter Wemm <peter@FreeBSD.org> | 2001-01-19 12:49:21 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2001-01-19 12:49:21 +0000 |
commit | 10ca19cf93862f128cbd38abc7398f14cf09ef02 (patch) | |
tree | ac9826ca76aadbdfefa8d6a75c76f9dbe07d1a7e /usr.sbin | |
parent | bb9dcfee8e44523d0913141bdce434ea9e38d932 (diff) | |
download | src-10ca19cf93862f128cbd38abc7398f14cf09ef02.tar.gz src-10ca19cf93862f128cbd38abc7398f14cf09ef02.zip |
Implement option strings that we can use in #ifdefs (where unavoidable)
as a replacement for the evil #define NFOO. If 'device npx' is in the
static kernel, a synthetic option '#define DEV_NPX 1' will be available
to stick in an opt_xxx.h file. "#if NNPX > 0" can be replaced with
"#ifdef DEV_NPX" and we can get rid of the overloaded meaning of the
device count mechanism.
Notes
Notes:
svn path=/head/; revision=71251
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/config/config.y | 25 | ||||
-rw-r--r-- | usr.sbin/config/configvers.h | 2 | ||||
-rw-r--r-- | usr.sbin/config/mkoptions.c | 2 |
3 files changed, 27 insertions, 2 deletions
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index 4c9a448754ba..035452723410 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -86,6 +86,15 @@ int maxusers; static void yyerror(char *s); +static char * +devopt(char *dev) +{ + char *ret = malloc(strlen(dev) + 5); + + sprintf(ret, "DEV_%s", dev); + raisestr(ret); + return ret; +} %} %% @@ -260,12 +269,28 @@ Dev: Device_spec: DEVICE Dev = { + struct opt *op = (struct opt *)malloc(sizeof (struct opt)); + memset(op, 0, sizeof(*op)); + op->op_name = devopt($2); + op->op_next = opt; + op->op_value = ns("1"); + op->op_line = yyline; + opt = op; + /* and the device part */ cur.d_type = DEVICE; cur.d_name = $2; cur.d_count = UNKNOWN; } | DEVICE Dev NUMBER = { + struct opt *op = (struct opt *)malloc(sizeof (struct opt)); + memset(op, 0, sizeof(*op)); + op->op_name = devopt($2); + op->op_next = opt; + op->op_value = ns("1"); + op->op_line = yyline; + opt = op; + /* and the device part */ cur.d_type = DEVICE; cur.d_name = $2; cur.d_count = $3; diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h index a9a6faceee30..dde529064cc0 100644 --- a/usr.sbin/config/configvers.h +++ b/usr.sbin/config/configvers.h @@ -8,4 +8,4 @@ * * $FreeBSD$ */ -#define CONFIGVERS 500005 +#define CONFIGVERS 500006 diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c index 9496ca457aaa..4f9e2a15a602 100644 --- a/usr.sbin/config/mkoptions.c +++ b/usr.sbin/config/mkoptions.c @@ -115,7 +115,7 @@ options(void) for (ol = otab; ol != 0; ol = ol->o_next) do_option(ol->o_name); for (op = opt; op; op = op->op_next) { - if (!op->op_ownfile) { + if (!op->op_ownfile && strncmp(op->op_name, "DEV_", 4)) { printf("%s:%d: unknown option \"%s\"\n", PREFIX, op->op_line, op->op_name); exit(1); |