Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): revert migration from Lst_ForEachUntil...
details: https://anonhg.NetBSD.org/src/rev/102722960302
branches: trunk
changeset: 1014580:102722960302
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Sep 26 17:39:45 2020 +0000
description:
make(1): revert migration from Lst_ForEachUntil to Lst_ForEach
There is a crucial difference between these functions, in that
Lst_ForEachUntil can cope with a few concurrent modifications while
iterating over the list. This is something that Lst_ForEach doesn't do.
This difference led to a crash very early in NetBSD's build.sh.
diffstat:
usr.bin/make/job.c | 6 +-
usr.bin/make/main.c | 6 +-
usr.bin/make/make.c | 130 ++++++++++++++++++++++++++++++++++++--------------
usr.bin/make/parse.c | 7 +-
usr.bin/make/targ.c | 16 +++--
5 files changed, 114 insertions(+), 51 deletions(-)
diffs (truncated from 480 to 300 lines):
diff -r 6062629b9aa6 -r 102722960302 usr.bin/make/job.c
--- a/usr.bin/make/job.c Sat Sep 26 17:15:20 2020 +0000
+++ b/usr.bin/make/job.c Sat Sep 26 17:39:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.241 2020/09/26 17:15:20 rillig Exp $ */
+/* $NetBSD: job.c,v 1.242 2020/09/26 17:39:45 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.241 2020/09/26 17:15:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.242 2020/09/26 17:39:45 rillig Exp $");
# define STATIC static
@@ -655,7 +655,7 @@
* jobp job for which to print it
*
* Results:
- * 0, unless the command was "..."
+ * Always 0, unless the command was "..."
*
* Side Effects:
* If the command begins with a '-' and the shell has no error control,
diff -r 6062629b9aa6 -r 102722960302 usr.bin/make/main.c
--- a/usr.bin/make/main.c Sat Sep 26 17:15:20 2020 +0000
+++ b/usr.bin/make/main.c Sat Sep 26 17:39:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.348 2020/09/26 17:15:20 rillig Exp $ */
+/* $NetBSD: main.c,v 1.349 2020/09/26 17:39:45 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.348 2020/09/26 17:15:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.349 2020/09/26 17:39:45 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 @@
static int
-addErrorCMD(void *cmdp, void *unused)
+addErrorCMD(void *cmdp, void *gnp)
{
if (cmdp == NULL)
return 1; /* stop */
diff -r 6062629b9aa6 -r 102722960302 usr.bin/make/make.c
--- a/usr.bin/make/make.c Sat Sep 26 17:15:20 2020 +0000
+++ b/usr.bin/make/make.c Sat Sep 26 17:39:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.147 2020/09/26 17:15:20 rillig Exp $ */
+/* $NetBSD: make.c,v 1.148 2020/09/26 17:39:45 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.147 2020/09/26 17:15:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.148 2020/09/26 17:39:45 rillig Exp $");
static unsigned int checked = 1;/* Sequence # to detect recursion */
static GNodeList *toBeMade; /* The current fringe of the graph. These
@@ -116,11 +116,14 @@
* 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 void MakeBuildParent(void *, void *);
+static int MakeBuildParent(void *, void *);
MAKE_ATTR_DEAD static void
make_abort(GNode *gn, int line)
@@ -375,11 +378,14 @@
* 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 void
+static int
MakeAddChild(void *gnp, void *lp)
{
GNode *gn = gnp;
@@ -391,6 +397,7 @@
gn->name, gn->cohort_num);
Lst_Enqueue(l, gn);
}
+ return 0;
}
/*-
@@ -402,12 +409,15 @@
* 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 void
+static int
MakeFindChild(void *gnp, void *pgnp)
{
GNode *gn = (GNode *)gnp;
@@ -416,6 +426,8 @@
(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
@@ -485,20 +497,28 @@
pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_USEBEFORE|OP_TRANSFORM);
}
-/* 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.
+/*-
+ *-----------------------------------------------------------------------
+ * 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.
*
* 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 void
+static int
MakeHandleUse(void *cgnp, void *pgnp)
{
GNode *cgn = (GNode *)cgnp;
@@ -510,7 +530,7 @@
cgn->type |= OP_MARK;
if ((cgn->type & (OP_USE|OP_USEBEFORE)) == 0)
- return;
+ return 0;
if (unmarked)
Make_HandleUse(cgn, pgn);
@@ -526,6 +546,7 @@
Lst_Remove(pgn->children, ln);
pgn->unmade--;
}
+ return 0;
}
@@ -695,7 +716,7 @@
parents = centurion->parents;
/* If this was a .ORDER node, schedule the RHS */
- Lst_ForEach(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade));
+ Lst_ForEachUntil(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade));
/* Now mark all the parents as having one less unmade child */
Lst_Open(parents);
@@ -950,6 +971,23 @@
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)
{
@@ -1003,26 +1041,22 @@
}
/* When a .ORDER LHS node completes we do this on each RHS */
-static void
+static int
MakeBuildParent(void *v_pn, void *toBeMade_next)
{
GNode *pn = v_pn;
if (pn->made != DEFERRED)
- return;
+ return 0;
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)
{
@@ -1105,7 +1139,25 @@
return FALSE;
}
-static void
+/*-
+ *-----------------------------------------------------------------------
+ * 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
MakePrintStatusOrder(void *ognp, void *gnp)
{
GNode *ogn = ognp;
@@ -1113,7 +1165,7 @@
if (!(ogn->flags & REMAKE) || ogn->made > REQUESTED)
/* not waiting for this one */
- return;
+ return 0;
printf(" `%s%s' has .ORDER dependency against %s%s ",
gn->name, gn->cohort_num, ogn->name, ogn->cohort_num);
@@ -1124,14 +1176,9 @@
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.
- *
Home |
Main Index |
Thread Index |
Old Index