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): replace a few Lst_ForEachUntil with si...
details: https://anonhg.NetBSD.org/src/rev/c58a39e3184f
branches: trunk
changeset: 939387:c58a39e3184f
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Sep 26 16:55:58 2020 +0000
description:
make(1): replace a few Lst_ForEachUntil with simpler Lst_ForEach
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 | 24 +++-----
5 files changed, 54 insertions(+), 119 deletions(-)
diffs (truncated from 507 to 300 lines):
diff -r 894e7a15d00c -r c58a39e3184f usr.bin/make/job.c
--- a/usr.bin/make/job.c Sat Sep 26 16:41:42 2020 +0000
+++ b/usr.bin/make/job.c Sat Sep 26 16:55:58 2020 +0000
@@ -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 @@
* 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,
diff -r 894e7a15d00c -r c58a39e3184f usr.bin/make/main.c
--- a/usr.bin/make/main.c Sat Sep 26 16:41:42 2020 +0000
+++ b/usr.bin/make/main.c Sat Sep 26 16:55:58 2020 +0000
@@ -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 @@
static int
-addErrorCMD(void *cmdp, void *gnp)
+addErrorCMD(void *cmdp, void *unused)
{
if (cmdp == NULL)
return 1; /* stop */
diff -r 894e7a15d00c -r c58a39e3184f usr.bin/make/make.c
--- a/usr.bin/make/make.c Sat Sep 26 16:41:42 2020 +0000
+++ b/usr.bin/make/make.c Sat Sep 26 16:55:58 2020 +0000
@@ -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 @@
* 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 @@
* 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 @@
gn->name, gn->cohort_num);
Lst_Enqueue(l, gn);
}
- return 0;
}
/*-
@@ -409,15 +402,12 @@
* 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 @@
(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 @@
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 @@
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 @@
Lst_Remove(pgn->children, ln);
pgn->unmade--;
}
- return 0;
}
@@ -716,7 +695,7 @@
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 @@
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 @@
}
/* 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 @@
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 @@
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 @@
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