1 /*	$NetBSD: defs.h,v 1.95 2016/03/18 15:05:49 christos Exp $	*/
2 
3 /*
4  * Copyright (c) 1992, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This software was developed by the Computer Systems Engineering group
8  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9  * contributed to Berkeley.
10  *
11  * All advertising materials mentioning features or use of this software
12  * must display the following acknowledgement:
13  *	This product includes software developed by the University of
14  *	California, Lawrence Berkeley Laboratories.
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions
18  * are met:
19  * 1. Redistributions of source code must retain the above copyright
20  *    notice, this list of conditions and the following disclaimer.
21  * 2. Redistributions in binary form must reproduce the above copyright
22  *    notice, this list of conditions and the following disclaimer in the
23  *    documentation and/or other materials provided with the distribution.
24  * 3. Neither the name of the University nor the names of its contributors
25  *    may be used to endorse or promote products derived from this software
26  *    without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38  * SUCH DAMAGE.
39  *
40  *	from: @(#)config.h	8.1 (Berkeley) 6/6/93
41  */
42 
43 /*
44  * defs.h:  Global definitions for "config"
45  */
46 
47 #if HAVE_NBTOOL_CONFIG_H
48 #include "nbtool_config.h"
49 #endif
50 
51 #include <sys/types.h>
52 #include <sys/param.h>
53 #include <sys/queue.h>
54 
55 #if !defined(MAKE_BOOTSTRAP) && defined(BSD)
56 #include <sys/cdefs.h>
57 #include <paths.h>
58 #endif
59 
60 #include <stdio.h>
61 #include <stdlib.h>
62 #include <unistd.h>
63 
64 /* These are really for MAKE_BOOTSTRAP but harmless. */
65 #ifndef __dead
66 #define __dead
67 #endif
68 #ifndef __printflike
69 #define __printflike(a, b)
70 #endif
71 #ifndef _PATH_DEVNULL
72 #define _PATH_DEVNULL "/dev/null"
73 #endif
74 
75 #ifdef	MAKE_BOOTSTRAP
76 #undef	dev_t
77 #undef	devmajor_t
78 #undef	devminor_t
79 #undef	NODEV
80 #undef	NODEVMAJOR
81 #undef	major
82 #undef	minor
83 #undef	makedev
84 #define	dev_t		unsigned int	/* XXX: assumes int is 32 bits */
85 #define	NODEV		((dev_t)-1)
86 #define devmajor_t	int
87 #define devminor_t	int
88 #define NODEVMAJOR	(-1)
89 #define major(x)        ((devmajor_t)((((x) & 0x000fff00) >>  8)))
90 #define minor(x)        ((devminor_t)((((x) & 0xfff00000) >> 12) | \
91 			       (((x) & 0x000000ff) >>  0)))
92 #define makedev(x,y)    ((dev_t)((((dev_t)(x) <<  8) & 0x000fff00U) | \
93                                  (((dev_t)(y) << 12) & 0xfff00000U) | \
94                                  (((dev_t)(y) <<  0) & 0x000000ffU)))
95 #define __attribute__(x)
96 #endif	/* MAKE_BOOTSTRAP */
97 
98 #undef setprogname
99 #undef getprogname
100 extern const char *progname;
101 #define	setprogname(s)	((void)(progname = (s)))
102 #define	getprogname()	(progname)
103 
104 #define ARRCHR '#'
105 
106 /*
107  * The next two lines define the current version of the config(1) binary,
108  * and the minimum version of the configuration files it supports.
109  */
110 #define CONFIG_VERSION		20151112
111 #define CONFIG_MINVERSION	0
112 
113 /*
114  * Name/value lists.  Values can be strings or pointers and/or can carry
115  * integers.  The names can be NULL, resulting in simple value lists.
116  */
117 struct nvlist {
118 	struct nvlist	*nv_next;
119 	const char	*nv_name;
120 	const char	*nv_str;
121 	void		*nv_ptr;
122 	long long	nv_num;
123 	int		nv_ifunit;		/* XXX XXX XXX */
124 	int		nv_flags;
125 #define	NV_DEPENDED	1
126 };
127 
128 /*
129  * Kernel configurations.
130  */
131 struct config {
132 	TAILQ_ENTRY(config) cf_next;
133 	const char *cf_name;		/* "netbsd" */
134 	int	cf_lineno;		/* source line */
135 	const char *cf_fstype;		/* file system type */
136 	struct	nvlist *cf_root;	/* "root on ra0a" */
137 	struct	nvlist *cf_dump;	/* "dumps on ra0b" */
138 };
139 
140 /*
141  * Option definition list
142  */
143 struct defoptlist {
144 	struct defoptlist *dl_next;
145 	const char *dl_name;
146 	const char *dl_value;
147 	const char *dl_lintvalue;
148 	int dl_obsolete;
149 	struct nvlist *dl_depends;
150 };
151 
152 struct files;
153 TAILQ_HEAD(filelist, files);
154 
155 struct module {
156 	const char		*m_name;
157 #if 1
158 	struct attrlist		*m_deps;
159 #else
160 	struct attrlist		*m_attrs;
161 	struct modulelist	*m_deps;
162 #endif
163 	int			m_expanding;
164 	struct filelist		m_files;
165 	int			m_weight;
166 };
167 
168 /*
169  * Attributes.  These come in three flavors: "plain", "device class,"
170  * and "interface".  Plain attributes (e.g., "ether") simply serve
171  * to pull in files.  Device class attributes are like plain
172  * attributes, but additionally specify a device class (e.g., the
173  * "disk" device class attribute specifies that devices with the
174  * attribute belong to the "DV_DISK" class) and are mutually exclusive.
175  * Interface attributes (e.g., "scsi") carry three lists: locators,
176  * child devices, and references.  The locators are those things
177  * that must be specified in order to configure a device instance
178  * using this attribute (e.g., "tg0 at scsi0").  The a_devs field
179  * lists child devices that can connect here (e.g., "tg"s), while
180  * the a_refs are parents that carry the attribute (e.g., actual
181  * SCSI host adapter drivers such as the SPARC "esp").
182  */
183 struct attr {
184 	/* XXX */
185 	struct module a_m;
186 #define	a_name		a_m.m_name
187 #define	a_deps		a_m.m_deps
188 #define	a_expanding	a_m.m_expanding
189 #define	a_files		a_m.m_files
190 #define	a_weight	a_m.m_weight
191 
192 	/* "interface attribute" */
193 	int	a_iattr;		/* true => allows children */
194 	struct	loclist *a_locs;	/* locators required */
195 	int	a_loclen;		/* length of above list */
196 	struct	nvlist *a_devs;		/* children */
197 	struct	nvlist *a_refs;		/* parents */
198 
199 	/* "device class" */
200 	const char *a_devclass;		/* device class described */
201 };
202 
203 /*
204  * List of attributes.
205  */
206 struct attrlist {
207 	struct attrlist *al_next;
208 	struct attr *al_this;
209 };
210 
211 /*
212  * List of locators. (Either definitions or uses...)
213  *
214  * XXX it would be nice if someone could clarify wtf ll_string and ll_num
215  * are actually holding. (This stuff was previously stored in a very ad
216  * hoc fashion, and the code is far from clear.)
217  */
218 struct loclist {
219 	const char *ll_name;
220 	const char *ll_string;
221 	long long ll_num;
222 	struct loclist *ll_next;
223 };
224 
225 /*
226  * Parent specification.  Multiple device instances may share a
227  * given parent spec.  Parent specs are emitted only if there are
228  * device instances which actually reference it.
229  */
230 struct pspec {
231 	TAILQ_ENTRY(pspec) p_list;	/* link on parent spec list */
232 	struct	attr *p_iattr;		/* interface attribute of parent */
233 	struct	devbase *p_atdev;	/* optional parent device base */
234 	int	p_atunit;		/* optional parent device unit */
235 	struct	nvlist *p_devs;		/* children using it */
236 	int	p_inst;			/* parent spec instance */
237 	int	p_active;		/* parent spec is actively used */
238 };
239 
240 /*
241  * The "base" part (struct devbase) of a device ("uba", "sd"; but not
242  * "uba2" or "sd0").  It may be found "at" one or more attributes,
243  * including "at root" (this is represented by a NULL attribute), as
244  * specified by the device attachments (struct deva).
245  *
246  * Each device may also export attributes.  If any provide an output
247  * interface (e.g., "esp" provides "scsi"), other devices (e.g.,
248  * "tg"s) can be found at instances of this one (e.g., "esp"s).
249  * Such a connection must provide locators as specified by that
250  * interface attribute (e.g., "target").  The base device can
251  * export both output (aka `interface') attributes, as well as
252  * import input (`plain') attributes.  Device attachments may
253  * only import input attributes; it makes no sense to have a
254  * specific attachment export a new interface to other devices.
255  *
256  * Each base carries a list of instances (via d_ihead).  Note that this
257  * list "skips over" aliases; those must be found through the instances
258  * themselves.  Each base also carries a list of possible attachments,
259  * each of which specify a set of devices that the device can attach
260  * to, as well as the device instances that are actually using that
261  * attachment.
262  */
263 struct devbase {
264 	const char *d_name;		/* e.g., "sd" */
265 	TAILQ_ENTRY(devbase) d_next;
266 	int	d_isdef;		/* set once properly defined */
267 	int	d_ispseudo;		/* is a pseudo-device */
268 	devmajor_t d_major;		/* used for "root on sd0", e.g. */
269 	struct	attrlist *d_attrs;	/* attributes, if any */
270 	int	d_umax;			/* highest unit number + 1 */
271 	struct	devi *d_ihead;		/* first instance, if any */
272 	struct	devi **d_ipp;		/* used for tacking on more instances */
273 	struct	deva *d_ahead;		/* first attachment, if any */
274 	struct	deva **d_app;		/* used for tacking on attachments */
275 	struct	attr *d_classattr;	/* device class attribute (if any) */
276 };
277 
278 struct deva {
279 	const char *d_name;		/* name of attachment, e.g. "com_isa" */
280 	TAILQ_ENTRY(deva) d_next;	/* list of all instances */
281 	struct	deva *d_bsame;		/* list on same base */
282 	int	d_isdef;		/* set once properly defined */
283 	struct	devbase *d_devbase;	/* the base device */
284 	struct	nvlist *d_atlist;	/* e.g., "at tg" (attr list) */
285 	struct	attrlist *d_attrs;	/* attributes, if any */
286 	struct	devi *d_ihead;		/* first instance, if any */
287 	struct	devi **d_ipp;		/* used for tacking on more instances */
288 };
289 
290 /*
291  * An "instance" of a device.  The same instance may be listed more
292  * than once, e.g., "xx0 at isa? port FOO" + "xx0 at isa? port BAR".
293  *
294  * After everything has been read in and verified, the devi's are
295  * "packed" to collect all the information needed to generate ioconf.c.
296  * In particular, we try to collapse multiple aliases into a single entry.
297  * We then assign each "primary" (non-collapsed) instance a cfdata index.
298  * Note that there may still be aliases among these.
299  */
300 struct devi {
301 	/* created while parsing config file */
302 	const char *i_name;	/* e.g., "sd0" */
303 	int	i_unit;		/* unit from name, e.g., 0 */
304 	struct	devbase *i_base;/* e.g., pointer to "sd" base */
305 	TAILQ_ENTRY(devi) i_next; /* list of all instances */
306 	struct	devi *i_bsame;	/* list on same base */
307 	struct	devi *i_asame;	/* list on same base attachment */
308 	struct	devi *i_alias;	/* other aliases of this instance */
309 	const char *i_at;	/* where this is "at" (NULL if at root) */
310 	struct	pspec *i_pspec;	/* parent spec (NULL if at root) */
311 	struct	deva *i_atdeva;
312 	const char **i_locs;	/* locators (as given by pspec's iattr) */
313 	int	i_cfflags;	/* flags from config line */
314 	int	i_lineno;	/* line # in config, for later errors */
315 	const char *i_srcfile;	/* file it appears in */
316 	int	i_level;	/* position between negated instances */
317 	int	i_active;
318 #define	DEVI_ORPHAN	0	/* instance has no active parent */
319 #define	DEVI_ACTIVE	1	/* instance has an active parent */
320 #define	DEVI_IGNORED	2	/* instance's parent has been removed */
321 #define DEVI_BROKEN	3	/* instance is broken (syntax error) */
322 	int	i_pseudoroot;	/* instance is pseudoroot */
323 
324 	/* created during packing or ioconf.c generation */
325 	short	i_collapsed;	/* set => this alias no longer needed */
326 	u_short	i_cfindex;	/* our index in cfdata */
327 	int	i_locoff;	/* offset in locators.vec */
328 
329 };
330 /* special units */
331 #define	STAR	(-1)		/* unit number for, e.g., "sd*" */
332 #define	WILD	(-2)		/* unit number for, e.g., "sd?" */
333 
334 /*
335  * Files (*.c, *.S, or *.o).  This structure defines the common fields
336  * between the two.
337  */
338 struct files {
339 	TAILQ_ENTRY(files) fi_next;
340 	TAILQ_ENTRY(files) fi_snext;	/* per-suffix list */
341 	const char *fi_srcfile;	/* the name of the "files" file that got us */
342 	u_short	fi_srcline;	/* and the line number */
343 	u_char fi_flags;	/* as below */
344 	const char *fi_tail;	/* name, i.e., strrchr(fi_path, '/') + 1 */
345 	const char *fi_base;	/* tail minus ".c" (or whatever) */
346 	const char *fi_dir;	/* path to file */
347 	const char *fi_path;	/* full file path */
348 	const char *fi_prefix;	/* any file prefix */
349 	const char *fi_buildprefix;	/* prefix in builddir */
350 	int fi_suffix;		/* single char suffix */
351 	size_t fi_len;		/* path string length */
352 	struct condexpr *fi_optx; /* options expression */
353 	struct nvlist *fi_optf; /* flattened version of above, if needed */
354 	const char *fi_mkrule;	/* special make rule, if any */
355 	struct attr *fi_attr;	/* owner attr */
356 	int fi_order;		/* score of order in ${ALLFILES} */
357 	TAILQ_ENTRY(files) fi_anext;	/* next file in attr */
358 };
359 
360 /* flags */
361 #define	FI_SEL		0x01	/* selected */
362 #define	FI_NEEDSCOUNT	0x02	/* needs-count */
363 #define	FI_NEEDSFLAG	0x04	/* needs-flag */
364 #define	FI_HIDDEN	0x08	/* obscured by other(s), base names overlap */
365 
366 extern size_t nselfiles;
367 extern struct files **selfiles;
368 
369 /*
370  * Condition expressions.
371  */
372 
373 enum condexpr_types {
374 	CX_ATOM,
375 	CX_NOT,
376 	CX_AND,
377 	CX_OR,
378 };
379 struct condexpr {
380 	enum condexpr_types cx_type;
381 	union {
382 		const char *atom;
383 		struct condexpr *not;
384 		struct {
385 			struct condexpr *left;
386 			struct condexpr *right;
387 		} and, or;
388 	} cx_u;
389 };
390 #define cx_atom	cx_u.atom
391 #define cx_not	cx_u.not
392 #define cx_and	cx_u.and
393 #define cx_or	cx_u.or
394 
395 /*
396  * File/object prefixes.  These are arranged in a stack, and affect
397  * the behavior of the source path.
398  */
399 
400 struct prefix;
401 SLIST_HEAD(prefixlist, prefix);
402 
403 struct prefix {
404 	SLIST_ENTRY(prefix)	pf_next;	/* next prefix in stack */
405 	const char		*pf_prefix;	/* the actual prefix */
406 };
407 
408 /*
409  * Device major informations.
410  */
411 struct devm {
412 	TAILQ_ENTRY(devm) dm_next;
413 	const char	*dm_srcfile;	/* the name of the "majors" file */
414 	u_short		dm_srcline;	/* the line number */
415 	const char	*dm_name;	/* [bc]devsw name */
416 	devmajor_t	dm_cmajor;	/* character major */
417 	devmajor_t	dm_bmajor;	/* block major */
418 	struct condexpr	*dm_opts;	/* options */
419 	struct nvlist	*dm_devnodes;	/* information on /dev nodes */
420 };
421 
422 /*
423  * Hash tables look up name=value pairs.  The pointer value of the name
424  * is assumed to be constant forever; this can be arranged by interning
425  * the name.  (This is fairly convenient since our lexer does this for
426  * all identifier-like strings---it has to save them anyway, lest yacc's
427  * look-ahead wipe out the current one.)
428  */
429 struct hashtab;
430 
431 extern int lkmmode;
432 extern const char *conffile;		/* source file, e.g., "GENERIC.sparc" */
433 extern const char *machine;		/* machine type, e.g., "sparc" or "sun3" */
434 extern const char *machinearch;	/* machine arch, e.g., "sparc" or "m68k" */
435 extern struct	nvlist *machinesubarches;
436 				/* machine subarches, e.g., "sun68k" or "hpc" */
437 extern const char *ioconfname;		/* ioconf name, mutually exclusive to machine */
438 extern const char *srcdir;		/* path to source directory (rel. to build) */
439 extern const char *builddir;		/* path to build directory */
440 extern const char *defbuilddir;	/* default build directory */
441 extern const char *ident;		/* kernel "ident"ification string */
442 extern int	errors;			/* counts calls to error() */
443 extern int	minmaxusers;		/* minimum "maxusers" parameter */
444 extern int	defmaxusers;		/* default "maxusers" parameter */
445 extern int	maxmaxusers;		/* default "maxusers" parameter */
446 extern int	maxusers;		/* configuration's "maxusers" parameter */
447 extern int	maxpartitions;		/* configuration's "maxpartitions" parameter */
448 extern int	version;		/* version of the configuration file */
449 extern struct	nvlist *options;	/* options */
450 extern struct	nvlist *fsoptions;	/* filesystems */
451 extern struct	nvlist *mkoptions;	/* makeoptions */
452 extern struct	nvlist *appmkoptions;	/* appending mkoptions */
453 extern struct	nvlist *condmkoptions;	/* conditional makeoption table */
454 extern struct	hashtab *devbasetab;	/* devbase lookup */
455 extern struct	hashtab *devroottab;	/* attach at root lookup */
456 extern struct	hashtab *devatab;	/* devbase attachment lookup */
457 extern struct	hashtab *devitab;	/* device instance lookup */
458 extern struct	hashtab *deaddevitab;	/* removed instances lookup */
459 extern struct	hashtab *selecttab;	/* selects things that are "optional foo" */
460 extern struct	hashtab *needcnttab;	/* retains names marked "needs-count" */
461 extern struct	hashtab *opttab;	/* table of configured options */
462 extern struct	hashtab *fsopttab;	/* table of configured file systems */
463 extern struct	dlhash *defopttab;	/* options that have been "defopt"'d */
464 extern struct	dlhash *defflagtab;	/* options that have been "defflag"'d */
465 extern struct	dlhash *defparamtab;	/* options that have been "defparam"'d */
466 extern struct	dlhash *defoptlint;	/* lint values for options */
467 extern struct	nvhash *deffstab;	/* defined file systems */
468 extern struct	dlhash *optfiletab;	/* "defopt"'d option .h files */
469 extern struct	hashtab *attrtab;	/* attributes (locators, etc.) */
470 extern struct	hashtab *attrdeptab;	/* attribute dependencies */
471 extern struct	hashtab *bdevmtab;	/* block devm lookup */
472 extern struct	hashtab *cdevmtab;	/* character devm lookup */
473 
474 TAILQ_HEAD(devbasetq, devbase);
475 TAILQ_HEAD(devatq, deva);
476 TAILQ_HEAD(conftq, config);
477 TAILQ_HEAD(devitq, devi);
478 TAILQ_HEAD(devmtq, devm);
479 TAILQ_HEAD(pspectq, pspec);
480 
481 extern struct devbasetq allbases; /* list of all devbase structures */
482 extern struct devatq alldevas; /* list of all devbase attachments */
483 extern struct conftq allcf;/* list of configured kernels */
484 extern struct devitq alldevi, /* list of all instances */
485 		     allpseudo; /* list of all pseudo-devices */
486 extern struct devmtq alldevms; /* list of all device-majors */
487 extern struct pspectq allpspecs; /* list of all parent specs */
488 
489 extern int	ndevi;				/* number of devi's (before packing) */
490 extern int	npspecs;			/* number of parent specs */
491 extern devmajor_t maxbdevm;			/* max number of block major */
492 extern devmajor_t maxcdevm;			/* max number of character major */
493 extern int	do_devsw;			/* 0 if pre-devsw config */
494 extern int	oktopackage;			/* 0 before setmachine() */
495 extern int	devilevel;			/* used for devi->i_level */
496 
497 extern struct filelist		allfiles;	/* list of all kernel source files */
498 extern struct filelist		allcfiles;	/* list of all .c files */
499 extern struct filelist		allsfiles;	/* list of all .S files */
500 extern struct filelist		allofiles;	/* list of all .o files */
501 
502 extern struct prefixlist	prefixes,	/* prefix stack */
503 				allprefixes;	/* all prefixes used (after popped) */
504 extern struct prefixlist	buildprefixes,	/* build prefix stack */
505 				allbuildprefixes;/* all build prefixes used (after popped) */
506 
507 extern struct attr allattr;
508 extern struct devi **packed;		/* arrayified table for packed devi's */
509 extern size_t npacked;		/* size of packed table, <= ndevi */
510 
511 extern struct locators {			/* loc[] table for config */
512 	const char **vec;
513 	int	used;
514 } locators;
515 
516 struct numconst {
517 	int64_t	val;
518 	int fmt;
519 };
520 
521 /* files.c */
522 void	initfiles(void);
523 void	checkfiles(void);
524 int	fixfiles(void);		/* finalize */
525 int	fixdevsw(void);
526 void	addfile(const char *, struct condexpr *, u_char, const char *);
527 int	expr_eval(struct condexpr *, int (*)(const char *, void *), void *);
528 
529 /* hash.c */
530 struct	hashtab *ht_new(void);
531 void	ht_free(struct hashtab *);
532 int	ht_insrep2(struct hashtab *, const char *, const char *, void *, int);
533 int	ht_insrep(struct hashtab *, const char *, void *, int);
534 #define	ht_insert2(ht, nam1, nam2, val) ht_insrep2(ht, nam1, nam2, val, 0)
535 #define	ht_insert(ht, nam, val) ht_insrep(ht, nam, val, 0)
536 #define	ht_replace(ht, nam, val) ht_insrep(ht, nam, val, 1)
537 int	ht_remove2(struct hashtab *, const char *, const char *);
538 int	ht_remove(struct hashtab *, const char *);
539 void	*ht_lookup2(struct hashtab *, const char *, const char *);
540 void	*ht_lookup(struct hashtab *, const char *);
541 void	initintern(void);
542 const char *intern(const char *);
543 typedef int (*ht_callback2)(const char *, const char *, void *, void *);
544 typedef int (*ht_callback)(const char *, void *, void *);
545 int	ht_enumerate2(struct hashtab *, ht_callback2, void *);
546 int	ht_enumerate(struct hashtab *, ht_callback, void *);
547 
548 /* typed hash, named struct HT, whose type is string -> struct VT */
549 #define DECLHASH(HT, VT) \
550 	struct HT;							\
551 	struct HT *HT##_create(void);					\
552 	int HT##_insert(struct HT *, const char *, struct VT *);	\
553 	int HT##_replace(struct HT *, const char *, struct VT *);	\
554 	int HT##_remove(struct HT *, const char *);			\
555 	struct VT *HT##_lookup(struct HT *, const char *);		\
556 	int HT##_enumerate(struct HT *,					\
557 			int (*)(const char *, struct VT *, void *),	\
558 			void *)
559 DECLHASH(nvhash, nvlist);
560 DECLHASH(dlhash, defoptlist);
561 
562 /* lint.c */
563 void	emit_instances(void);
564 void	emit_options(void);
565 void	emit_params(void);
566 
567 /* main.c */
568 extern	int Mflag;
569 extern	int Sflag;
570 void	addoption(const char *, const char *);
571 void	addfsoption(const char *);
572 void	addmkoption(const char *, const char *);
573 void	appendmkoption(const char *, const char *);
574 void	appendcondmkoption(struct condexpr *, const char *, const char *);
575 void	deffilesystem(struct nvlist *, struct nvlist *);
576 void	defoption(const char *, struct defoptlist *, struct nvlist *);
577 void	defflag(const char *, struct defoptlist *, struct nvlist *, int);
578 void	defparam(const char *, struct defoptlist *, struct nvlist *, int);
579 void	deloption(const char *);
580 void	delfsoption(const char *);
581 void	delmkoption(const char *);
582 int	devbase_has_instances(struct devbase *, int);
583 int	is_declared_option(const char *);
584 int	deva_has_instances(struct deva *, int);
585 void	setupdirs(void);
586 void	fixmaxusers(void);
587 void	fixmkoption(void);
588 const char *strtolower(const char *);
589 
590 /* tests on option types */
591 #define OPT_FSOPT(n)	(nvhash_lookup(deffstab, (n)) != NULL)
592 #define OPT_DEFOPT(n)	(dlhash_lookup(defopttab, (n)) != NULL)
593 #define OPT_DEFFLAG(n)	(dlhash_lookup(defflagtab, (n)) != NULL)
594 #define OPT_DEFPARAM(n)	(dlhash_lookup(defparamtab, (n)) != NULL)
595 #define OPT_OBSOLETE(n)	(dlhash_lookup(obsopttab, (n)) != NULL)
596 #define DEFINED_OPTION(n) (is_declared_option((n)))
597 
598 /* main.c */
599 void	logconfig_include(FILE *, const char *);
600 
601 /* mkdevsw.c */
602 int	mkdevsw(void);
603 
604 /* mkheaders.c */
605 int	mkheaders(void);
606 int	moveifchanged(const char *, const char *);
607 int	emitlocs(void);
608 int	emitioconfh(void);
609 
610 /* mkioconf.c */
611 int	mkioconf(void);
612 
613 /* mkmakefile.c */
614 int	mkmakefile(void);
615 
616 /* mkswap.c */
617 int	mkswap(void);
618 
619 /* pack.c */
620 void	pack(void);
621 
622 /* scan.l */
623 u_short	currentline(void);
624 int	firstfile(const char *);
625 void	package(const char *);
626 int	include(const char *, int, int, int);
627 extern int includedepth;
628 
629 /* sem.c, other than for yacc actions */
630 void	initsem(void);
631 int	onlist(struct nvlist *, void *);
632 
633 /* util.c */
634 void	prefix_push(const char *);
635 void	prefix_pop(void);
636 void	buildprefix_push(const char *);
637 void	buildprefix_pop(void);
638 char	*sourcepath(const char *);
639 extern	int dflag;
640 #define	CFGDBG(n, ...) \
641 	do { if ((dflag) >= (n)) cfgdbg(__VA_ARGS__); } while (0)
642 void	cfgdbg(const char *, ...)			/* debug info */
643      __printflike(1, 2);
644 void	cfgwarn(const char *, ...)			/* immediate warns */
645      __printflike(1, 2);
646 void	cfgxwarn(const char *, int, const char *, ...)	/* delayed warns */
647      __printflike(3, 4);
648 void	cfgerror(const char *, ...)			/* immediate errs */
649      __printflike(1, 2);
650 void	cfgxerror(const char *, int, const char *, ...)	/* delayed errs */
651      __printflike(3, 4);
652 __dead void panic(const char *, ...)
653      __printflike(1, 2);
654 struct nvlist *newnv(const char *, const char *, void *, long long, struct nvlist *);
655 void	nvfree(struct nvlist *);
656 void	nvfreel(struct nvlist *);
657 struct nvlist *nvcat(struct nvlist *, struct nvlist *);
658 void	autogen_comment(FILE *, const char *);
659 struct defoptlist *defoptlist_create(const char *, const char *, const char *);
660 void defoptlist_destroy(struct defoptlist *);
661 struct defoptlist *defoptlist_append(struct defoptlist *, struct defoptlist *);
662 struct attrlist *attrlist_create(void);
663 struct attrlist *attrlist_cons(struct attrlist *, struct attr *);
664 void attrlist_destroy(struct attrlist *);
665 void attrlist_destroyall(struct attrlist *);
666 struct loclist *loclist_create(const char *, const char *, long long);
667 void loclist_destroy(struct loclist *);
668 struct condexpr *condexpr_create(enum condexpr_types);
669 void condexpr_destroy(struct condexpr *);
670 
671 /* liby */
672 void	yyerror(const char *);
673 int	yylex(void);
674