=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/make.c,v retrieving revision 1.74 retrieving revision 1.75 diff -c -r1.74 -r1.75 *** src/usr.bin/make/make.c 2019/12/21 15:28:17 1.74 --- src/usr.bin/make/make.c 2019/12/21 15:29:25 1.75 *************** *** 1,4 **** ! /* $OpenBSD: make.c,v 1.74 2019/12/21 15:28:17 espie Exp $ */ /* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: make.c,v 1.75 2019/12/21 15:29:25 espie Exp $ */ /* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */ /* *************** *** 51,57 **** * various bookkeeping chores like finding the * youngest child of the parent, filling * the IMPSRC context variable, etc. It will ! * place the parent on the toBeMade queue if it * should be. * */ --- 51,57 ---- * various bookkeeping chores like finding the * youngest child of the parent, filling * the IMPSRC context variable, etc. It will ! * place the parent on the to_build queue if it * should be. * */ *************** *** 89,95 **** /* The current fringe of the graph. These are nodes which await examination by * MakeOODate. It is added to by Make_Update and subtracted from by * MakeStartJobs */ ! static struct growableArray toBeMade; /* Hold back on nodes where equivalent stuff is already building... */ static struct growableArray heldBack; --- 89,95 ---- /* The current fringe of the graph. These are nodes which await examination by * MakeOODate. It is added to by Make_Update and subtracted from by * MakeStartJobs */ ! static struct growableArray to_build; /* Hold back on nodes where equivalent stuff is already building... */ static struct growableArray heldBack; *************** *** 110,116 **** static bool try_to_make_node(GNode *); static void add_targets_to_make(Lst); ! static bool has_unmade_predecessor(GNode *); static void requeue_successors(GNode *); static void random_setup(void); --- 110,116 ---- static bool try_to_make_node(GNode *); static void add_targets_to_make(Lst); ! static bool has_predecessor_left_to_build(GNode *); static void requeue_successors(GNode *); static void random_setup(void); *************** *** 120,126 **** bool no_jobs_left() { ! return Array_IsEmpty(&toBeMade); } static void --- 120,126 ---- bool no_jobs_left() { ! return Array_IsEmpty(&to_build); } static void *************** *** 157,171 **** } static bool ! has_unmade_predecessor(GNode *gn) { LstNode ln; ! if (Lst_IsEmpty(&gn->preds)) return false; ! for (ln = Lst_First(&gn->preds); ln != NULL; ln = Lst_Adv(ln)) { GNode *pgn = Lst_Datum(ln); if (pgn->must_make && pgn->built_status == UNKNOWN) { --- 157,171 ---- } static bool ! has_predecessor_left_to_build(GNode *gn) { LstNode ln; ! if (Lst_IsEmpty(&gn->predecessors)) return false; ! for (ln = Lst_First(&gn->predecessors); ln != NULL; ln = Lst_Adv(ln)) { GNode *pgn = Lst_Datum(ln); if (pgn->must_make && pgn->built_status == UNKNOWN) { *************** *** 183,197 **** { LstNode ln; /* Deal with successor nodes. If any is marked for making and has an ! * unmade count of 0, has not been made and isn't in the examination ! * queue, it means we need to place it in the queue as it restrained ! * itself before. */ for (ln = Lst_First(&gn->successors); ln != NULL; ln = Lst_Adv(ln)) { GNode *succ = Lst_Datum(ln); ! if (succ->must_make && succ->unmade == 0 && succ->built_status == UNKNOWN) ! Array_PushNew(&toBeMade, succ); } } --- 183,197 ---- { LstNode ln; /* Deal with successor nodes. If any is marked for making and has an ! * children_left count of 0, has not been made and isn't in the ! * examination queue, it means we need to place it in the queue as ! * it restrained itself before. */ for (ln = Lst_First(&gn->successors); ln != NULL; ln = Lst_Adv(ln)) { GNode *succ = Lst_Datum(ln); ! if (succ->must_make && succ->children_left == 0 && succ->built_status == UNKNOWN) ! Array_PushNew(&to_build, succ); } } *************** *** 208,214 **** if (DEBUG(HELDJOBS)) printf("%s finished, releasing: %s\n", gn->name, heldBack.a[i]->name); ! Array_Push(&toBeMade, heldBack.a[i]); continue; } heldBack.a[j] = heldBack.a[i]; --- 208,214 ---- if (DEBUG(HELDJOBS)) printf("%s finished, releasing: %s\n", gn->name, heldBack.a[i]->name); ! Array_Push(&to_build, heldBack.a[i]); continue; } heldBack.a[j] = heldBack.a[i]; *************** *** 227,236 **** * Always returns 0 * * Side Effects: ! * The unmade field of pgn is decremented and pgn may be placed on ! * the toBeMade queue if this field becomes 0. * ! * If the child was made, the parent's childMade field will be set to * true *----------------------------------------------------------------------- */ --- 227,236 ---- * Always returns 0 * * Side Effects: ! * The children_left field of pgn is decremented and pgn may be placed on ! * the to_build queue if this field becomes 0. * ! * If the child got built, the parent's child_rebuilt field will be set to * true *----------------------------------------------------------------------- */ *************** *** 272,298 **** for (ln = Lst_First(&cgn->parents); ln != NULL; ln = Lst_Adv(ln)) { pgn = Lst_Datum(ln); /* SIB: there should be a siblings loop there */ ! pgn->unmade--; if (pgn->must_make) { if (DEBUG(MAKE)) printf("%s--=%d ", ! pgn->name, pgn->unmade); if ( ! (cgn->type & (OP_EXEC|OP_USE))) { if (cgn->built_status == REBUILT) ! pgn->childMade = true; (void)Make_TimeStamp(pgn, cgn); } ! if (pgn->unmade == 0) { /* ! * Queue the node up -- any unmade * predecessors will be dealt with in * MakeStartJobs. */ if (DEBUG(MAKE)) printf("QUEUING "); ! Array_Push(&toBeMade, pgn); ! } else if (pgn->unmade < 0) { Error("Child %s discovered graph cycles through %s", cgn->name, pgn->name); } } --- 272,298 ---- for (ln = Lst_First(&cgn->parents); ln != NULL; ln = Lst_Adv(ln)) { pgn = Lst_Datum(ln); /* SIB: there should be a siblings loop there */ ! pgn->children_left--; if (pgn->must_make) { if (DEBUG(MAKE)) printf("%s--=%d ", ! pgn->name, pgn->children_left); if ( ! (cgn->type & (OP_EXEC|OP_USE))) { if (cgn->built_status == REBUILT) ! pgn->child_rebuilt = true; (void)Make_TimeStamp(pgn, cgn); } ! if (pgn->children_left == 0) { /* ! * Queue the node up -- any yet-to-build * predecessors will be dealt with in * MakeStartJobs. */ if (DEBUG(MAKE)) printf("QUEUING "); ! Array_Push(&to_build, pgn); ! } else if (pgn->children_left < 0) { Error("Child %s discovered graph cycles through %s", cgn->name, pgn->name); } } *************** *** 314,324 **** return false; } ! if (gn->unmade != 0) { if (DEBUG(MAKE)) ! printf(" Requeuing (%d)\n", gn->unmade); add_targets_to_make(&gn->children); ! Array_Push(&toBeMade, gn); return false; } if (has_been_built(gn)) { --- 314,324 ---- return false; } ! if (gn->children_left != 0) { if (DEBUG(MAKE)) ! printf(" Requeuing (%d)\n", gn->children_left); add_targets_to_make(&gn->children); ! Array_Push(&to_build, gn); return false; } if (has_been_built(gn)) { *************** *** 326,341 **** printf(" already made\n"); return false; } ! if (has_unmade_predecessor(gn)) { if (DEBUG(MAKE)) printf(" Dropping for now\n"); return false; } /* SIB: this is where there should be a siblings loop */ ! if (gn->unmade != 0) { if (DEBUG(MAKE)) ! printf(" Requeuing (after deps: %d)\n", gn->unmade); add_targets_to_make(&gn->children); return false; } --- 326,342 ---- printf(" already made\n"); return false; } ! if (has_predecessor_left_to_build(gn)) { if (DEBUG(MAKE)) printf(" Dropping for now\n"); return false; } /* SIB: this is where there should be a siblings loop */ ! if (gn->children_left != 0) { if (DEBUG(MAKE)) ! printf(" Requeuing (after deps: %d)\n", ! gn->children_left); add_targets_to_make(&gn->children); return false; } *************** *** 407,413 **** * 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. *----------------------------------------------------------------------- */ --- 408,414 ---- * returns true. At all other times, this function returns false. * * Side Effects: ! * Nodes are removed from the to_build queue and job table slots * are filled. *----------------------------------------------------------------------- */ *************** *** 416,422 **** { GNode *gn; ! while (can_start_job() && (gn = Array_Pop(&toBeMade)) != NULL) { if (try_to_make_node(gn)) return true; } --- 417,423 ---- { GNode *gn; ! while (can_start_job() && (gn = Array_Pop(&to_build)) != NULL) { if (try_to_make_node(gn)) return true; } *************** *** 429,435 **** GNode *gn = gnp; if (gn->built_status == UPTODATE) { printf("`%s' is up to date.\n", gn->name); ! } else if (gn->unmade != 0) { printf("`%s' not remade because of errors.\n", gn->name); } } --- 430,436 ---- GNode *gn = gnp; if (gn->built_status == UPTODATE) { printf("`%s' is up to date.\n", gn->name); ! } else if (gn->children_left != 0) { printf("`%s' not remade because of errors.\n", gn->name); } } *************** *** 454,460 **** Make_HandleUse(cgn, pgn); } ! /* Add stuff to the toBeMade queue. we try to sort things so that stuff * that can be done directly is done right away. This won't be perfect, * since some dependencies are only discovered later (e.g., SuffFindDeps). */ --- 455,461 ---- Make_HandleUse(cgn, pgn); } ! /* Add stuff to the to_build queue. we try to sort things so that stuff * that can be done directly is done right away. This won't be perfect, * since some dependencies are only discovered later (e.g., SuffFindDeps). */ *************** *** 488,507 **** Suff_FindDeps(gn); expand_all_children(gn); ! if (gn->unmade != 0) { if (DEBUG(MAKE)) ! printf("%s: not queuing (%d unmade children)\n", ! gn->name, gn->unmade); Lst_ForEach(&gn->children, MakeAddChild, &examine); } else { if (DEBUG(MAKE)) printf("%s: queuing\n", gn->name); ! Array_Push(&toBeMade, gn); } } if (randomize_queue) ! randomize_garray(&toBeMade); } /*- --- 489,508 ---- Suff_FindDeps(gn); expand_all_children(gn); ! if (gn->children_left != 0) { if (DEBUG(MAKE)) ! printf("%s: not queuing (%d children left to build)\n", ! gn->name, gn->children_left); Lst_ForEach(&gn->children, MakeAddChild, &examine); } else { if (DEBUG(MAKE)) printf("%s: queuing\n", gn->name); ! Array_Push(&to_build, gn); } } if (randomize_queue) ! randomize_garray(&to_build); } /*- *************** *** 510,516 **** * Initialize the nodes to remake and the list of nodes which are * ready to be made by doing a breadth-first traversal of the graph * starting from the nodes in the given list. Once this traversal ! * is finished, all the 'leaves' of the graph are in the toBeMade * queue. * Using this queue and the Job module, work back up the graph, * calling on MakeStartJobs to keep the job table as full as --- 511,517 ---- * Initialize the nodes to remake and the list of nodes which are * ready to be made by doing a breadth-first traversal of the graph * starting from the nodes in the given list. Once this traversal ! * is finished, all the 'leaves' of the graph are in the to_build * queue. * Using this queue and the Job module, work back up the graph, * calling on MakeStartJobs to keep the job table as full as *************** *** 521,527 **** * * Side Effects: * The must_make field of all nodes involved in the creation of the given ! * targets is set to 1. The toBeMade list is set to contain all the * 'leaves' of these subgraphs. *----------------------------------------------------------------------- */ --- 522,528 ---- * * Side Effects: * The must_make field of all nodes involved in the creation of the given ! * targets is set to 1. The to_build list is set to contain all the * 'leaves' of these subgraphs. *----------------------------------------------------------------------- */ *************** *** 531,537 **** bool problem; /* errors occurred */ /* wild guess at initial sizes */ ! Array_Init(&toBeMade, 500); Array_Init(&examine, 150); Array_Init(&heldBack, 100); ohash_init(&targets, 10, &gnode_info); --- 532,538 ---- bool problem; /* errors occurred */ /* wild guess at initial sizes */ ! Array_Init(&to_build, 500); Array_Init(&examine, 150); Array_Init(&heldBack, 100); ohash_init(&targets, 10, &gnode_info); *************** *** 683,689 **** if (gn->built_status == UPTODATE) continue; ! if (gn->unmade != 0) { GNode *c; gn->in_cycle = true; --- 684,690 ---- if (gn->built_status == UPTODATE) continue; ! if (gn->children_left != 0) { GNode *c; gn->in_cycle = true;