rename nv_int -> nv_num and make it long long, so that dev_t will fit when

we change it.
This commit is contained in:
christos 2008-12-28 01:23:46 +00:00
parent 074ef1779e
commit 0001b92828
10 changed files with 64 additions and 61 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.25 2008/12/21 11:39:56 martin Exp $ */ /* $NetBSD: defs.h,v 1.26 2008/12/28 01:23:46 christos Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -110,7 +110,7 @@ struct nvlist {
const char *nv_name; const char *nv_name;
const char *nv_str; const char *nv_str;
void *nv_ptr; void *nv_ptr;
int nv_int; long long nv_num;
int nv_ifunit; /* XXX XXX XXX */ int nv_ifunit; /* XXX XXX XXX */
int nv_flags; int nv_flags;
#define NV_DEPENDED 1 #define NV_DEPENDED 1
@ -200,7 +200,7 @@ struct devbase {
TAILQ_ENTRY(devbase) d_next; TAILQ_ENTRY(devbase) d_next;
int d_isdef; /* set once properly defined */ int d_isdef; /* set once properly defined */
int d_ispseudo; /* is a pseudo-device */ int d_ispseudo; /* is a pseudo-device */
int d_major; /* used for "root on sd0", e.g. */ dev_t d_major; /* used for "root on sd0", e.g. */
struct nvlist *d_attrs; /* attributes, if any */ struct nvlist *d_attrs; /* attributes, if any */
int d_umax; /* highest unit number + 1 */ int d_umax; /* highest unit number + 1 */
struct devi *d_ihead; /* first instance, if any */ struct devi *d_ihead; /* first instance, if any */
@ -287,12 +287,12 @@ struct filetype
* depending on whether it has names on which to *be* optional. The * depending on whether it has names on which to *be* optional. The
* options field (fi_optx) is actually an expression tree, with nodes * options field (fi_optx) is actually an expression tree, with nodes
* for OR, AND, and NOT, as well as atoms (words) representing some * for OR, AND, and NOT, as well as atoms (words) representing some
* particular option. The node type is stored in the nv_int field. * particular option. The node type is stored in the nv_num field.
* Subexpressions appear in the `next' field; for the binary operators * Subexpressions appear in the `next' field; for the binary operators
* AND and OR, the left subexpression is first stored in the nv_ptr field. * AND and OR, the left subexpression is first stored in the nv_ptr field.
* *
* For any file marked as needs-count or needs-flag, fixfiles() will * For any file marked as needs-count or needs-flag, fixfiles() will
* build fi_optf, a `flat list' of the options with nv_int fields that * build fi_optf, a `flat list' of the options with nv_num fields that
* contain counts or `need' flags; this is used in mkheaders(). * contain counts or `need' flags; this is used in mkheaders().
*/ */
struct files { struct files {
@ -551,7 +551,7 @@ void cfgxerror(const char *, int, const char *, ...) /* delayed errs */
__attribute__((__format__(__printf__, 3, 4))); __attribute__((__format__(__printf__, 3, 4)));
__dead void panic(const char *, ...) __dead void panic(const char *, ...)
__attribute__((__format__(__printf__, 1, 2))); __attribute__((__format__(__printf__, 1, 2)));
struct nvlist *newnv(const char *, const char *, void *, int, struct nvlist *); struct nvlist *newnv(const char *, const char *, void *, long long, struct nvlist *);
void nvfree(struct nvlist *); void nvfree(struct nvlist *);
void nvfreel(struct nvlist *); void nvfreel(struct nvlist *);
struct nvlist *nvcat(struct nvlist *, struct nvlist *); struct nvlist *nvcat(struct nvlist *, struct nvlist *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: files.c,v 1.7 2007/11/30 23:19:18 dsl Exp $ */ /* $NetBSD: files.c,v 1.8 2008/12/28 01:23:46 christos Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -501,7 +501,7 @@ expr_eval(struct nvlist *expr, int (*fn)(const char *, void *), void *context)
{ {
int lhs, rhs; int lhs, rhs;
switch (expr->nv_int) { switch (expr->nv_num) {
case FX_ATOM: case FX_ATOM:
return ((*fn)(expr->nv_name, context)); return ((*fn)(expr->nv_name, context));
@ -519,7 +519,7 @@ expr_eval(struct nvlist *expr, int (*fn)(const char *, void *), void *context)
rhs = expr_eval(expr->nv_next, fn, context); rhs = expr_eval(expr->nv_next, fn, context);
return (lhs | rhs); return (lhs | rhs);
} }
panic("expr_eval %d", expr->nv_int); panic("expr_eval %lld", expr->nv_num);
/* NOTREACHED */ /* NOTREACHED */
return (0); return (0);
} }
@ -534,7 +534,7 @@ expr_free(struct nvlist *expr)
/* This loop traverses down the RHS of each subexpression. */ /* This loop traverses down the RHS of each subexpression. */
for (; expr != NULL; expr = rhs) { for (; expr != NULL; expr = rhs) {
switch (expr->nv_int) { switch (expr->nv_num) {
/* Atoms and !-exprs have no left hand side. */ /* Atoms and !-exprs have no left hand side. */
case FX_ATOM: case FX_ATOM:
@ -548,7 +548,7 @@ expr_free(struct nvlist *expr)
break; break;
default: default:
panic("expr_free %d", expr->nv_int); panic("expr_free %lld", expr->nv_num);
} }
rhs = expr->nv_next; rhs = expr->nv_next;
nvfree(expr); nvfree(expr);
@ -574,7 +574,7 @@ static void
pr0(struct nvlist *e) pr0(struct nvlist *e)
{ {
switch (e->nv_int) { switch (e->nv_num) {
case FX_ATOM: case FX_ATOM:
printf(" %s", e->nv_name); printf(" %s", e->nv_name);
return; return;
@ -588,7 +588,7 @@ pr0(struct nvlist *e)
printf(" (|"); printf(" (|");
break; break;
default: default:
printf(" (?%d?", e->nv_int); printf(" (?%lld?", e->nv_num);
break; break;
} }
if (e->nv_ptr) if (e->nv_ptr)

View File

@ -1,5 +1,5 @@
%{ %{
/* $NetBSD: gram.y,v 1.17 2008/06/10 18:11:31 drochner Exp $ */ /* $NetBSD: gram.y,v 1.18 2008/12/28 01:23:46 christos Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -725,7 +725,7 @@ mk_nsis(const char *name, int count, struct nvlist *adefs, int opt)
*p = new_s("0"); *p = new_s("0");
snprintf(buf, sizeof(buf), "%s%c%d", name, ARRCHR, i); snprintf(buf, sizeof(buf), "%s%c%d", name, ARRCHR, i);
(*p)->nv_name = i == 0 ? name : intern(buf); (*p)->nv_name = i == 0 ? name : intern(buf);
(*p)->nv_int = i > 0 || opt; (*p)->nv_num = i > 0 || opt;
p = &(*p)->nv_next; p = &(*p)->nv_next;
} }
*p = 0; *p = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lint.c,v 1.6 2008/04/29 06:53:03 martin Exp $ */ /* $NetBSD: lint.c,v 1.7 2008/12/28 01:23:46 christos Exp $ */
/* /*
* Copyright (c) 2007 The NetBSD Foundation. * Copyright (c) 2007 The NetBSD Foundation.
@ -130,7 +130,7 @@ do_emit_instances(struct devbase *d, struct attr *at)
printf("%s0\tat\t%s?", d->d_name, at->a_name); printf("%s0\tat\t%s?", d->d_name, at->a_name);
for (nv = at->a_locs; nv != NULL; nv = nv->nv_next) { for (nv = at->a_locs; nv != NULL; nv = nv->nv_next) {
if (nv->nv_int == 0) if (nv->nv_num == 0)
printf(" %s %c", nv->nv_name, printf(" %s %c", nv->nv_name,
nv->nv_str ? '?' : '0'); nv->nv_str ? '?' : '0');
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.32 2008/10/20 11:02:18 ad Exp $ */ /* $NetBSD: main.c,v 1.33 2008/12/28 01:23:46 christos Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -1086,7 +1086,7 @@ cfcrosscheck(struct config *cf, const char *what, struct nvlist *nv)
if (has_attr(dev->d_attrs, s_ifnet)) if (has_attr(dev->d_attrs, s_ifnet))
devunit = nv->nv_ifunit; /* XXX XXX XXX */ devunit = nv->nv_ifunit; /* XXX XXX XXX */
else else
devunit = minor((uint32_t)nv->nv_int) / maxpartitions; devunit = (int)(minor(nv->nv_num) / maxpartitions);
if (devbase_has_instances(dev, devunit)) if (devbase_has_instances(dev, devunit))
continue; continue;
if (devbase_has_instances(dev, STAR) && if (devbase_has_instances(dev, STAR) &&

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkheaders.c,v 1.13 2007/11/09 05:21:30 cube Exp $ */ /* $NetBSD: mkheaders.c,v 1.14 2008/12/28 01:23:46 christos Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -102,7 +102,7 @@ mkheaders(void)
} }
static void static void
fprint_global(FILE *fp, const char *name, unsigned int value) fprint_global(FILE *fp, const char *name, long long value)
{ {
/* /*
* We have to doubt the founding fathers here. * We have to doubt the founding fathers here.
@ -116,12 +116,12 @@ fprint_global(FILE *fp, const char *name, unsigned int value)
fprintf(fp, "#ifdef _LOCORE\n" fprintf(fp, "#ifdef _LOCORE\n"
" .ifndef _KERNEL_OPT_%s\n" " .ifndef _KERNEL_OPT_%s\n"
" .global _KERNEL_OPT_%s\n" " .global _KERNEL_OPT_%s\n"
" .equiv _KERNEL_OPT_%s,0x%x\n" " .equiv _KERNEL_OPT_%s,0x%llx\n"
" .endif\n" " .endif\n"
"#else\n" "#else\n"
"__asm(\" .ifndef _KERNEL_OPT_%s\\n" "__asm(\" .ifndef _KERNEL_OPT_%s\\n"
" .global _KERNEL_OPT_%s\\n" " .global _KERNEL_OPT_%s\\n"
" .equiv _KERNEL_OPT_%s,0x%x\\n" " .equiv _KERNEL_OPT_%s,0x%llx\\n"
" .endif\");\n" " .endif\");\n"
"#endif\n", "#endif\n",
name, name, name, value, name, name, name, value,
@ -151,8 +151,8 @@ fprintcnt(FILE *fp, struct nvlist *nv)
{ {
const char *name = cntname(nv->nv_name); const char *name = cntname(nv->nv_name);
fprintf(fp, "#define\t%s\t%d\n", name, nv->nv_int); fprintf(fp, "#define\t%s\t%lld\n", name, nv->nv_num);
fprint_global(fp, name, nv->nv_int); fprint_global(fp, name, nv->nv_num);
} }
static int static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkioconf.c,v 1.10 2007/12/12 00:03:33 lukem Exp $ */ /* $NetBSD: mkioconf.c,v 1.11 2008/12/28 01:23:46 christos Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -489,8 +489,8 @@ emitname2blk(FILE *fp)
if (dev->d_major == NODEV) if (dev->d_major == NODEV)
continue; continue;
fprintf(fp, "\t{ \"%s\", %d },\n", fprintf(fp, "\t{ \"%s\", %lld },\n",
dev->d_name, dev->d_major); dev->d_name, (long long)dev->d_major);
} }
fprintf(fp, "\t{ NULL, 0 }\n};\n"); fprintf(fp, "\t{ NULL, 0 }\n};\n");
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkswap.c,v 1.5 2008/12/19 17:11:57 pgoyette Exp $ */ /* $NetBSD: mkswap.c,v 1.6 2008/12/28 01:23:46 christos Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -79,8 +79,8 @@ mkdevstr(dev_t d)
if (d == NODEV) if (d == NODEV)
(void)snprintf(buf, sizeof(buf), "NODEV"); (void)snprintf(buf, sizeof(buf), "NODEV");
else else
(void)snprintf(buf, sizeof(buf), "makedev(%d, %d)", (void)snprintf(buf, sizeof(buf), "makedev(%" PRIi64 ", %"
major(d), minor(d)); PRIi64 ")", (int64_t)major(d), (int64_t)minor(d));
return buf; return buf;
} }
@ -114,7 +114,7 @@ mkoneswap(struct config *cf)
cf->cf_root->nv_str); cf->cf_root->nv_str);
fprintf(fp, "const char *rootspec = %s;\n", specinfo); fprintf(fp, "const char *rootspec = %s;\n", specinfo);
fprintf(fp, "dev_t\trootdev = %s;\t/* %s */\n\n", fprintf(fp, "dev_t\trootdev = %s;\t/* %s */\n\n",
mkdevstr(nv->nv_int), mkdevstr(nv->nv_num),
nv->nv_str == s_qmark ? "wildcarded" : nv->nv_str); nv->nv_str == s_qmark ? "wildcarded" : nv->nv_str);
/* /*
@ -127,7 +127,7 @@ mkoneswap(struct config *cf)
snprintf(specinfo, sizeof(specinfo), "\"%s\"", cf->cf_dump->nv_str); snprintf(specinfo, sizeof(specinfo), "\"%s\"", cf->cf_dump->nv_str);
fprintf(fp, "const char *dumpspec = %s;\n", specinfo); fprintf(fp, "const char *dumpspec = %s;\n", specinfo);
fprintf(fp, "dev_t\tdumpdev = %s;\t/* %s */\n\n", fprintf(fp, "dev_t\tdumpdev = %s;\t/* %s */\n\n",
nv ? mkdevstr(nv->nv_int) : "NODEV", nv ? mkdevstr(nv->nv_num) : "NODEV",
nv ? nv->nv_str : "unspecified"); nv ? nv->nv_str : "unspecified");
/* /*

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.c,v 1.30 2008/07/07 16:10:27 cube Exp $ */ /* $NetBSD: sem.c,v 1.31 2008/12/28 01:23:46 christos Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -83,9 +83,9 @@ static char *extend(char *, const char *);
static int split(const char *, size_t, char *, size_t, int *); static int split(const char *, size_t, char *, size_t, int *);
static void selectbase(struct devbase *, struct deva *); static void selectbase(struct devbase *, struct deva *);
static const char **fixloc(const char *, struct attr *, struct nvlist *); static const char **fixloc(const char *, struct attr *, struct nvlist *);
static const char *makedevstr(int, int); static const char *makedevstr(dev_t, dev_t);
static const char *major2name(int); static const char *major2name(int);
static int dev2major(struct devbase *); static dev_t dev2major(struct devbase *);
extern const char *yyfile; extern const char *yyfile;
extern int vflag; extern int vflag;
@ -635,8 +635,8 @@ setmajor(struct devbase *d, int n)
{ {
if (d != &errdev && d->d_major != NODEV) if (d != &errdev && d->d_major != NODEV)
cfgerror("device `%s' is already major %d", cfgerror("device `%s' is already major %lld",
d->d_name, d->d_major); d->d_name, (long long)d->d_major);
else else
d->d_major = n; d->d_major = n;
} }
@ -661,7 +661,7 @@ major2name(int maj)
return (NULL); return (NULL);
} }
int dev_t
dev2major(struct devbase *dev) dev2major(struct devbase *dev)
{ {
struct devm *dm; struct devm *dm;
@ -680,17 +680,19 @@ dev2major(struct devbase *dev)
* Make a string description of the device at maj/min. * Make a string description of the device at maj/min.
*/ */
static const char * static const char *
makedevstr(int maj, int min) makedevstr(dev_t maj, dev_t min)
{ {
const char *devicename; const char *devicename;
char buf[32]; char buf[32];
devicename = major2name(maj); devicename = major2name(maj);
if (devicename == NULL) if (devicename == NULL)
(void)snprintf(buf, sizeof(buf), "<%d/%d>", maj, min); (void)snprintf(buf, sizeof(buf), "<%lld/%lld>",
(long long)maj, (long long)min);
else else
(void)snprintf(buf, sizeof(buf), "%s%d%c", devicename, (void)snprintf(buf, sizeof(buf), "%s%lld%c", devicename,
min / maxpartitions, (min % maxpartitions) + 'a'); (long long)min / maxpartitions,
(char)(min % maxpartitions) + 'a');
return (intern(buf)); return (intern(buf));
} }
@ -707,7 +709,8 @@ resolve(struct nvlist **nvp, const char *name, const char *what,
struct nvlist *nv; struct nvlist *nv;
struct devbase *dev; struct devbase *dev;
const char *cp; const char *cp;
int maj, min, i, l; dev_t maj, min;
int i, l;
int unit; int unit;
char buf[NAMESIZE]; char buf[NAMESIZE];
@ -719,9 +722,9 @@ resolve(struct nvlist **nvp, const char *name, const char *what,
* Apply default. Easiest to do this by number. * Apply default. Easiest to do this by number.
* Make sure to retain NODEVness, if this is dflt's disposition. * Make sure to retain NODEVness, if this is dflt's disposition.
*/ */
if (dflt->nv_int != NODEV) { if (dflt->nv_num != NODEV) {
maj = major(dflt->nv_int); maj = major(dflt->nv_num);
min = ((minor(dflt->nv_int) / maxpartitions) * min = ((minor(dflt->nv_num) / maxpartitions) *
maxpartitions) + part; maxpartitions) + part;
d = makedev(maj, min); d = makedev(maj, min);
cp = makedevstr(maj, min); cp = makedevstr(maj, min);
@ -729,13 +732,13 @@ resolve(struct nvlist **nvp, const char *name, const char *what,
cp = NULL; cp = NULL;
*nvp = nv = newnv(NULL, cp, NULL, d, NULL); *nvp = nv = newnv(NULL, cp, NULL, d, NULL);
} }
if (nv->nv_int != NODEV) { if (nv->nv_num != NODEV) {
/* /*
* By the numbers. Find the appropriate major number * By the numbers. Find the appropriate major number
* to make a name. * to make a name.
*/ */
maj = major(nv->nv_int); maj = major(nv->nv_num);
min = minor(nv->nv_int); min = minor(nv->nv_num);
nv->nv_str = makedevstr(maj, min); nv->nv_str = makedevstr(maj, min);
return (0); return (0);
} }
@ -774,7 +777,7 @@ resolve(struct nvlist **nvp, const char *name, const char *what,
* don't bother making a device number. * don't bother making a device number.
*/ */
if (has_attr(dev->d_attrs, s_ifnet)) { if (has_attr(dev->d_attrs, s_ifnet)) {
nv->nv_int = NODEV; nv->nv_num = NODEV;
nv->nv_ifunit = unit; /* XXX XXX XXX */ nv->nv_ifunit = unit; /* XXX XXX XXX */
} else { } else {
maj = dev2major(dev); maj = dev2major(dev);
@ -783,7 +786,7 @@ resolve(struct nvlist **nvp, const char *name, const char *what,
name, what, nv->nv_str); name, what, nv->nv_str);
return (1); return (1);
} }
nv->nv_int = makedev(maj, unit * maxpartitions + part); nv->nv_num = makedev(maj, unit * maxpartitions + part);
} }
nv->nv_name = dev->d_name; nv->nv_name = dev->d_name;
@ -1744,18 +1747,18 @@ fixloc(const char *name, struct attr *attr, struct nvlist *got)
else else
lp = emalloc((attr->a_loclen + 1) * sizeof(const char *)); lp = emalloc((attr->a_loclen + 1) * sizeof(const char *));
for (n = got; n != NULL; n = n->nv_next) for (n = got; n != NULL; n = n->nv_next)
n->nv_int = -1; n->nv_num = -1;
nmissing = 0; nmissing = 0;
mp = missing; mp = missing;
/* yes, this is O(mn), but m and n should be small */ /* yes, this is O(mn), but m and n should be small */
for (ord = 0, m = attr->a_locs; m != NULL; m = m->nv_next, ord++) { for (ord = 0, m = attr->a_locs; m != NULL; m = m->nv_next, ord++) {
for (n = got; n != NULL; n = n->nv_next) { for (n = got; n != NULL; n = n->nv_next) {
if (n->nv_name == m->nv_name) { if (n->nv_name == m->nv_name) {
n->nv_int = ord; n->nv_num = ord;
break; break;
} }
} }
if (n == NULL && m->nv_int == 0) { if (n == NULL && m->nv_num == 0) {
nmissing++; nmissing++;
mp = extend(mp, m->nv_name); mp = extend(mp, m->nv_name);
} }
@ -1769,10 +1772,10 @@ fixloc(const char *name, struct attr *attr, struct nvlist *got)
nnodefault = 0; nnodefault = 0;
ndp = nodefault; ndp = nodefault;
for (n = got; n != NULL; n = n->nv_next) { for (n = got; n != NULL; n = n->nv_next) {
if (n->nv_int >= 0) { if (n->nv_num >= 0) {
if (n->nv_str != NULL) if (n->nv_str != NULL)
lp[n->nv_int] = n->nv_str; lp[n->nv_num] = n->nv_str;
else if (lp[n->nv_int] == NULL) { else if (lp[n->nv_num] == NULL) {
nnodefault++; nnodefault++;
ndp = extend(ndp, n->nv_name); ndp = extend(ndp, n->nv_name);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.7 2007/12/12 00:03:34 lukem Exp $ */ /* $NetBSD: util.c,v 1.8 2008/12/28 01:23:46 christos Exp $ */
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -136,7 +136,7 @@ sourcepath(const char *file)
} }
struct nvlist * struct nvlist *
newnv(const char *name, const char *str, void *ptr, int i, struct nvlist *next) newnv(const char *name, const char *str, void *ptr, long long i, struct nvlist *next)
{ {
struct nvlist *nv; struct nvlist *nv;
@ -145,7 +145,7 @@ newnv(const char *name, const char *str, void *ptr, int i, struct nvlist *next)
nv->nv_name = name; nv->nv_name = name;
nv->nv_str = str; nv->nv_str = str;
nv->nv_ptr = ptr; nv->nv_ptr = ptr;
nv->nv_int = i; nv->nv_num = i;
return nv; return nv;
} }