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