diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2000-06-23 16:18:10 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2000-06-23 16:18:10 +0000 |
commit | dec90b2d5ea86b10e997457c6dca338aba4d1cc7 (patch) | |
tree | 8515a557df2273e17c2a26132f52081f2e9c7d86 /usr.bin/make | |
parent | 6d5c836a14118d8966a373381cc9baffc8053b05 (diff) |
Start of variable fixes and speed-ups.
This patch may seem a bit non-sensical at first. It simply introduces some
new interface. Specifically, recognizes that some variable names
(.TARGET/$@, .OODATE/$?, .ALLSRC/$>, .IMPSRC/$<, .PREFIX/$*, .ARCHIVE/$!,
.MEMBER/$%) are `special' (the actual variables which are local to a
target, e.g. GNode).
Currently, The Varq functions (for Varquick access) are only stubs to the
normal functions.
This fixes a very important detail before proceeding to turn variable lists
into hash tables: if every GNode holds a hash table, initialization times
for those will be very costly. But generic GNodes only hold those seven
special variables... which can be stored directly into a small array;
the only general cases are the environment, the command line and
global variables.
Diffstat (limited to 'usr.bin/make')
-rw-r--r-- | usr.bin/make/arch.c | 16 | ||||
-rw-r--r-- | usr.bin/make/compat.c | 13 | ||||
-rw-r--r-- | usr.bin/make/extern.h | 6 | ||||
-rw-r--r-- | usr.bin/make/job.c | 6 | ||||
-rw-r--r-- | usr.bin/make/make.c | 35 | ||||
-rw-r--r-- | usr.bin/make/make.h | 10 | ||||
-rw-r--r-- | usr.bin/make/suff.c | 26 | ||||
-rw-r--r-- | usr.bin/make/var.c | 50 |
8 files changed, 108 insertions, 54 deletions
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index 7640bf9e2e9..045d20d979b 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arch.c,v 1.29 2000/06/23 16:15:49 espie Exp $ */ +/* $OpenBSD: arch.c,v 1.30 2000/06/23 16:18:08 espie Exp $ */ /* $NetBSD: arch.c,v 1.17 1996/11/06 17:58:59 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -static char rcsid[] = "$OpenBSD: arch.c,v 1.29 2000/06/23 16:15:49 espie Exp $"; +static char rcsid[] = "$OpenBSD: arch.c,v 1.30 2000/06/23 16:18:08 espie Exp $"; #endif #endif /* not lint */ @@ -941,8 +941,8 @@ Arch_Touch (gn) FILE * arch; /* Stream open to archive, positioned properly */ struct ar_hdr arh; /* Current header describing member */ - arch = ArchFindMember(Var_Value(ARCHIVE, gn), - Var_Value(MEMBER, gn), + arch = ArchFindMember(Varq_Value(ARCHIVE_INDEX, gn), + Varq_Value(MEMBER_INDEX, gn), &arh, "r+"); sprintf(arh.ar_date, "%-12ld", (long) now); @@ -1010,8 +1010,8 @@ Arch_MTime (gn) struct ar_hdr *arhPtr; /* Header of desired member */ time_t modTime; /* Modification time as an integer */ - arhPtr = ArchStatMember (Var_Value(ARCHIVE, gn), - Var_Value(MEMBER, gn), + arhPtr = ArchStatMember (Varq_Value(ARCHIVE_INDEX, gn), + Varq_Value(MEMBER_INDEX, gn), TRUE); if (arhPtr != NULL) { gn->mtime = (time_t) strtol(arhPtr->ar_date, NULL, 10); @@ -1121,9 +1121,9 @@ Arch_FindLib (gn, path) free (libName); #ifdef LIBRARIES - Var_Set (TARGET, gn->name, gn); + Varq_Set(TARGET_INDEX, gn->name, gn); #else - Var_Set (TARGET, gn->path == NULL ? gn->name : gn->path, gn); + Varq_Set(TARGET_INDEX, gn->path == NULL ? gn->name : gn->path, gn); #endif /* LIBRARIES */ } diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index 279de0b99ff..1515c3d59e7 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compat.c,v 1.28 2000/06/17 14:38:14 espie Exp $ */ +/* $OpenBSD: compat.c,v 1.29 2000/06/23 16:18:08 espie Exp $ */ /* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: compat.c,v 1.28 2000/06/17 14:38:14 espie Exp $"; +static char rcsid[] = "$OpenBSD: compat.c,v 1.29 2000/06/23 16:18:08 espie Exp $"; #endif #endif /* not lint */ @@ -110,7 +110,7 @@ CompatInterrupt (signo) GNode *gn; if ((curTarg != NULL) && !Targ_Precious (curTarg)) { - char *file = Var_Value(TARGET, curTarg); + char *file = Varq_Value(TARGET_INDEX, curTarg); if (!noExecute && eunlink(file) != -1) { Error("*** %s removed\n", file); @@ -462,9 +462,8 @@ CompatMake(gnp, pgnp) return; } - if (Lst_Member(&gn->iParents, pgn) != NULL) { - Var_Set(IMPSRC, Var_Value(TARGET, gn), pgn); - } + if (Lst_Member(&gn->iParents, pgn) != NULL) + Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn); /* * All the children were made ok. Now cmtime contains the modification @@ -617,7 +616,7 @@ CompatMake(gnp, pgnp) pgn->make = FALSE; } else { if (Lst_Member(&gn->iParents, pgn) != NULL) - Var_Set (IMPSRC, Var_Value(TARGET, gn), pgn); + Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn); switch(gn->made) { case BEINGMADE: Error("Graph cycles through %s\n", gn->name); diff --git a/usr.bin/make/extern.h b/usr.bin/make/extern.h index 685194f94c9..c70ca7435fa 100644 --- a/usr.bin/make/extern.h +++ b/usr.bin/make/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.23 2000/06/17 14:40:28 espie Exp $ */ +/* $OpenBSD: extern.h,v 1.24 2000/06/23 16:18:09 espie Exp $ */ /* $NetBSD: nonints.h,v 1.12 1996/11/06 17:59:19 christos Exp $ */ /*- @@ -144,9 +144,13 @@ void Targ_PrintGraph __P((int)); /* var.c */ void Var_Delete __P((char *, GNode *)); void Var_Set __P((char *, char *, GNode *)); +void Varq_Set __P((int, char *, GNode *)); void Var_Append __P((char *, char *, GNode *)); +void Varq_Append __P((int, char *, GNode *)); Boolean Var_Exists __P((char *, GNode *)); +Boolean Varq_Exists __P((int, GNode *)); char *Var_Value __P((char *, GNode *)); +char *Varq_Value __P((int, GNode *)); char *Var_Parse __P((char *, GNode *, Boolean, size_t *, Boolean *)); char *Var_Subst __P((char *, GNode *, Boolean)); void Var_SubstVar __P((Buffer, char *, const char *, GNode *)); diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index a4ad6f5b2d2..32f78d14495 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.30 2000/06/23 16:15:49 espie Exp $ */ +/* $OpenBSD: job.c,v 1.31 2000/06/23 16:18:09 espie Exp $ */ /* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: job.c,v 1.30 2000/06/23 16:15:49 espie Exp $"; +static char rcsid[] = "$OpenBSD: job.c,v 1.31 2000/06/23 16:18:09 espie Exp $"; #endif #endif /* not lint */ @@ -1097,7 +1097,7 @@ Job_CheckCommands(gn, abortProc) * .DEFAULT itself. */ Make_HandleUse(DEFAULT, gn); - Var_Set(IMPSRC, Var_Value(TARGET, gn), gn); + Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), gn); } else if (Dir_MTime(gn) == 0) { /* * The node wasn't the target of an operator we have no .DEFAULT diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index 4b8cdcc5f99..fe76c7eea5d 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -1,4 +1,4 @@ -/* $OpenBSD: make.c,v 1.19 2000/06/23 16:15:50 espie Exp $ */ +/* $OpenBSD: make.c,v 1.20 2000/06/23 16:18:09 espie Exp $ */ /* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: make.c,v 1.19 2000/06/23 16:15:50 espie Exp $"; +static char rcsid[] = "$OpenBSD: make.c,v 1.20 2000/06/23 16:18:09 espie Exp $"; #endif #endif /* not lint */ @@ -399,7 +399,7 @@ Make_Update (cgn) register char *cname; /* the child's name */ register LstNode ln; /* Element in parents and iParents lists */ - cname = Var_Value(TARGET, cgn); + cname = Varq_Value(TARGET_INDEX, cgn); /* * If the child was actually made, see what its modification time is @@ -515,14 +515,14 @@ Make_Update (cgn) * of this node. */ { - char *cpref = Var_Value(PREFIX, cgn); + char *cpref = Varq_Value(PREFIX_INDEX, cgn); Lst_Open(&cgn->iParents); while ((ln = Lst_Next(&cgn->iParents)) != NULL) { pgn = (GNode *)Lst_Datum (ln); if (pgn->make) { - Var_Set (IMPSRC, cname, pgn); - Var_Set (PREFIX, cpref, pgn); + Varq_Set(IMPSRC_INDEX, cname, pgn); + Varq_Set(PREFIX_INDEX, cpref, pgn); } } Lst_Close(&cgn->iParents); @@ -558,18 +558,17 @@ MakeAddAllSrc(cgnp, pgnp) char *child; if (OP_NOP(cgn->type) || - (child = Var_Value(TARGET, cgn)) == NULL) { + (child = Varq_Value(TARGET_INDEX, cgn)) == NULL) { /* * this node is only source; use the specific pathname for it */ child = cgn->path ? cgn->path : cgn->name; } - Var_Append (ALLSRC, child, pgn); + Varq_Append(ALLSRC_INDEX, child, pgn); if (pgn->type & OP_JOIN) { - if (cgn->made == MADE) { - Var_Append(OODATE, child, pgn); - } + if (cgn->made == MADE) + Varq_Append(OODATE_INDEX, child, pgn); } else if ((pgn->mtime < cgn->mtime) || (cgn->mtime >= now && cgn->made == MADE)) { @@ -589,7 +588,7 @@ MakeAddAllSrc(cgnp, pgnp) * since cgn->mtime is set to now in Make_Update. According to * some people, this is good... */ - Var_Append(OODATE, child, pgn); + Varq_Append(OODATE_INDEX, child, pgn); } } } @@ -622,15 +621,13 @@ Make_DoAllVar (gn) { Lst_ForEach(&gn->children, MakeAddAllSrc, gn); - if (!Var_Exists (OODATE, gn)) { - Var_Set (OODATE, "", gn); - } - if (!Var_Exists (ALLSRC, gn)) { - Var_Set (ALLSRC, "", gn); - } + if (!Varq_Exists(OODATE_INDEX, gn)) + Varq_Set(OODATE_INDEX, "", gn); + if (!Varq_Exists(ALLSRC_INDEX, gn)) + Varq_Set(ALLSRC_INDEX, "", gn); if (gn->type & OP_JOIN) - Var_Set(TARGET, Var_Value(ALLSRC, gn), gn); + Varq_Set(TARGET_INDEX, Varq_Value(ALLSRC_INDEX, gn), gn); } /*- diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index 2512405aaee..fa92abfc339 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -1,4 +1,4 @@ -/* $OpenBSD: make.h,v 1.20 2000/06/17 14:40:29 espie Exp $ */ +/* $OpenBSD: make.h,v 1.21 2000/06/23 16:18:09 espie Exp $ */ /* $NetBSD: make.h,v 1.15 1997/03/10 21:20:00 christos Exp $ */ /* @@ -86,6 +86,14 @@ #define OUT_OF_DATE INT_MIN +/* Variables that are kept in local GNodes. */ +#define TARGET_INDEX 0 +#define OODATE_INDEX 1 +#define ALLSRC_INDEX 2 +#define IMPSRC_INDEX 3 +#define PREFIX_INDEX 4 +#define ARCHIVE_INDEX 5 +#define MEMBER_INDEX 6 /*- * The structure for an individual graph node. Each node has several * pieces of data associated with it. diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index d2f17fdcfc4..bc75abc23f6 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: suff.c,v 1.31 2000/06/23 16:15:50 espie Exp $ */ +/* $OpenBSD: suff.c,v 1.32 2000/06/23 16:18:09 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else -static char rcsid[] = "$OpenBSD: suff.c,v 1.31 2000/06/23 16:15:50 espie Exp $"; +static char rcsid[] = "$OpenBSD: suff.c,v 1.32 2000/06/23 16:18:09 espie Exp $"; #endif #endif /* not lint */ @@ -1659,8 +1659,8 @@ SuffFindArchiveDeps(gn, slst) /* * Set the other two local variables required for this target. */ - Var_Set (MEMBER, name, gn); - Var_Set (ARCHIVE, gn->name, gn); + Varq_Set(MEMBER_INDEX, name, gn); + Varq_Set(ARCHIVE_INDEX, gn->name, gn); if (ms != NULL) { /* @@ -1881,10 +1881,10 @@ SuffFindNormalDeps(gn, slst) * if it's only a source, it doesn't matter what we put here as far * as expanding sources is concerned, since it has none... */ - Var_Set(TARGET, gn->name, gn); + Varq_Set(TARGET_INDEX, gn->name, gn); pref = (targ != NULL) ? targ->pref : gn->name; - Var_Set(PREFIX, pref, gn); + Varq_Set(PREFIX_INDEX, pref, gn); /* * Now we've got the important local variables set, expand any sources @@ -1911,7 +1911,7 @@ sfnd_abort: &targ->suff->searchPath)); if (gn->path != NULL) { char *ptr; - Var_Set(TARGET, gn->path, gn); + Varq_Set(TARGET_INDEX, gn->path, gn); if (targ != NULL) { /* @@ -1931,7 +1931,7 @@ sfnd_abort: else ptr = gn->path; - Var_Set(PREFIX, ptr, gn); + Varq_Set(PREFIX_INDEX, ptr, gn); gn->path[savep] = savec; } else { @@ -1946,7 +1946,7 @@ sfnd_abort: else ptr = gn->path; - Var_Set(PREFIX, ptr, gn); + Varq_Set(PREFIX_INDEX, ptr, gn); } } } else { @@ -2039,9 +2039,9 @@ sfnd_abort: */ targ->node->type |= OP_DEPS_FOUND; - Var_Set(PREFIX, targ->pref, targ->node); + Varq_Set(PREFIX_INDEX, targ->pref, targ->node); - Var_Set(TARGET, targ->node->name, targ->node); + Varq_Set(TARGET_INDEX, targ->node->name, targ->node); } } @@ -2147,14 +2147,14 @@ SuffFindDeps (gn, slst) Arch_FindLib(gn, &s->searchPath); } else { gn->suffix = NULL; - Var_Set (TARGET, gn->name, gn); + Varq_Set(TARGET_INDEX, gn->name, gn); } /* * Because a library (-lfoo) target doesn't follow the standard * filesystem conventions, we don't set the regular variables for * the thing. .PREFIX is simply made empty... */ - Var_Set(PREFIX, "", gn); + Varq_Set(PREFIX_INDEX, "", gn); } else { SuffFindNormalDeps(gn, slst); } diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index d13aa3cf980..5042e22224c 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.33 2000/06/17 14:38:20 espie Exp $ */ +/* $OpenBSD: var.c,v 1.34 2000/06/23 16:18:09 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* @@ -70,7 +70,7 @@ #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: var.c,v 1.33 2000/06/17 14:38:20 espie Exp $"; +static char rcsid[] = "$OpenBSD: var.c,v 1.34 2000/06/23 16:18:09 espie Exp $"; #endif #endif /* not lint */ @@ -125,6 +125,52 @@ static char rcsid[] = "$OpenBSD: var.c,v 1.33 2000/06/17 14:38:20 espie Exp $"; #include "make.h" #include "buf.h" +/* `Quick' index variants. For now, these are stubs which call the `real' + * slow function. + */ +static char *varnames[] = { + TARGET, + OODATE, + ALLSRC, + IMPSRC, + PREFIX, + ARCHIVE, + MEMBER }; + +void +Varq_Set(idx, val, gn) + int idx; + char *val; + GNode *gn; +{ + Var_Set(varnames[idx], val, gn); +} + +void +Varq_Append(idx, val, gn) + int idx; + char *val; + GNode *gn; +{ + Var_Append(varnames[idx], val, gn); +} + +char * +Varq_Value(idx, gn) + int idx; + GNode *gn; +{ + return Var_Value(varnames[idx], gn); +} + +Boolean +Varq_Exists(idx, gn) + int idx; + GNode *gn; +{ + return Var_Exists(varnames[idx], gn); +} + /* * This is a harmless return value for Var_Parse that can be used by Var_Subst * to determine if there was an error in parsing -- easier than returning |