Module Name: src
Committed By: rillig
Date: Sat Sep 26 16:55:58 UTC 2020
Modified Files:
src/usr.bin/make: job.c main.c make.c parse.c targ.c
Log Message:
make(1): replace a few Lst_ForEachUntil with simpler Lst_ForEach
To generate a diff of this commit:
cvs rdiff -u -r1.239 -r1.240 src/usr.bin/make/job.c
cvs rdiff -u -r1.346 -r1.347 src/usr.bin/make/main.c
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/make/make.c
cvs rdiff -u -r1.332 -r1.333 src/usr.bin/make/parse.c
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/make/targ.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/job.c
diff -u src/usr.bin/make/job.c:1.239 src/usr.bin/make/job.c:1.240
--- src/usr.bin/make/job.c:1.239 Sat Sep 26 16:00:12 2020
+++ src/usr.bin/make/job.c Sat Sep 26 16:55:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.239 2020/09/26 16:00:12 rillig Exp $ */
+/* $NetBSD: job.c,v 1.240 2020/09/26 16:55:58 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -140,7 +140,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.239 2020/09/26 16:00:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.240 2020/09/26 16:55:58 rillig Exp $");
# define STATIC static
@@ -655,7 +655,7 @@ JobFindPid(int pid, int status, Boolean
* jobp job for which to print it
*
* Results:
- * Always 0, unless the command was "..."
+ * 0, unless the command was "..."
*
* Side Effects:
* If the command begins with a '-' and the shell has no error control,
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.346 src/usr.bin/make/main.c:1.347
--- src/usr.bin/make/main.c:1.346 Sat Sep 26 16:00:12 2020
+++ src/usr.bin/make/main.c Sat Sep 26 16:55:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.346 2020/09/26 16:00:12 rillig Exp $ */
+/* $NetBSD: main.c,v 1.347 2020/09/26 16:55:58 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
#endif
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.346 2020/09/26 16:00:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.347 2020/09/26 16:55:58 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
The Regents of the University of California. All rights reserved.");
@@ -1969,7 +1969,7 @@ cached_realpath(const char *pathname, ch
static int
-addErrorCMD(void *cmdp, void *gnp)
+addErrorCMD(void *cmdp, void *unused)
{
if (cmdp == NULL)
return 1; /* stop */
Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.145 src/usr.bin/make/make.c:1.146
--- src/usr.bin/make/make.c:1.145 Sat Sep 26 16:00:12 2020
+++ src/usr.bin/make/make.c Sat Sep 26 16:55:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.145 2020/09/26 16:00:12 rillig Exp $ */
+/* $NetBSD: make.c,v 1.146 2020/09/26 16:55:58 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.145 2020/09/26 16:00:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.146 2020/09/26 16:55:58 rillig Exp $");
static unsigned int checked = 1;/* Sequence # to detect recursion */
static GNodeList *toBeMade; /* The current fringe of the graph. These
@@ -116,14 +116,11 @@ static GNodeList *toBeMade; /* The curre
* Make_Update and subtracted from by
* MakeStartJobs */
-static int MakeAddChild(void *, void *);
-static int MakeFindChild(void *, void *);
-static int MakeHandleUse(void *, void *);
static Boolean MakeStartJobs(void);
static int MakePrintStatus(void *, void *);
static int MakeCheckOrder(void *, void *);
static int MakeBuildChild(void *, void *);
-static int MakeBuildParent(void *, void *);
+static void MakeBuildParent(void *, void *);
MAKE_ATTR_DEAD static void
make_abort(GNode *gn, int line)
@@ -378,14 +375,11 @@ Make_OODate(GNode *gn)
* gnp the node to add
* lp the list to which to add it
*
- * Results:
- * Always returns 0
- *
* Side Effects:
* The given list is extended
*-----------------------------------------------------------------------
*/
-static int
+static void
MakeAddChild(void *gnp, void *lp)
{
GNode *gn = gnp;
@@ -397,7 +391,6 @@ MakeAddChild(void *gnp, void *lp)
gn->name, gn->cohort_num);
Lst_Enqueue(l, gn);
}
- return 0;
}
/*-
@@ -409,15 +402,12 @@ MakeAddChild(void *gnp, void *lp)
* Input:
* gnp the node to find
*
- * Results:
- * Always returns 0
- *
* Side Effects:
* The path and mtime of the node and the cmgn of the parent are
* updated; the unmade children count of the parent is decremented.
*-----------------------------------------------------------------------
*/
-static int
+static void
MakeFindChild(void *gnp, void *pgnp)
{
GNode *gn = (GNode *)gnp;
@@ -426,8 +416,6 @@ MakeFindChild(void *gnp, void *pgnp)
(void)Dir_MTime(gn, 0);
Make_TimeStamp(pgn, gn);
pgn->unmade--;
-
- return 0;
}
/* Called by Make_Run and SuffApplyTransform on the downward pass to handle
@@ -497,28 +485,20 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_USEBEFORE|OP_TRANSFORM);
}
-/*-
- *-----------------------------------------------------------------------
- * MakeHandleUse --
- * Callback function for Lst_ForEachUntil, used by Make_Run on the downward
- * pass to handle .USE nodes. Should be called before the children
- * are enqueued to be looked at by MakeAddChild.
- * This function calls Make_HandleUse to copy the .USE node's commands,
- * type flags and children to the parent node.
+/* Callback function for Lst_ForEachUntil, used by Make_Run on the downward
+ * pass to handle .USE nodes. Should be called before the children
+ * are enqueued to be looked at by MakeAddChild.
+ * This function calls Make_HandleUse to copy the .USE node's commands,
+ * type flags and children to the parent node.
*
* Input:
* cgnp the child we've just examined
* pgnp the current parent
*
- * Results:
- * returns 0.
- *
* Side Effects:
* After expansion, .USE child nodes are removed from the parent
- *
- *-----------------------------------------------------------------------
*/
-static int
+static void
MakeHandleUse(void *cgnp, void *pgnp)
{
GNode *cgn = (GNode *)cgnp;
@@ -530,7 +510,7 @@ MakeHandleUse(void *cgnp, void *pgnp)
cgn->type |= OP_MARK;
if ((cgn->type & (OP_USE|OP_USEBEFORE)) == 0)
- return 0;
+ return;
if (unmarked)
Make_HandleUse(cgn, pgn);
@@ -546,7 +526,6 @@ MakeHandleUse(void *cgnp, void *pgnp)
Lst_Remove(pgn->children, ln);
pgn->unmade--;
}
- return 0;
}
@@ -716,7 +695,7 @@ 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_ForEach(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade));
/* Now mark all the parents as having one less unmade child */
Lst_Open(parents);
@@ -971,23 +950,6 @@ Make_DoAllVar(GNode *gn)
gn->flags |= DONE_ALLSRC;
}
-/*-
- *-----------------------------------------------------------------------
- * MakeStartJobs --
- * Start as many jobs as possible.
- *
- * Results:
- * If the query flag was given to pmake, no job will be started,
- * but as soon as an out-of-date target is found, this function
- * returns TRUE. At all other times, this function returns FALSE.
- *
- * Side Effects:
- * Nodes are removed from the toBeMade queue and job table slots
- * are filled.
- *
- *-----------------------------------------------------------------------
- */
-
static int
MakeCheckOrder(void *v_bn, void *ignore MAKE_ATTR_UNUSED)
{
@@ -1041,22 +1003,26 @@ MakeBuildChild(void *v_cn, void *toBeMad
}
/* When a .ORDER LHS node completes we do this on each RHS */
-static int
+static void
MakeBuildParent(void *v_pn, void *toBeMade_next)
{
GNode *pn = v_pn;
if (pn->made != DEFERRED)
- return 0;
+ return;
if (MakeBuildChild(pn, toBeMade_next) == 0) {
/* Mark so that when this node is built we reschedule its parents */
pn->flags |= DONE_ORDER;
}
-
- return 0;
}
+/* Start as many jobs as possible, taking them from the toBeMade queue.
+ *
+ * If the query flag was given to pmake, no job will be started,
+ * but as soon as an out-of-date target is found, this function
+ * returns TRUE. At all other times, this function returns FALSE.
+ */
static Boolean
MakeStartJobs(void)
{
@@ -1139,25 +1105,7 @@ MakeStartJobs(void)
return FALSE;
}
-/*-
- *-----------------------------------------------------------------------
- * MakePrintStatus --
- * Print the status of a top-level node, viz. it being up-to-date
- * already or not created due to an error in a lower level.
- * Callback function for Make_Run via Lst_ForEachUntil.
- *
- * Input:
- * gnp Node to examine
- *
- * Results:
- * Always returns 0.
- *
- * Side Effects:
- * A message may be printed.
- *
- *-----------------------------------------------------------------------
- */
-static int
+static void
MakePrintStatusOrder(void *ognp, void *gnp)
{
GNode *ogn = ognp;
@@ -1165,7 +1113,7 @@ MakePrintStatusOrder(void *ognp, void *g
if (!(ogn->flags & REMAKE) || ogn->made > REQUESTED)
/* not waiting for this one */
- return 0;
+ return;
printf(" `%s%s' has .ORDER dependency against %s%s ",
gn->name, gn->cohort_num, ogn->name, ogn->cohort_num);
@@ -1176,9 +1124,14 @@ MakePrintStatusOrder(void *ognp, void *g
gn->name, gn->cohort_num, ogn->name, ogn->cohort_num);
GNode_FprintDetails(debug_file, "(", ogn, ")\n");
}
- return 0;
}
+/* Print the status of a top-level node, viz. it being up-to-date
+ * already or not created due to an error in a lower level.
+ *
+ * Input:
+ * gnp Node to examine
+ */
static int
MakePrintStatus(void *gnp, void *v_errors)
{
@@ -1210,7 +1163,7 @@ MakePrintStatus(void *gnp, void *v_error
GNode_FprintDetails(debug_file, " (", gn, ")!\n");
}
/* Most likely problem is actually caused by .ORDER */
- Lst_ForEachUntil(gn->order_pred, MakePrintStatusOrder, gn);
+ Lst_ForEach(gn->order_pred, MakePrintStatusOrder, gn);
break;
default:
/* Errors - already counted */
@@ -1316,37 +1269,26 @@ Make_ExpandUse(GNodeList *targs)
(void)Dir_MTime(gn, 0);
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
UnmarkChildren(gn);
- Lst_ForEachUntil(gn->children, MakeHandleUse, gn);
+ Lst_ForEach(gn->children, MakeHandleUse, gn);
if ((gn->type & OP_MADE) == 0)
Suff_FindDeps(gn);
else {
/* Pretend we made all this node's children */
- Lst_ForEachUntil(gn->children, MakeFindChild, gn);
+ Lst_ForEach(gn->children, MakeFindChild, gn);
if (gn->unmade != 0)
printf("Warning: %s%s still has %d unmade children\n",
gn->name, gn->cohort_num, gn->unmade);
}
if (gn->unmade != 0)
- Lst_ForEachUntil(gn->children, MakeAddChild, examine);
+ Lst_ForEach(gn->children, MakeAddChild, examine);
}
Lst_Free(examine);
}
-/*-
- *-----------------------------------------------------------------------
- * Make_ProcessWait --
- * Convert .WAIT nodes into dependencies
- *
- * Input:
- * targs the initial list of targets
- *
- *-----------------------------------------------------------------------
- */
-
-static int
+static void
link_parent(void *cnp, void *pnp)
{
GNode *cn = cnp;
@@ -1355,7 +1297,6 @@ link_parent(void *cnp, void *pnp)
Lst_Append(pn->children, cn);
Lst_Append(cn->parents, pn);
pn->unmade++;
- return 0;
}
/* Make the .WAIT node depend on the previous children */
@@ -1377,6 +1318,7 @@ add_wait_dependency(GNodeListNode *owln,
}
}
+/* Convert .WAIT nodes into dependencies. */
static void
Make_ProcessWait(GNodeList *targs)
{
@@ -1398,7 +1340,7 @@ Make_ProcessWait(GNodeList *targs)
/* Get it displayed in the diag dumps */
Lst_Prepend(Targ_List(), pgn);
- Lst_ForEachUntil(targs, link_parent, pgn);
+ Lst_ForEach(targs, link_parent, pgn);
/* Start building with the 'dummy' .MAIN' node */
MakeBuildChild(pgn, NULL);
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.332 src/usr.bin/make/parse.c:1.333
--- src/usr.bin/make/parse.c:1.332 Sat Sep 26 16:00:12 2020
+++ src/usr.bin/make/parse.c Sat Sep 26 16:55:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.332 2020/09/26 16:00:12 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.333 2020/09/26 16:55:58 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.332 2020/09/26 16:00:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.333 2020/09/26 16:55:58 rillig Exp $");
/* types and constants */
@@ -829,9 +829,6 @@ ParseLinkSrc(void *pgnp, void *data)
* gnp The node to which the operator is to be applied
* opp The operator to apply
*
- * Results:
- * Always 0
- *
* Side Effects:
* The type field of the node is altered to reflect any new bits in
* the op.
Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.98 src/usr.bin/make/targ.c:1.99
--- src/usr.bin/make/targ.c:1.98 Sat Sep 26 16:27:27 2020
+++ src/usr.bin/make/targ.c Sat Sep 26 16:55:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.98 2020/09/26 16:27:27 rillig Exp $ */
+/* $NetBSD: targ.c,v 1.99 2020/09/26 16:55:58 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
#include "dir.h"
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.98 2020/09/26 16:27:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.99 2020/09/26 16:55:58 rillig Exp $");
static GNodeList *allTargets; /* the list of all targets found so far */
#ifdef CLEANUP
@@ -129,7 +129,6 @@ static GNodeList *allGNs; /* List of all
#endif
static Hash_Table targets; /* a hash table of same */
-static int TargPrintOnlySrc(void *, void *);
#ifdef CLEANUP
static void TargFreeGN(void *);
#endif
@@ -436,7 +435,7 @@ made_name(GNodeMade made)
}
}
-static int
+static void
PrintNode(void *gnp, void *passp)
{
GNode *gn = gnp;
@@ -445,7 +444,7 @@ PrintNode(void *gnp, void *passp)
fprintf(debug_file, "# %s%s", gn->name, gn->cohort_num);
GNode_FprintDetails(debug_file, ", ", gn, "\n");
if (gn->flags == 0)
- return 0;
+ return;
if (!OP_NOP(gn->type)) {
fprintf(debug_file, "#\n");
@@ -494,10 +493,9 @@ PrintNode(void *gnp, void *passp)
Targ_PrintCmds(gn);
fprintf(debug_file, "\n\n");
if (gn->type & OP_DOUBLEDEP) {
- Lst_ForEachUntil(gn->cohorts, PrintNode, passp);
+ Lst_ForEach(gn->cohorts, PrintNode, passp);
}
}
- return 0;
}
/* Print the contents of a node. */
@@ -510,24 +508,22 @@ Targ_PrintNode(GNode *gn, int pass)
void
Targ_PrintNodes(GNodeList *gnodes, int pass)
{
- Lst_ForEachUntil(gnodes, PrintNode, &pass);
+ Lst_ForEach(gnodes, PrintNode, &pass);
}
/* Print only those targets that are just a source.
* The name of each file is printed, preceded by #\t. */
-static int
+static void
TargPrintOnlySrc(void *gnp, void *dummy MAKE_ATTR_UNUSED)
{
GNode *gn = (GNode *)gnp;
if (!OP_NOP(gn->type))
- return 0;
+ return;
fprintf(debug_file, "#\t%s [%s]",
gn->name, gn->path ? gn->path : gn->name);
Targ_PrintType(gn->type);
fprintf(debug_file, "\n");
-
- return 0;
}
/* Input:
@@ -539,10 +535,10 @@ void
Targ_PrintGraph(int pass)
{
fprintf(debug_file, "#*** Input graph:\n");
- Lst_ForEachUntil(allTargets, PrintNode, &pass);
+ Lst_ForEach(allTargets, PrintNode, &pass);
fprintf(debug_file, "\n\n");
fprintf(debug_file, "#\n# Files that are only sources:\n");
- Lst_ForEachUntil(allTargets, TargPrintOnlySrc, NULL);
+ Lst_ForEach(allTargets, TargPrintOnlySrc, NULL);
fprintf(debug_file, "#*** Global Variables:\n");
Var_Dump(VAR_GLOBAL);
fprintf(debug_file, "#*** Command-line Variables:\n");