Index: head/sys/conf/Makefile.alpha =================================================================== --- head/sys/conf/Makefile.alpha (revision 152017) +++ head/sys/conf/Makefile.alpha (revision 152018) @@ -1,90 +1,90 @@ # Makefile.alpha -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.alpha 7.1 5/10/91 # $FreeBSD$ # # Makefile for FreeBSD # # This makefile is constructed from a machine description: # config machineid # Most changes should be made in the machine description # /sys/alpha/conf/``machineid'' # after which you should do # config machineid # Generic makefile changes should be made in # /sys/conf/Makefile.alpha # after which config should be rerun for all machines. # # Which version of config(8) is required. -%VERSREQ= 600003 +%VERSREQ= 600004 .if !defined(S) .if exists(./@/.) S= ./@ .else S= ../../.. .endif .endif .include "$S/conf/kern.pre.mk" %BEFORE_DEPEND %OBJS %FILES.c %FILES.s %FILES.m %CLEAN SYSTEM_OBJS+= __divqu.o __divq.o __divlu.o __divl.o SYSTEM_OBJS+= __remqu.o __remq.o __remlu.o __reml.o CLEAN+= __divqu.S __divq.S __divlu.S __divl.S CLEAN+= __remqu.S __remq.S __remlu.S __reml.S __divqu.S: $S/$M/$M/divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__divqu')define(OP,\`div')define(S,\`false')"; \ echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET} __divq.S: $S/$M/$M/divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__divq')define(OP,\`div')define(S,\`true')"; \ echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET} __divlu.S: $S/$M/$M/divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__divlu')define(OP,\`div')define(S,\`false')"; \ echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET} __divl.S: $S/$M/$M/divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__divl')define(OP,\`div')define(S,\`true')"; \ echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET} __remqu.S: $S/$M/$M/divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__remqu')define(OP,\`rem')define(S,\`false')"; \ echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET} __remq.S: $S/$M/$M/divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__remq')define(OP,\`rem')define(S,\`true')"; \ echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET} __remlu.S: $S/$M/$M/divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__remlu')define(OP,\`rem')define(S,\`false')"; \ echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET} __reml.S: $S/$M/$M/divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__reml')define(OP,\`rem')define(S,\`true')"; \ echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET} %RULES .include "$S/conf/kern.post.mk" Index: head/sys/conf/Makefile.amd64 =================================================================== --- head/sys/conf/Makefile.amd64 (revision 152017) +++ head/sys/conf/Makefile.amd64 (revision 152018) @@ -1,55 +1,55 @@ # Makefile.amd64 -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 # from FreeBSD: src/sys/conf/Makefile.i386,v 1.255 2002/02/20 23:35:49 # $FreeBSD$ # # Makefile for FreeBSD # # This makefile is constructed from a machine description: # config machineid # Most changes should be made in the machine description # /sys/amd64/conf/``machineid'' # after which you should do # config machineid # Generic makefile changes should be made in # /sys/conf/Makefile.amd64 # after which config should be rerun for all machines. # # Which version of config(8) is required. -%VERSREQ= 600003 +%VERSREQ= 600004 STD8X16FONT?= iso .if !defined(S) .if exists(./@/.) S= ./@ .else S= ../../.. .endif .endif .include "$S/conf/kern.pre.mk" DDB_ENABLED!= grep DDB opt_ddb.h || true .if !empty(DDB_ENABLED) CFLAGS+= -fno-omit-frame-pointer .endif MKMODULESENV+= MACHINE=amd64 %BEFORE_DEPEND %OBJS %FILES.c %FILES.s %FILES.m %CLEAN %RULES .include "$S/conf/kern.post.mk" Index: head/sys/conf/Makefile.arm =================================================================== --- head/sys/conf/Makefile.arm (revision 152017) +++ head/sys/conf/Makefile.arm (revision 152018) @@ -1,79 +1,79 @@ # Makefile.arm -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 # $FreeBSD$ # # Makefile for FreeBSD # # This makefile is constructed from a machine description: # config machineid # Most changes should be made in the machine description # /sys/arm/conf/``machineid'' # after which you should do # config machineid # Generic makefile changes should be made in # /sys/conf/Makefile.arm # after which config should be rerun for all machines. # # Which version of config(8) is required. -%VERSREQ= 600003 +%VERSREQ= 600004 # Temporary stuff while we're still embryonic NO_MODULES= STD8X16FONT?= iso .if !defined(S) .if exists(./@/.) S= ./@ .else S= ../../.. .endif .endif .include "$S/conf/kern.pre.mk" SYSTEM_LD:= ${SYSTEM_LD:$S/conf/ldscript.$M=ldscript.$M} SYSTEM_DEP:= ${SYSTEM_DEP:$S/conf/ldscript.$M=ldscript.$M} .if defined(ARM_BIG_ENDIAN) CC += -mbig-endian SYSTEM_LD += -EB .endif .if !defined(DEBUG) CFLAGS += -mno-apcs-frame .endif DDB_ENABLED!= grep DDB opt_ddb.h || true .if ${DDB_ENABLED} != "" SYSTEM_LD_TAIL += ;echo "\#define KERNNAME \"${KERNEL_KO}\"" >opt_kernname.h ; \ ${OBJCOPY} --strip-symbol '$$d' --strip-symbol '$$a' \ --strip-symbol '$$t' ${KERNEL_KO} ;\ ${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.arm \ $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S -o ${KERNEL_KO}.tramp .endif %BEFORE_DEPEND %OBJS %FILES.c %FILES.s %FILES.m %CLEAN .if ${DDB_ENABLED} != "" CLEAN+= kernel.tramp .endif ldscript.$M: $S/conf/ldscript.$M cat $S/conf/ldscript.$M|sed s/KERNPHYSADDR/${KERNPHYSADDR}/g| \ sed s/KERNVIRTADDR/${KERNVIRTADDR}/g > ldscript.$M %RULES .include "$S/conf/kern.post.mk" Index: head/sys/conf/Makefile.i386 =================================================================== --- head/sys/conf/Makefile.i386 (revision 152017) +++ head/sys/conf/Makefile.i386 (revision 152018) @@ -1,49 +1,49 @@ # Makefile.i386 -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 # $FreeBSD$ # # Makefile for FreeBSD # # This makefile is constructed from a machine description: # config machineid # Most changes should be made in the machine description # /sys/i386/conf/``machineid'' # after which you should do # config machineid # Generic makefile changes should be made in # /sys/conf/Makefile.i386 # after which config should be rerun for all machines. # # Which version of config(8) is required. -%VERSREQ= 600003 +%VERSREQ= 600004 STD8X16FONT?= iso .if !defined(S) .if exists(./@/.) S= ./@ .else S= ../../.. .endif .endif .include "$S/conf/kern.pre.mk" MKMODULESENV+= MACHINE=i386 %BEFORE_DEPEND %OBJS %FILES.c %FILES.s %FILES.m %CLEAN %RULES .include "$S/conf/kern.post.mk" Index: head/sys/conf/Makefile.ia64 =================================================================== --- head/sys/conf/Makefile.ia64 (revision 152017) +++ head/sys/conf/Makefile.ia64 (revision 152018) @@ -1,55 +1,55 @@ # Makefile.ia64 -- with config changes. # Copyright 1990 W. Jolitz # from: src/sys/conf/Makefile.alpha,v 1.76 # $FreeBSD$ # # Makefile for FreeBSD # # This makefile is constructed from a machine description: # config machineid # Most changes should be made in the machine description # /sys/ia64/conf/``machineid'' # after which you should do # config machineid # Generic makefile changes should be made in # /sys/conf/Makefile.ia64 # after which config should be rerun for all machines. # GCC3= you bet # Which version of config(8) is required. -%VERSREQ= 600003 +%VERSREQ= 600004 STD8X16FONT?= iso .if !defined(S) .if exists(./@/.) S= ./@ .else S= ../../.. .endif .endif .include "$S/conf/kern.pre.mk" INCLUDES+= -I$S/contrib/ia64/libuwx/src CFLAGS+= -mconstant-gp ASM_CFLAGS= -x assembler-with-cpp -Wa,-x -DLOCORE ${CFLAGS} %BEFORE_DEPEND %OBJS %FILES.c %FILES.s %FILES.m %CLEAN %RULES .include "$S/conf/kern.post.mk" Index: head/sys/conf/Makefile.pc98 =================================================================== --- head/sys/conf/Makefile.pc98 (revision 152017) +++ head/sys/conf/Makefile.pc98 (revision 152018) @@ -1,49 +1,49 @@ # Makefile for FreeBSD(98) after: # # Makefile.i386 -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 # $FreeBSD$ # # Makefile for FreeBSD # # This makefile is constructed from a machine description: # config machineid # Most changes should be made in the machine description # /sys/pc98/conf/``machineid'' # after which you should do # config machineid # Generic makefile changes should be made in # /sys/conf/Makefile.pc98 # after which config should be rerun for all machines. # # Which version of config(8) is required. -%VERSREQ= 600003 +%VERSREQ= 600004 .if !defined(S) .if exists(./@/.) S= ./@ .else S= ../../.. .endif .endif .include "$S/conf/kern.pre.mk" MKMODULESENV+= MACHINE=pc98 %BEFORE_DEPEND %OBJS %FILES.c %FILES.s %FILES.m %CLEAN %RULES .include "$S/conf/kern.post.mk" Index: head/sys/conf/Makefile.powerpc =================================================================== --- head/sys/conf/Makefile.powerpc (revision 152017) +++ head/sys/conf/Makefile.powerpc (revision 152018) @@ -1,54 +1,54 @@ # Makefile.powerpc -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 # $FreeBSD$ # # Makefile for FreeBSD # # This makefile is constructed from a machine description: # config machineid # Most changes should be made in the machine description # /sys/powerpc/conf/``machineid'' # after which you should do # config machineid # Generic makefile changes should be made in # /sys/conf/Makefile.powerpc # after which config should be rerun for all machines. # # Which version of config(8) is required. -%VERSREQ= 600003 +%VERSREQ= 600004 STD8X16FONT?= iso .if !defined(S) .if exists(./@/.) S= ./@ .else S= ../../.. .endif .endif .include "$S/conf/kern.pre.mk" CFLAGS+= -msoft-float DDB_ENABLED!= grep DDB opt_ddb.h || true .if !empty(DDB_ENABLED) CFLAGS+= -fno-omit-frame-pointer .endif %BEFORE_DEPEND %OBJS %FILES.c %FILES.s %FILES.m %CLEAN %RULES .include "$S/conf/kern.post.mk" Index: head/sys/conf/Makefile.sparc64 =================================================================== --- head/sys/conf/Makefile.sparc64 (revision 152017) +++ head/sys/conf/Makefile.sparc64 (revision 152018) @@ -1,49 +1,49 @@ # Makefile.sparc64 -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 # $FreeBSD$ # # Makefile for FreeBSD # # This makefile is constructed from a machine description: # config machineid # Most changes should be made in the machine description # /sys/sparc64/conf/``machineid'' # after which you should do # config machineid # Generic makefile changes should be made in # /sys/conf/Makefile.sparc64 # after which config should be rerun for all machines. # # Which version of config(8) is required. -%VERSREQ= 600003 +%VERSREQ= 600004 STD8X16FONT?= iso .if !defined(S) .if exists(./@/.) S= ./@ .else S= ../../.. .endif .endif .include "$S/conf/kern.pre.mk" MDOBJS= exception.o interrupt.o %BEFORE_DEPEND %OBJS %FILES.c %FILES.s %FILES.m %CLEAN %RULES .include "$S/conf/kern.post.mk" Index: head/usr.sbin/config/config.y =================================================================== --- head/usr.sbin/config/config.y (revision 152017) +++ head/usr.sbin/config/config.y (revision 152018) @@ -1,399 +1,411 @@ %union { char *str; int val; struct file_list *file; } %token ARCH %token COMMA %token CONFIG %token CPU +%token NOCPU %token DEVICE %token NODEVICE %token ENV %token EQUALS %token HINTS %token IDENT %token MAXUSERS %token PROFILE %token OPTIONS %token NOOPTION %token MAKEOPTIONS %token NOMAKEOPTION %token SEMICOLON %token INCLUDE %token FILES %token ID %token NUMBER %type Save_id %type Opt_value %type Dev %{ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)config.y 8.1 (Berkeley) 6/6/93 * $FreeBSD$ */ #include #include #include #include #include "config.h" struct device_head dtab; char *ident; char *env; int envmode; char *hints; int hintmode; int yyline; const char *yyfile; struct file_list_head ftab; struct files_name_head fntab; char errbuf[80]; int maxusers; #define ns(s) strdup(s) int include(const char *, int); void yyerror(const char *s); int yywrap(void); static char * devopt(char *dev) { char *ret = malloc(strlen(dev) + 5); sprintf(ret, "DEV_%s", dev); raisestr(ret); return ret; } %} %% Configuration: Many_specs ; Many_specs: Many_specs Spec | /* lambda */ ; Spec: Device_spec SEMICOLON | Config_spec SEMICOLON | INCLUDE ID SEMICOLON = { include($2, 0); }; | FILES ID SEMICOLON = { newfile($2); }; | SEMICOLON | error SEMICOLON ; Config_spec: ARCH Save_id = { if (machinename != NULL) errx(1, "%s:%d: only one machine directive is allowed", yyfile, yyline); machinename = $2; machinearch = $2; } | ARCH Save_id Save_id = { if (machinename != NULL) errx(1, "%s:%d: only one machine directive is allowed", yyfile, yyline); machinename = $2; machinearch = $3; } | CPU Save_id = { struct cputype *cp = (struct cputype *)malloc(sizeof (struct cputype)); memset(cp, 0, sizeof(*cp)); cp->cpu_name = $2; SLIST_INSERT_HEAD(&cputype, cp, cpu_next); + } | + NOCPU Save_id + = { + struct cputype *cp, *cp2; + SLIST_FOREACH_SAFE(cp, &cputype, cpu_next, cp2) { + if (strcmp(cp->cpu_name, $2) != 0) + continue; + SLIST_REMOVE(&cputype, cp, cputype, cpu_next); + free(cp); + break; + } } | OPTIONS Opt_list | NOOPTION Save_id = { rmopt(&opt, $2); } | MAKEOPTIONS Mkopt_list | NOMAKEOPTION Save_id = { rmopt(&mkopt, $2); } | IDENT ID = { ident = $2; } | System_spec | MAXUSERS NUMBER = { maxusers = $2; } | PROFILE NUMBER = { profiling = $2; } | ENV ID = { env = $2; envmode = 1; } | HINTS ID = { hints = $2; hintmode = 1; } System_spec: CONFIG System_id System_parameter_list = { errx(1, "%s:%d: root/dump/swap specifications obsolete", yyfile, yyline);} | CONFIG System_id ; System_id: Save_id = { newopt(&mkopt, ns("KERNEL"), $1); }; System_parameter_list: System_parameter_list ID | ID ; Opt_list: Opt_list COMMA Option | Option ; Option: Save_id = { char *s; newopt(&opt, $1, NULL); if ((s = strchr($1, '='))) errx(1, "%s:%d: The `=' in options should not be " "quoted", yyfile, yyline); } | Save_id EQUALS Opt_value = { newopt(&opt, $1, $3); } ; Opt_value: ID = { $$ = $1; } | NUMBER = { char buf[80]; (void) snprintf(buf, sizeof(buf), "%d", $1); $$ = ns(buf); } ; Save_id: ID = { $$ = $1; } ; Mkopt_list: Mkopt_list COMMA Mkoption | Mkoption ; Mkoption: Save_id = { newopt(&mkopt, $1, ns("")); } | Save_id EQUALS Opt_value = { newopt(&mkopt, $1, $3); } ; Dev: ID = { $$ = $1; } ; Device_spec: DEVICE Dev_list | NODEVICE NoDev_list ; Dev_list: Dev_list COMMA Device | Device ; NoDev_list: NoDev_list COMMA NoDevice | NoDevice ; Device: Dev = { newopt(&opt, devopt($1), ns("1")); /* and the device part */ newdev($1); } NoDevice: Dev = { char *s = devopt($1); rmopt(&opt, s); free(s); /* and the device part */ rmdev($1); } ; %% void yyerror(const char *s) { errx(1, "%s:%d: %s", yyfile, yyline + 1, s); } int yywrap(void) { if (found_defaults) { if (freopen(PREFIX, "r", stdin) == NULL) err(2, "%s", PREFIX); yyfile = PREFIX; yyline = 0; found_defaults = 0; return 0; } return 1; } /* * Add a new file to the list of files. */ static void newfile(char *name) { struct files_name *nl; nl = (struct files_name *) malloc(sizeof *nl); bzero(nl, sizeof *nl); nl->f_name = name; STAILQ_INSERT_TAIL(&fntab, nl, f_next); } /* * add a device to the list of devices */ static void newdev(char *name) { struct device *np; np = (struct device *) malloc(sizeof *np); memset(np, 0, sizeof(*np)); np->d_name = name; STAILQ_INSERT_TAIL(&dtab, np, d_next); } /* * remove a device from the list of devices */ static void rmdev(char *name) { struct device *dp, *rmdp; STAILQ_FOREACH(dp, &dtab, d_next) { if (eq(dp->d_name, name)) { rmdp = dp; dp = STAILQ_NEXT(dp, d_next); STAILQ_REMOVE(&dtab, rmdp, device, d_next); free(rmdp->d_name); free(rmdp); if (dp == NULL) break; } } } static void newopt(struct opt_head *list, char *name, char *value) { struct opt *op; op = (struct opt *)malloc(sizeof (struct opt)); memset(op, 0, sizeof(*op)); op->op_name = name; op->op_ownfile = 0; op->op_value = value; SLIST_INSERT_HEAD(list, op, op_next); } static void rmopt(struct opt_head *list, char *name) { struct opt *op, *rmop; SLIST_FOREACH(op, list, op_next) { if (eq(op->op_name, name)) { rmop = op; op = SLIST_NEXT(op, op_next); SLIST_REMOVE(list, rmop, opt, op_next); free(rmop->op_name); if (rmop->op_value != NULL) free(rmop->op_value); free(rmop); if (op == NULL) break; } } } Index: head/usr.sbin/config/configvers.h =================================================================== --- head/usr.sbin/config/configvers.h (revision 152017) +++ head/usr.sbin/config/configvers.h (revision 152018) @@ -1,11 +1,11 @@ /* * 6 digits of version. The most significant are branch indicators * (eg: RELENG_2_2 = 22, -current presently = 60 etc). The least * significant digits are incremented for each incompatible change. * * The numbering scheme is inspired by the sys/conf/newvers.sh RELDATE * and system. * * $FreeBSD$ */ -#define CONFIGVERS 600003 +#define CONFIGVERS 600004 Index: head/usr.sbin/config/lang.l =================================================================== --- head/usr.sbin/config/lang.l (revision 152017) +++ head/usr.sbin/config/lang.l (revision 152018) @@ -1,270 +1,271 @@ %{ /*- * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)lang.l 8.1 (Berkeley) 6/6/93 * $FreeBSD$ */ #include #include #include #include "y.tab.h" #include "config.h" #define YY_NO_UNPUT /* * Data for returning to previous files from include files. */ struct incl { struct incl *in_prev; /* previous includes in effect, if any */ YY_BUFFER_STATE in_buf; /* previous lex state */ const char *in_fname; /* previous file name */ int in_lineno; /* previous line number */ int in_ateof; /* token to insert at EOF */ }; static struct incl *inclp; static const char *lastfile; /* * Key word table */ struct kt { const char *kt_name; int kt_val; } key_words[] = { { "config", CONFIG }, { "cpu", CPU }, + { "nocpu", NOCPU }, { "device", DEVICE }, { "devices", DEVICE }, { "nodevice", NODEVICE }, { "nodevices", NODEVICE }, { "env", ENV }, { "hints", HINTS }, { "ident", IDENT }, { "machine", ARCH }, /* MACHINE is defined in /sys/param.h */ { "makeoptions", MAKEOPTIONS }, { "nomakeoption", NOMAKEOPTION }, { "maxusers", MAXUSERS }, { "profile", PROFILE }, { "option", OPTIONS }, { "options", OPTIONS }, { "nooption", NOOPTION }, { "nooptions", NOOPTION }, { "include", INCLUDE }, { "files", FILES }, { 0, 0 }, }; static int endinclude(void); int include(const char *, int); int kw_lookup(char *); unsigned int octal(const char *); unsigned int hex(const char *); int yyerror(const char *); %} ID [A-Za-z_][-A-Za-z_0-9]* %START TOEOL %% {ID} { int i; BEGIN 0; if ((i = kw_lookup(yytext)) == -1) { yylval.str = strdup(yytext); return ID; } return i; } \\\"[^"]+\\\" { BEGIN 0; yytext[yyleng-2] = '"'; yytext[yyleng-1] = '\0'; yylval.str = strdup(yytext + 1); return ID; } \"[^"]+\" { BEGIN 0; yytext[yyleng-1] = '\0'; yylval.str = strdup(yytext + 1); return ID; } [^# \t\n]* { BEGIN 0; yylval.str = strdup(yytext); return ID; } 0[0-7]* { yylval.val = octal(yytext); return NUMBER; } 0x[0-9a-fA-F]+ { yylval.val = hex(yytext); return NUMBER; } -?[1-9][0-9]* { yylval.val = atoi(yytext); return NUMBER; } "?" { yylval.val = -1; return NUMBER; } \n/[ \t] { yyline++; } \n { yyline++; return SEMICOLON; } #.* { /* Ignored (comment) */; } [ \t\f]* { /* Ignored (white space) */; } ";" { return SEMICOLON; } "," { return COMMA; } "=" { BEGIN TOEOL; return EQUALS; } <> { int tok; if (inclp == NULL) return YY_NULL; tok = endinclude(); if (tok != 0) return tok; /* otherwise continue scanning */ } . { return yytext[0]; } %% /* * kw_lookup * Look up a string in the keyword table. Returns a -1 if the * string is not a keyword otherwise it returns the keyword number */ int kw_lookup(char *word) { struct kt *kp; for (kp = key_words; kp->kt_name != 0; kp++) if (eq(word, kp->kt_name)) return kp->kt_val; return -1; } /* * Number conversion routines */ unsigned int octal(const char *str) { unsigned int num; (void) sscanf(str, "%o", &num); return num; } unsigned int hex(const char *str) { unsigned int num; (void) sscanf(str+2, "%x", &num); return num; } /* * Open the named file for inclusion at the current point. Returns 0 on * success (file opened and previous state pushed), nonzero on failure * (fopen failed, complaint made). The `ateof' parameter controls the * token to be inserted at the end of the include file. If ateof == 0, * then nothing is inserted. */ int include(const char *fname, int ateof) { FILE *fp; struct incl *in; char *fnamebuf; fp = fopen(fname, "r"); if (fp == NULL && fname[0] != '.' && fname[0] != '/') { asprintf(&fnamebuf, "../../conf/%s", fname); if (fnamebuf != NULL) { fp = fopen(fnamebuf, "r"); free(fnamebuf); } } if (fp == NULL) { yyerror("cannot open included file"); return (-1); } in = malloc(sizeof(*in)); assert(in != NULL); in->in_prev = inclp; in->in_buf = YY_CURRENT_BUFFER; in->in_fname = yyfile; in->in_lineno = yyline; in->in_ateof = ateof; inclp = in; yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE)); yyfile = fname; yyline = 0; return (0); } /* * Terminate the most recent inclusion. */ static int endinclude() { struct incl *in; int ateof; in = inclp; assert(in != NULL); inclp = in->in_prev; lastfile = yyfile; yy_delete_buffer(YY_CURRENT_BUFFER); (void)fclose(yyin); yy_switch_to_buffer(in->in_buf); yyfile = in->in_fname; yyline = in->in_lineno; ateof = in->in_ateof; free(in); return (ateof); }