Tue Nov 24 22:45:24 2020 UTC ()
make(1): inline Lst_ForEachUntil in MakeStartJobs


(rillig)
diff -r1.212 -r1.213 src/usr.bin/make/make.c

cvs diff -r1.212 -r1.213 src/usr.bin/make/make.c (expand / switch to unified diff)

--- src/usr.bin/make/make.c 2020/11/24 22:32:18 1.212
+++ src/usr.bin/make/make.c 2020/11/24 22:45:24 1.213
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: make.c,v 1.212 2020/11/24 22:32:18 rillig Exp $ */ 1/* $NetBSD: make.c,v 1.213 2020/11/24 22:45:24 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -92,27 +92,27 @@ @@ -92,27 +92,27 @@
92 * GNode_IsOODate Determine if a target is out-of-date. 92 * GNode_IsOODate Determine if a target is out-of-date.
93 * 93 *
94 * Make_HandleUse See if a child is a .USE node for a parent 94 * Make_HandleUse See if a child is a .USE node for a parent
95 * and perform the .USE actions if so. 95 * and perform the .USE actions if so.
96 * 96 *
97 * Make_ExpandUse Expand .USE nodes 97 * Make_ExpandUse Expand .USE nodes
98 */ 98 */
99 99
100#include "make.h" 100#include "make.h"
101#include "dir.h" 101#include "dir.h"
102#include "job.h" 102#include "job.h"
103 103
104/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */ 104/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */
105MAKE_RCSID("$NetBSD: make.c,v 1.212 2020/11/24 22:32:18 rillig Exp $"); 105MAKE_RCSID("$NetBSD: make.c,v 1.213 2020/11/24 22:45:24 rillig Exp $");
106 106
107/* Sequence # to detect recursion. */ 107/* Sequence # to detect recursion. */
108static unsigned int checked_seqno = 1; 108static unsigned int checked_seqno = 1;
109 109
110/* The current fringe of the graph. 110/* The current fringe of the graph.
111 * These are nodes which await examination by MakeOODate. 111 * These are nodes which await examination by MakeOODate.
112 * It is added to by Make_Update and subtracted from by MakeStartJobs */ 112 * It is added to by Make_Update and subtracted from by MakeStartJobs */
113static GNodeList *toBeMade; 113static GNodeList *toBeMade;
114 114
115static int MakeBuildParent(void *, void *); 115static int MakeBuildParent(void *, void *);
116 116
117void 117void
118debug_printf(const char *fmt, ...) 118debug_printf(const char *fmt, ...)
@@ -935,27 +935,36 @@ MakeStartJobs(void) @@ -935,27 +935,36 @@ MakeStartJobs(void)
935 /* We've already looked at this node since a job finished... */ 935 /* We've already looked at this node since a job finished... */
936 DEBUG2(MAKE, "already checked %s%s\n", gn->name, gn->cohort_num); 936 DEBUG2(MAKE, "already checked %s%s\n", gn->name, gn->cohort_num);
937 gn->made = DEFERRED; 937 gn->made = DEFERRED;
938 continue; 938 continue;
939 } 939 }
940 gn->checked_seqno = checked_seqno; 940 gn->checked_seqno = checked_seqno;
941 941
942 if (gn->unmade != 0) { 942 if (gn->unmade != 0) {
943 /* 943 /*
944 * We can't build this yet, add all unmade children to toBeMade, 944 * We can't build this yet, add all unmade children to toBeMade,
945 * just before the current first element. 945 * just before the current first element.
946 */ 946 */
947 gn->made = DEFERRED; 947 gn->made = DEFERRED;
948 Lst_ForEachUntil(gn->children, MakeBuildChild, toBeMade->first); 948
 949 {
 950 GNodeListNode *firstToBeMade = toBeMade->first;
 951 GNodeListNode *ln;
 952
 953 for (ln = gn->children->first; ln != NULL; ln = ln->next)
 954 if (MakeBuildChild(ln->datum, firstToBeMade) != 0)
 955 break;
 956 }
 957
949 /* and drop this node on the floor */ 958 /* and drop this node on the floor */
950 DEBUG2(MAKE, "dropped %s%s\n", gn->name, gn->cohort_num); 959 DEBUG2(MAKE, "dropped %s%s\n", gn->name, gn->cohort_num);
951 continue; 960 continue;
952 } 961 }
953 962
954 gn->made = BEINGMADE; 963 gn->made = BEINGMADE;
955 if (GNode_IsOODate(gn)) { 964 if (GNode_IsOODate(gn)) {
956 DEBUG0(MAKE, "out-of-date\n"); 965 DEBUG0(MAKE, "out-of-date\n");
957 if (opts.queryFlag) 966 if (opts.queryFlag)
958 return TRUE; 967 return TRUE;
959 Make_DoAllVar(gn); 968 Make_DoAllVar(gn);
960 Job_Make(gn); 969 Job_Make(gn);
961 have_token = FALSE; 970 have_token = FALSE;