Module Name: src
Committed By: rillig
Date: Mon Oct 19 21:57:37 UTC 2020
Modified Files:
src/usr.bin/make: arch.c dir.c lst.c lst.h main.c make.c meta.c parse.c
suff.c
Log Message:
make(1): inline simple Lst getters
The function call variant takes more screen space than the direct field
access. Having an abstract API is usually a good idea, in this case of
simple read-only member access it makes the code more difficult to read.
LstNode_Set has been kept as a function since it is not a read-only
accessor function.
To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/make/arch.c
cvs rdiff -u -r1.170 -r1.171 src/usr.bin/make/dir.c
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/lst.c
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/make/lst.h
cvs rdiff -u -r1.378 -r1.379 src/usr.bin/make/main.c
cvs rdiff -u -r1.164 -r1.165 src/usr.bin/make/make.c
cvs rdiff -u -r1.126 -r1.127 src/usr.bin/make/meta.c
cvs rdiff -u -r1.393 -r1.394 src/usr.bin/make/parse.c
cvs rdiff -u -r1.194 -r1.195 src/usr.bin/make/suff.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.136 src/usr.bin/make/arch.c:1.137
--- src/usr.bin/make/arch.c:1.136 Sun Oct 18 13:02:10 2020
+++ src/usr.bin/make/arch.c Mon Oct 19 21:57:37 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.136 2020/10/18 13:02:10 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.137 2020/10/19 21:57:37 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
#include "config.h"
/* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: arch.c,v 1.136 2020/10/18 13:02:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.137 2020/10/19 21:57:37 rillig Exp $");
#ifdef TARGET_MACHINE
#undef MAKE_MACHINE
@@ -468,7 +468,7 @@ ArchStatMember(const char *archive, cons
if (ln != NULL) {
struct ar_hdr *hdr;
- ar = LstNode_Datum(ln);
+ ar = ln->datum;
hdr = Hash_FindValue(&ar->members, member);
if (hdr != NULL)
return hdr;
Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.170 src/usr.bin/make/dir.c:1.171
--- src/usr.bin/make/dir.c:1.170 Sun Oct 18 17:19:54 2020
+++ src/usr.bin/make/dir.c Mon Oct 19 21:57:37 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.170 2020/10/18 17:19:54 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.171 2020/10/19 21:57:37 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -135,7 +135,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: dir.c,v 1.170 2020/10/18 17:19:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.171 2020/10/19 21:57:37 rillig Exp $");
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -1510,7 +1510,7 @@ Dir_AddDir(SearchPath *path, const char
if (path != NULL && strcmp(name, ".DOTLAST") == 0) {
SearchPathNode *ln = Lst_Find(path, DirFindName, name);
if (ln != NULL)
- return LstNode_Datum(ln);
+ return ln->datum;
dotLast->refCount++;
Lst_Prepend(path, dotLast);
Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.78 src/usr.bin/make/lst.c:1.79
--- src/usr.bin/make/lst.c:1.78 Mon Oct 19 21:41:31 2020
+++ src/usr.bin/make/lst.c Mon Oct 19 21:57:37 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.78 2020/10/19 21:41:31 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.79 2020/10/19 21:57:37 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -34,7 +34,7 @@
#include "make.h"
-MAKE_RCSID("$NetBSD: lst.c,v 1.78 2020/10/19 21:41:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.79 2020/10/19 21:57:37 rillig Exp $");
/* Allocate and initialize a list node.
*
@@ -268,7 +268,7 @@ LstNode_SetNull(ListNode *node)
ListNode *
Lst_Find(List *list, LstFindProc match, const void *matchArgs)
{
- return Lst_FindFrom(list, Lst_First(list), match, matchArgs);
+ return Lst_FindFrom(list, list->first, match, matchArgs);
}
/* Return the first node from the list, starting at the given node, for which
Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.73 src/usr.bin/make/lst.h:1.74
--- src/usr.bin/make/lst.h:1.73 Mon Oct 19 21:41:31 2020
+++ src/usr.bin/make/lst.h Mon Oct 19 21:57:37 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.h,v 1.73 2020/10/19 21:41:31 rillig Exp $ */
+/* $NetBSD: lst.h,v 1.74 2020/10/19 21:57:37 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -145,12 +145,7 @@ void Lst_Destroy(List *, LstFreeProc);
static inline MAKE_ATTR_UNUSED Boolean
Lst_IsEmpty(List *list) { return list->first == NULL; }
-/* Return the first node of the list, or NULL if the list is empty. */
-static inline MAKE_ATTR_UNUSED ListNode *
-Lst_First(List *list) { return list->first; }
-/* Return the last node of the list, or NULL if the list is empty. */
-static inline MAKE_ATTR_UNUSED ListNode *
-Lst_Last(List *list) { return list->last; }
+
/* Find the first node for which the function returns TRUE, or NULL. */
ListNode *Lst_Find(List *, LstFindProc, const void *);
/* Find the first node for which the function returns TRUE, or NULL.
@@ -175,9 +170,6 @@ void Lst_MoveAll(List *, List *);
/* Node-specific functions */
-/* Return the datum of the node. Usually not NULL. */
-static inline MAKE_ATTR_UNUSED void *
-LstNode_Datum(ListNode *node) { return node->datum; }
/* Replace the value of the node. */
void LstNode_Set(ListNode *, void *);
/* Set the value of the node to NULL. Having NULL in a list is unusual. */
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.378 src/usr.bin/make/main.c:1.379
--- src/usr.bin/make/main.c:1.378 Sun Oct 18 13:02:10 2020
+++ src/usr.bin/make/main.c Mon Oct 19 21:57:37 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.378 2020/10/18 13:02:10 rillig Exp $ */
+/* $NetBSD: main.c,v 1.379 2020/10/19 21:57:37 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.378 2020/10/18 13:02:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.379 2020/10/19 21:57:37 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -1370,7 +1370,7 @@ main(int argc, char **argv)
ln = Lst_Find(sysMkPath, ReadMakefileSucceeded, NULL);
if (ln == NULL)
Fatal("%s: cannot open %s.", progname,
- (char *)LstNode_Datum(Lst_First(sysMkPath)));
+ (char *)sysMkPath->first->datum);
}
if (!Lst_IsEmpty(makefiles)) {
@@ -1379,7 +1379,7 @@ main(int argc, char **argv)
ln = Lst_Find(makefiles, ReadMakefileFailed, NULL);
if (ln != NULL)
Fatal("%s: cannot open %s.", progname,
- (char *)LstNode_Datum(ln));
+ (char *)ln->datum);
} else {
(void)Var_Subst("${" MAKEFILE_PREFERENCE "}",
VAR_CMD, VARE_WANTRES, &p1);
Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.164 src/usr.bin/make/make.c:1.165
--- src/usr.bin/make/make.c:1.164 Mon Oct 19 19:55:25 2020
+++ src/usr.bin/make/make.c Mon Oct 19 21:57:37 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.164 2020/10/19 19:55:25 rillig Exp $ */
+/* $NetBSD: make.c,v 1.165 2020/10/19 21:57:37 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
#include "job.h"
/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */
-MAKE_RCSID("$NetBSD: make.c,v 1.164 2020/10/19 19:55:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.165 2020/10/19 21:57:37 rillig Exp $");
/* Sequence # to detect recursion. */
static unsigned int checked = 1;
@@ -622,12 +622,12 @@ Make_Update(GNode *cgn)
parents = centurion->parents;
/* If this was a .ORDER node, schedule the RHS */
- Lst_ForEachUntil(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade));
+ Lst_ForEachUntil(centurion->order_succ, MakeBuildParent, toBeMade->first);
/* Now mark all the parents as having one less unmade child */
Lst_Open(parents);
while ((ln = Lst_Next(parents)) != NULL) {
- pgn = LstNode_Datum(ln);
+ pgn = ln->datum;
if (DEBUG(MAKE))
debug_printf("inspect parent %s%s: flags %x, "
"type %x, made %d, unmade %d ",
@@ -723,7 +723,7 @@ Make_Update(GNode *cgn)
const char *cpref = Var_Value(PREFIX, cgn, &p1);
while ((ln = Lst_Next(cgn->implicitParents)) != NULL) {
- pgn = LstNode_Datum(ln);
+ pgn = ln->datum;
if (pgn->flags & REMAKE) {
Var_Set(IMPSRC, cname, pgn);
if (cpref != NULL)
@@ -961,7 +961,7 @@ MakeStartJobs(void)
* just before the current first element.
*/
gn->made = DEFERRED;
- Lst_ForEachUntil(gn->children, MakeBuildChild, Lst_First(toBeMade));
+ Lst_ForEachUntil(gn->children, MakeBuildChild, toBeMade->first);
/* and drop this node on the floor */
DEBUG2(MAKE, "dropped %s%s\n", gn->name, gn->cohort_num);
continue;
@@ -1240,10 +1240,10 @@ Make_ProcessWait(GNodeList *targs)
if (pgn->type & OP_DOUBLEDEP)
Lst_PrependAll(examine, pgn->cohorts);
- owln = Lst_First(pgn->children);
+ owln = pgn->children->first;
Lst_Open(pgn->children);
for (; (ln = Lst_Next(pgn->children)) != NULL; ) {
- GNode *cgn = LstNode_Datum(ln);
+ GNode *cgn = ln->datum;
if (cgn->type & OP_WAIT) {
add_wait_dependency(owln, cgn);
owln = ln;
Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.126 src/usr.bin/make/meta.c:1.127
--- src/usr.bin/make/meta.c:1.126 Mon Oct 19 20:41:53 2020
+++ src/usr.bin/make/meta.c Mon Oct 19 21:57:37 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.126 2020/10/19 20:41:53 rillig Exp $ */
+/* $NetBSD: meta.c,v 1.127 2020/10/19 21:57:37 rillig Exp $ */
/*
* Implement 'meta' mode.
@@ -1150,7 +1150,7 @@ meta_oodate(GNode *gn, Boolean oodate)
/* we want to track all the .meta we read */
Var_Append(".MAKE.META.FILES", fname, VAR_GLOBAL);
- cmdNode = Lst_First(gn->commands);
+ cmdNode = gn->commands->first;
while (!oodate && (x = fgetLine(&buf, &bufsz, 0, fp)) > 0) {
lineno++;
if (buf[x - 1] == '\n')
@@ -1327,7 +1327,7 @@ meta_oodate(GNode *gn, Boolean oodate)
nln = Lst_FindFrom(missingFiles,
missingNode->next,
path_match, p);
- tp = LstNode_Datum(missingNode);
+ tp = missingNode->datum;
Lst_Remove(missingFiles, missingNode);
free(tp);
} while ((missingNode = nln) != NULL);
@@ -1502,7 +1502,7 @@ meta_oodate(GNode *gn, Boolean oodate)
fname, lineno);
oodate = TRUE;
} else {
- char *cmd = LstNode_Datum(cmdNode);
+ char *cmd = cmdNode->datum;
Boolean hasOODATE = FALSE;
if (strstr(cmd, "$?"))
@@ -1579,7 +1579,7 @@ meta_oodate(GNode *gn, Boolean oodate)
fclose(fp);
if (!Lst_IsEmpty(missingFiles)) {
DEBUG2(META, "%s: missing files: %s...\n",
- fname, (char *)LstNode_Datum(Lst_First(missingFiles)));
+ fname, (char *)missingFiles->first->datum);
oodate = TRUE;
}
if (!oodate && !have_filemon && filemonMissing) {
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.393 src/usr.bin/make/parse.c:1.394
--- src/usr.bin/make/parse.c:1.393 Mon Oct 19 20:55:30 2020
+++ src/usr.bin/make/parse.c Mon Oct 19 21:57:37 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.393 2020/10/19 20:55:30 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.394 2020/10/19 21:57:37 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.393 2020/10/19 20:55:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.394 2020/10/19 21:57:37 rillig Exp $");
/* types and constants */
@@ -762,7 +762,7 @@ static void
LinkSource(GNode *pgn, GNode *cgn, Boolean isSpecial)
{
if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(pgn->cohorts))
- pgn = LstNode_Datum(Lst_Last(pgn->cohorts));
+ pgn = pgn->cohorts->last->datum;
Lst_Append(pgn->children, cgn);
pgn->unmade++;
Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.194 src/usr.bin/make/suff.c:1.195
--- src/usr.bin/make/suff.c:1.194 Mon Oct 19 21:38:10 2020
+++ src/usr.bin/make/suff.c Mon Oct 19 21:57:37 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.194 2020/10/19 21:38:10 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.195 2020/10/19 21:57:37 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.194 2020/10/19 21:38:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.195 2020/10/19 21:57:37 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -369,7 +369,7 @@ SuffInsert(SuffList *l, Suff *s)
Suff *s2 = NULL; /* the suffix descriptor in this element */
for (ln = l->first; ln != NULL; ln = ln->next) {
- s2 = LstNode_Datum(ln);
+ s2 = ln->datum;
if (s2->sNum >= s->sNum) {
break;
}
@@ -487,7 +487,7 @@ SuffParseTransform(const char *str, Suff
}
return FALSE;
}
- src = LstNode_Datum(srcLn);
+ src = srcLn->datum;
str2 = str + src->nameLen;
if (*str2 == '\0') {
single = src;
@@ -549,7 +549,7 @@ Suff_AddTransform(const char *line)
* free the commands themselves, because a given command can be
* attached to several different transformations.
*/
- gn = LstNode_Datum(ln);
+ gn = ln->datum;
Lst_Free(gn->commands);
Lst_Free(gn->children);
gn->commands = Lst_New();
@@ -586,7 +586,7 @@ void
Suff_EndTransform(GNode *gn)
{
if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(gn->cohorts))
- gn = LstNode_Datum(Lst_Last(gn->cohorts));
+ gn = gn->cohorts->last->datum;
if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(gn->commands) &&
Lst_IsEmpty(gn->children))
{
@@ -811,7 +811,7 @@ Suff_DoPaths(void)
inLibs = Lst_New();
for (ln = sufflist->first; ln != NULL; ln = ln->next) {
- Suff *s = LstNode_Datum(ln);
+ Suff *s = ln->datum;
if (!Lst_IsEmpty(s->searchPath)) {
#ifdef INCLUDES
if (s->flags & SUFF_INCLUDE) {
@@ -961,7 +961,7 @@ SuffRemoveSrc(SrcList *l)
#endif
while ((ln = Lst_Next(l)) != NULL) {
- Src *s = LstNode_Datum(ln);
+ Src *s = ln->datum;
if (s->children == 0) {
free(s->file);
if (!s->parent)
@@ -1083,7 +1083,7 @@ SuffFindCmds(Src *targ, SrcList *slst)
Lst_Close(t->children);
return NULL;
}
- s = LstNode_Datum(gln);
+ s = gln->datum;
if (s->type & OP_OPTIONAL && Lst_IsEmpty(t->commands)) {
/*
@@ -1164,7 +1164,7 @@ SuffFindCmds(Src *targ, SrcList *slst)
static void
SuffExpandChildren(GNodeListNode *cln, GNode *pgn)
{
- GNode *cgn = LstNode_Datum(cln);
+ GNode *cgn = cln->datum;
GNode *gn; /* New source 8) */
char *cp; /* Expanded value */
@@ -1317,7 +1317,7 @@ SuffExpandChildren(GNodeListNode *cln, G
static void
SuffExpandWildcards(GNodeListNode *cln, GNode *pgn)
{
- GNode *cgn = LstNode_Datum(cln);
+ GNode *cgn = cln->datum;
StringList *explist;
if (!Dir_HasWildcards(cgn->name))
@@ -1383,7 +1383,7 @@ Suff_FindPath(GNode* gn)
SUFF_DEBUG1("Wildcard expanding \"%s\"...", gn->name);
if (ln != NULL)
- suff = LstNode_Datum(ln);
+ suff = ln->datum;
/* XXX: Here we can save the suffix so we don't have to do this again */
}
@@ -1447,14 +1447,14 @@ SuffApplyTransform(GNode *tGn, GNode *sG
return FALSE;
}
- gn = LstNode_Datum(ln);
+ gn = ln->datum;
SUFF_DEBUG3("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name);
/*
* Record last child for expansion purposes
*/
- ln = Lst_Last(tGn->children);
+ ln = tGn->children->last;
/*
* Pass the buck to Make_HandleUse to apply the rule
@@ -1569,7 +1569,7 @@ SuffFindArchiveDeps(GNode *gn, SrcList *
* Now we've got the important local variables set, expand any sources
* that still contain variables or wildcards in their names.
*/
- for (ln = Lst_First(gn->children); ln != NULL; ln = nln) {
+ for (ln = gn->children->first; ln != NULL; ln = nln) {
nln = ln->next;
SuffExpandChildren(ln, gn);
}
@@ -1594,7 +1594,7 @@ SuffFindArchiveDeps(GNode *gn, SrcList *
/*
* Got one -- apply it
*/
- Suff *suff = LstNode_Datum(ln);
+ Suff *suff = ln->datum;
if (!SuffApplyTransform(gn, mem, suff, ms)) {
SUFF_DEBUG2("\tNo transformation from %s -> %s\n",
ms->name, suff->name);
@@ -1658,7 +1658,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *s
/*
* Begin at the beginning...
*/
- ln = Lst_First(sufflist);
+ ln = sufflist->first;
srcs = Lst_New();
targs = Lst_New();
@@ -1699,7 +1699,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *s
*/
targ = bmake_malloc(sizeof(Src));
targ->file = bmake_strdup(gn->name);
- targ->suff = LstNode_Datum(ln);
+ targ->suff = ln->datum;
targ->suff->refCount++;
targ->node = gn;
targ->parent = NULL;
@@ -1776,7 +1776,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *s
* for setting the local variables.
*/
if (!Lst_IsEmpty(targs)) {
- targ = LstNode_Datum(Lst_First(targs));
+ targ = targs->first->datum;
} else {
targ = NULL;
}
@@ -1799,7 +1799,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *s
* Now we've got the important local variables set, expand any sources
* that still contain variables or wildcards in their names.
*/
- for (ln = Lst_First(gn->children); ln != NULL; ln = nln) {
+ for (ln = gn->children->first; ln != NULL; ln = nln) {
nln = ln->next;
SuffExpandChildren(ln, gn);
}