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