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