Module Name: src Committed By: rillig Date: Sat Sep 26 17:15:20 UTC 2020
Modified Files: src/usr.bin/make: dir.c job.c lst.c lst.h main.c make.c meta.c suff.c targ.c Log Message: make(1): inline and remove LstNode_Prev and LstNode_Next These functions made the code larger than necessary. The prev and next fields are published intentionally since navigating in a doubly-linked list is simple to do and there is no need to wrap this in a layer of function calls, not even syntactically. (On the execution level, the function calls had been inlined anyway.) To generate a diff of this commit: cvs rdiff -u -r1.147 -r1.148 src/usr.bin/make/dir.c cvs rdiff -u -r1.240 -r1.241 src/usr.bin/make/job.c cvs rdiff -u -r1.71 -r1.72 src/usr.bin/make/lst.c cvs rdiff -u -r1.68 -r1.69 src/usr.bin/make/lst.h cvs rdiff -u -r1.347 -r1.348 src/usr.bin/make/main.c cvs rdiff -u -r1.146 -r1.147 src/usr.bin/make/make.c cvs rdiff -u -r1.119 -r1.120 src/usr.bin/make/meta.c cvs rdiff -u -r1.168 -r1.169 src/usr.bin/make/suff.c cvs rdiff -u -r1.100 -r1.101 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/dir.c diff -u src/usr.bin/make/dir.c:1.147 src/usr.bin/make/dir.c:1.148 --- src/usr.bin/make/dir.c:1.147 Fri Sep 25 06:49:13 2020 +++ src/usr.bin/make/dir.c Sat Sep 26 17:15:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.147 2020/09/25 06:49:13 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.148 2020/09/26 17:15:20 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -134,7 +134,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.147 2020/09/25 06:49:13 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.148 2020/09/26 17:15:20 rillig Exp $"); #define DIR_DEBUG0(fmt) \ if (!DEBUG(DIR)) (void) 0; else fprintf(debug_file, fmt) @@ -1705,10 +1705,9 @@ void Dir_Concat(SearchPath *path1, SearchPath *path2) { SearchPathNode *ln; - CachedDir *dir; - for (ln = Lst_First(path2); ln != NULL; ln = LstNode_Next(ln)) { - dir = LstNode_Datum(ln); + for (ln = path2->first; ln != NULL; ln = ln->next) { + CachedDir *dir = ln->datum; if (Lst_FindDatum(path1, dir) == NULL) { dir->refCount += 1; Lst_Append(path1, dir); @@ -1746,8 +1745,8 @@ void Dir_PrintPath(SearchPath *path) { SearchPathNode *node; - for (node = Lst_First(path); node != NULL; node = LstNode_Next(node)) { - const CachedDir *dir = LstNode_Datum(node); + for (node = path->first; node != NULL; node = node->next) { + const CachedDir *dir = node->datum; fprintf(debug_file, "%s ", dir->name); } } Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.240 src/usr.bin/make/job.c:1.241 --- src/usr.bin/make/job.c:1.240 Sat Sep 26 16:55:58 2020 +++ src/usr.bin/make/job.c Sat Sep 26 17:15:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.240 2020/09/26 16:55:58 rillig Exp $ */ +/* $NetBSD: job.c,v 1.241 2020/09/26 17:15:20 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.240 2020/09/26 16:55:58 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.241 2020/09/26 17:15:20 rillig Exp $"); # define STATIC static @@ -689,7 +689,7 @@ JobPrintCommand(void *cmdp, void *jobp) job->node->type |= OP_SAVE_CMDS; if ((job->flags & JOB_IGNDOTS) == 0) { StringListNode *dotsNode = Lst_FindDatum(job->node->commands, cmd); - job->tailCmds = dotsNode != NULL ? LstNode_Next(dotsNode) : NULL; + job->tailCmds = dotsNode != NULL ? dotsNode->next : NULL; return 1; } return 0; @@ -884,8 +884,8 @@ JobSaveCommands(Job *job) { StringListNode *node; - for (node = job->tailCmds; node != NULL; node = LstNode_Next(node)) { - char *cmd = LstNode_Datum(node); + for (node = job->tailCmds; node != NULL; node = node->next) { + const char *cmd = node->datum; char *expanded_cmd; /* XXX: This Var_Subst is only intended to expand the dynamic * variables such as .TARGET, .IMPSRC. It is not intended to Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.71 src/usr.bin/make/lst.c:1.72 --- src/usr.bin/make/lst.c:1.71 Fri Sep 25 04:18:11 2020 +++ src/usr.bin/make/lst.c Sat Sep 26 17:15:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.71 2020/09/25 04:18:11 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.72 2020/09/26 17:15:20 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -34,7 +34,7 @@ #include "make.h" -MAKE_RCSID("$NetBSD: lst.c,v 1.71 2020/09/25 04:18:11 rillig Exp $"); +MAKE_RCSID("$NetBSD: lst.c,v 1.72 2020/09/26 17:15:20 rillig Exp $"); /* Allocate and initialize a list node. * @@ -290,8 +290,7 @@ Lst_Find(List *list, LstFindProc match, /* Return the first node from the list, starting at the given node, for which * the match function returns TRUE, or NULL if none of the nodes matches. * - * The start node may be NULL, in which case nothing is found. This allows - * for passing Lst_First or LstNode_Next as the start node. */ + * The start node may be NULL, in which case nothing is found. */ ListNode * Lst_FindFrom(List *list, ListNode *node, LstFindProc match, const void *matchArgs) { Index: src/usr.bin/make/lst.h diff -u src/usr.bin/make/lst.h:1.68 src/usr.bin/make/lst.h:1.69 --- src/usr.bin/make/lst.h:1.68 Fri Sep 25 15:54:50 2020 +++ src/usr.bin/make/lst.h Sat Sep 26 17:15:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.h,v 1.68 2020/09/25 15:54:50 rillig Exp $ */ +/* $NetBSD: lst.h,v 1.69 2020/09/26 17:15:20 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -88,8 +88,8 @@ typedef struct List List; typedef struct ListNode ListNode; struct ListNode { - ListNode *prev; /* previous element in list */ - ListNode *next; /* next in list */ + ListNode *prev; /* previous node in list, or NULL */ + ListNode *next; /* next node in list, or NULL */ uint8_t priv_useCount; /* Count of functions using the node. * node may not be deleted until count * goes to 0 */ @@ -175,12 +175,6 @@ void Lst_MoveAll(List *, List *); /* Node-specific functions */ -/* Return the successor of the node, or NULL. */ -static inline MAKE_ATTR_UNUSED ListNode * -LstNode_Next(ListNode *node) { return node->next; } -/* Return the predecessor of the node, or NULL. */ -static inline MAKE_ATTR_UNUSED ListNode * -LstNode_Prev(ListNode *node) { return node->prev; } /* Return the datum of the node. Usually not NULL. */ static inline MAKE_ATTR_UNUSED void * LstNode_Datum(ListNode *node) { return node->datum; } Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.347 src/usr.bin/make/main.c:1.348 --- src/usr.bin/make/main.c:1.347 Sat Sep 26 16:55:58 2020 +++ src/usr.bin/make/main.c Sat Sep 26 17:15:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.347 2020/09/26 16:55:58 rillig Exp $ */ +/* $NetBSD: main.c,v 1.348 2020/09/26 17:15:20 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.347 2020/09/26 16:55:58 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.348 2020/09/26 17:15:20 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."); @@ -869,8 +869,8 @@ doPrintVars(void) else expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE); - for (ln = Lst_First(variables); ln != NULL; ln = LstNode_Next(ln)) { - char *var = LstNode_Datum(ln); + for (ln = variables->first; ln != NULL; ln = ln->next) { + const char *var = ln->datum; const char *value; char *p1; Index: src/usr.bin/make/make.c diff -u src/usr.bin/make/make.c:1.146 src/usr.bin/make/make.c:1.147 --- src/usr.bin/make/make.c:1.146 Sat Sep 26 16:55:58 2020 +++ src/usr.bin/make/make.c Sat Sep 26 17:15:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.146 2020/09/26 16:55:58 rillig Exp $ */ +/* $NetBSD: make.c,v 1.147 2020/09/26 17:15:20 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.146 2020/09/26 16:55:58 rillig Exp $"); +MAKE_RCSID("$NetBSD: make.c,v 1.147 2020/09/26 17:15:20 rillig Exp $"); static unsigned int checked = 1;/* Sequence # to detect recursion */ static GNodeList *toBeMade; /* The current fringe of the graph. These @@ -1306,7 +1306,7 @@ add_wait_dependency(GNodeListNode *owln, GNodeListNode *cln; GNode *cn; - for (cln = owln; (cn = LstNode_Datum(cln)) != wn; cln = LstNode_Next(cln)) { + for (cln = owln; (cn = cln->datum) != wn; cln = cln->next) { if (DEBUG(MAKE)) fprintf(debug_file, ".WAIT: add dependency %s%s -> %s\n", cn->name, cn->cohort_num, wn->name); Index: src/usr.bin/make/meta.c diff -u src/usr.bin/make/meta.c:1.119 src/usr.bin/make/meta.c:1.120 --- src/usr.bin/make/meta.c:1.119 Thu Sep 24 07:53:32 2020 +++ src/usr.bin/make/meta.c Sat Sep 26 17:15:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.119 2020/09/24 07:53:32 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.120 2020/09/26 17:15:20 rillig Exp $ */ /* * Implement 'meta' mode. @@ -1331,7 +1331,7 @@ meta_oodate(GNode *gn, Boolean oodate) do { char *tp; nln = Lst_FindFrom(missingFiles, - LstNode_Next(missingNode), + missingNode->next, path_match, p); tp = LstNode_Datum(missingNode); Lst_Remove(missingFiles, missingNode); @@ -1565,7 +1565,7 @@ meta_oodate(GNode *gn, Boolean oodate) oodate = TRUE; } free(cmd); - cmdNode = LstNode_Next(cmdNode); + cmdNode = cmdNode->next; } } else if (strcmp(buf, "CWD") == 0) { /* Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.168 src/usr.bin/make/suff.c:1.169 --- src/usr.bin/make/suff.c:1.168 Sat Sep 26 16:00:12 2020 +++ src/usr.bin/make/suff.c Sat Sep 26 17:15:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.168 2020/09/26 16:00:12 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.169 2020/09/26 17:15:20 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -126,7 +126,7 @@ #include "dir.h" /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ -MAKE_RCSID("$NetBSD: suff.c,v 1.168 2020/09/26 16:00:12 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.169 2020/09/26 17:15:20 rillig Exp $"); #define SUFF_DEBUG0(fmt) \ if (!DEBUG(SUFF)) (void) 0; else fprintf(debug_file, fmt) @@ -487,8 +487,7 @@ SuffParseTransform(const char *str, Suff if (srcLn == NULL) { srcLn = Lst_Find(sufflist, SuffSuffIsPrefix, str); } else { - srcLn = Lst_FindFrom(sufflist, LstNode_Next(srcLn), - SuffSuffIsPrefix, str); + srcLn = Lst_FindFrom(sufflist, srcLn->next, SuffSuffIsPrefix, str); } if (srcLn == NULL) { /* @@ -1332,7 +1331,7 @@ SuffExpandChildren(GNodeListNode *cln, G Lst_Append(gn->parents, pgn); pgn->unmade++; /* Expand wildcards on new node */ - SuffExpandWildcards(LstNode_Prev(cln), pgn); + SuffExpandWildcards(cln->prev, pgn); } Lst_Free(members); @@ -1503,8 +1502,8 @@ SuffApplyTransform(GNode *tGn, GNode *sG /* * Deal with wildcards and variables in any acquired sources */ - for (ln = ln != NULL ? LstNode_Next(ln) : NULL; ln != NULL; ln = nln) { - nln = LstNode_Next(ln); + for (ln = ln != NULL ? ln->next : NULL; ln != NULL; ln = nln) { + nln = ln->next; SuffExpandChildren(ln, tGn); } @@ -1609,7 +1608,7 @@ SuffFindArchiveDeps(GNode *gn, SrcList * * that still contain variables or wildcards in their names. */ for (ln = Lst_First(gn->children); ln != NULL; ln = nln) { - nln = LstNode_Next(ln); + nln = ln->next; SuffExpandChildren(ln, gn); } @@ -1763,7 +1762,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *s /* * Search from this suffix's successor... */ - ln = LstNode_Next(ln); + ln = ln->next; } } @@ -1839,7 +1838,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *s * that still contain variables or wildcards in their names. */ for (ln = Lst_First(gn->children); ln != NULL; ln = nln) { - nln = LstNode_Next(ln); + nln = ln->next; SuffExpandChildren(ln, gn); } Index: src/usr.bin/make/targ.c diff -u src/usr.bin/make/targ.c:1.100 src/usr.bin/make/targ.c:1.101 --- src/usr.bin/make/targ.c:1.100 Sat Sep 26 17:02:11 2020 +++ src/usr.bin/make/targ.c Sat Sep 26 17:15:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: targ.c,v 1.100 2020/09/26 17:02:11 rillig Exp $ */ +/* $NetBSD: targ.c,v 1.101 2020/09/26 17:15:20 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.100 2020/09/26 17:02:11 rillig Exp $"); +MAKE_RCSID("$NetBSD: targ.c,v 1.101 2020/09/26 17:15:20 rillig Exp $"); static GNodeList *allTargets; /* the list of all targets found so far */ #ifdef CLEANUP @@ -344,8 +344,8 @@ PrintNodeNames(GNodeList *gnodes) { GNodeListNode *node; - for (node = Lst_First(gnodes); node != NULL; node = LstNode_Next(node)) { - GNode *gn = LstNode_Datum(node); + for (node = gnodes->first; node != NULL; node = node->next) { + GNode *gn = node->datum; fprintf(debug_file, " %s%s", gn->name, gn->cohort_num); } } @@ -363,8 +363,8 @@ PrintNodeNamesLine(const char *label, GN void Targ_PrintCmds(GNode *gn) { - StringListNode *node = Lst_First(gn->commands); - for (; node != NULL; node = LstNode_Next(node)) { + StringListNode *node = gn->commands->first; + for (; node != NULL; node = node->next) { const char *cmd = LstNode_Datum(node); fprintf(debug_file, "\t%s\n", cmd); } @@ -562,14 +562,14 @@ Targ_Propagate(void) { GNodeListNode *pn, *cn; - for (pn = Lst_First(allTargets); pn != NULL; pn = LstNode_Next(pn)) { - GNode *pgn = LstNode_Datum(pn); + for (pn = allTargets->first; pn != NULL; pn = pn->next) { + GNode *pgn = pn->datum; if (!(pgn->type & OP_DOUBLEDEP)) continue; - for (cn = Lst_First(pgn->cohorts); cn != NULL; cn = LstNode_Next(cn)) { - GNode *cgn = LstNode_Datum(cn); + for (cn = pgn->cohorts->first; cn != NULL; cn = cn->next) { + GNode *cgn = cn->datum; cgn->type |= pgn->type & ~OP_OPMASK; }