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): reduce memory allocation for dirSearch...



details:   https://anonhg.NetBSD.org/src/rev/33661ef36be9
branches:  trunk
changeset: 946498:33661ef36be9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 29 01:40:26 2020 +0000

description:
make(1): reduce memory allocation for dirSearchPath

diffstat:

 usr.bin/make/arch.c  |   6 +++---
 usr.bin/make/cond.c  |   6 +++---
 usr.bin/make/dir.c   |  16 +++++++---------
 usr.bin/make/main.c  |   6 +++---
 usr.bin/make/make.h  |   4 ++--
 usr.bin/make/parse.c |  10 +++++-----
 usr.bin/make/suff.c  |  12 ++++++------
 7 files changed, 29 insertions(+), 31 deletions(-)

diffs (270 lines):

diff -r ce2e1da8e5fc -r 33661ef36be9 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Sun Nov 29 01:35:33 2020 +0000
+++ b/usr.bin/make/arch.c       Sun Nov 29 01:40:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.181 2020/11/28 23:13:28 rillig Exp $        */
+/*     $NetBSD: arch.c,v 1.182 2020/11/29 01:40:26 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -125,7 +125,7 @@
 #include "config.h"
 
 /*     "@(#)arch.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: arch.c,v 1.181 2020/11/28 23:13:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.182 2020/11/29 01:40:26 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -345,7 +345,7 @@
 
                } else if (Dir_HasWildcards(memName)) {
                        StringList members = LST_INIT;
-                       Dir_Expand(memName, dirSearchPath, &members);
+                       Dir_Expand(memName, &dirSearchPath, &members);
 
                        while (!Lst_IsEmpty(&members)) {
                                char *member = Lst_Dequeue(&members);
diff -r ce2e1da8e5fc -r 33661ef36be9 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Sun Nov 29 01:35:33 2020 +0000
+++ b/usr.bin/make/cond.c       Sun Nov 29 01:40:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.219 2020/11/28 23:39:58 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.220 2020/11/29 01:40:26 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -94,7 +94,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.219 2020/11/28 23:39:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.220 2020/11/29 01:40:26 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -313,7 +313,7 @@
        Boolean result;
        char *path;
 
-       path = Dir_FindFile(arg, dirSearchPath);
+       path = Dir_FindFile(arg, &dirSearchPath);
        DEBUG2(COND, "exists(%s) result is \"%s\"\n",
               arg, path != NULL ? path : "");
        result = path != NULL;
diff -r ce2e1da8e5fc -r 33661ef36be9 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Sun Nov 29 01:35:33 2020 +0000
+++ b/usr.bin/make/dir.c        Sun Nov 29 01:40:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.227 2020/11/28 23:22:14 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.228 2020/11/29 01:40:26 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -136,7 +136,7 @@
 #include "job.h"
 
 /*     "@(#)dir.c      8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: dir.c,v 1.227 2020/11/28 23:22:14 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.228 2020/11/29 01:40:26 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -214,7 +214,7 @@
 
 typedef ListNode SearchPathNode;
 
-SearchPath *dirSearchPath;     /* main search path */
+SearchPath dirSearchPath = LST_INIT;   /* main search path */
 
 /* A list of cached directories, with fast lookup by directory name. */
 typedef struct OpenDirs {
@@ -368,7 +368,6 @@
 void
 Dir_Init(void)
 {
-       dirSearchPath = SearchPath_New();
        OpenDirs_Init(&openDirs);
        HashTable_Init(&mtimes);
        HashTable_Init(&lmtimes);
@@ -459,8 +458,7 @@
        dotLast->refCount--;
        Dir_Destroy(dotLast);
        Dir_Destroy(dot);
-       SearchPath_Clear(dirSearchPath);
-       Lst_Free(dirSearchPath);
+       SearchPath_Clear(&dirSearchPath);
        OpenDirs_Done(&openDirs);
        HashTable_Done(&mtimes);
 #endif
@@ -479,7 +477,7 @@
 
        Var_Delete(".PATH", VAR_GLOBAL);
 
-       if ((ln = dirSearchPath->first) != NULL) {
+       if ((ln = dirSearchPath.first) != NULL) {
                CachedDir *dir = ln->datum;
                if (dir == dotLast) {
                        hasLastDot = TRUE;
@@ -494,7 +492,7 @@
                        Var_Append(".PATH", cur->name, VAR_GLOBAL);
        }
 
-       for (ln = dirSearchPath->first; ln != NULL; ln = ln->next) {
+       for (ln = dirSearchPath.first; ln != NULL; ln = ln->next) {
                CachedDir *dir = ln->datum;
                if (dir == dotLast)
                        continue;
@@ -1481,7 +1479,7 @@
 {
        SearchPath *path = SearchPath_New();
        SearchPathNode *ln;
-       for (ln = dirSearchPath->first; ln != NULL; ln = ln->next) {
+       for (ln = dirSearchPath.first; ln != NULL; ln = ln->next) {
                CachedDir *dir = ln->datum;
                dir->refCount++;
                Lst_Append(path, dir);
diff -r ce2e1da8e5fc -r 33661ef36be9 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Nov 29 01:35:33 2020 +0000
+++ b/usr.bin/make/main.c       Sun Nov 29 01:40:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.489 2020/11/29 00:42:01 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.490 2020/11/29 01:40:26 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.489 2020/11/29 00:42:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.490 2020/11/29 01:40:26 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -1288,7 +1288,7 @@
                savec = *cp;
                *cp = '\0';
                /* Add directory to search path */
-               (void)Dir_AddDir(dirSearchPath, path);
+               (void)Dir_AddDir(&dirSearchPath, path);
                *cp = savec;
                path = cp + 1;
        } while (savec == ':');
diff -r ce2e1da8e5fc -r 33661ef36be9 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Sun Nov 29 01:35:33 2020 +0000
+++ b/usr.bin/make/make.h       Sun Nov 29 01:40:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.228 2020/11/28 23:39:58 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.229 2020/11/29 01:40:26 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -508,7 +508,7 @@
 
 /* The list of directories to search when looking for targets (set by the
  * special target .PATH). */
-extern SearchPath *dirSearchPath;
+extern SearchPath dirSearchPath;
 /* Used for .include "...". */
 extern SearchPath *parseIncPath;
 /* Used for .include <...>, for the built-in sys.mk and makefiles from the
diff -r ce2e1da8e5fc -r 33661ef36be9 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sun Nov 29 01:35:33 2020 +0000
+++ b/usr.bin/make/parse.c      Sun Nov 29 01:40:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.462 2020/11/29 01:35:33 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.463 2020/11/29 01:40:26 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.462 2020/11/29 01:35:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.463 2020/11/29 01:40:26 rillig Exp $");
 
 /* types and constants */
 
@@ -1087,7 +1087,7 @@
     case SP_PATH:
        if (*inout_paths == NULL)
            *inout_paths = Lst_New();
-       Lst_Append(*inout_paths, dirSearchPath);
+       Lst_Append(*inout_paths, &dirSearchPath);
        break;
     case SP_MAIN:
        /* Allow targets from the command line to override the .MAIN node. */
@@ -2132,7 +2132,7 @@
            newName = str_concat3(incdir, "/", file + i);
            fullname = Dir_FindFile(newName, parseIncPath);
            if (fullname == NULL)
-               fullname = Dir_FindFile(newName, dirSearchPath);
+               fullname = Dir_FindFile(newName, &dirSearchPath);
            free(newName);
        }
        free(incdir);
@@ -2155,7 +2155,7 @@
            if (fullname == NULL) {
                fullname = Dir_FindFile(file, parseIncPath);
                if (fullname == NULL)
-                   fullname = Dir_FindFile(file, dirSearchPath);
+                   fullname = Dir_FindFile(file, &dirSearchPath);
            }
        }
     }
diff -r ce2e1da8e5fc -r 33661ef36be9 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Sun Nov 29 01:35:33 2020 +0000
+++ b/usr.bin/make/suff.c       Sun Nov 29 01:40:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.322 2020/11/29 01:30:38 rillig Exp $        */
+/*     $NetBSD: suff.c,v 1.323 2020/11/29 01:40:26 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*     "@(#)suff.c     8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.322 2020/11/29 01:30:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.323 2020/11/29 01:40:26 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -467,7 +467,7 @@
        SuffFree(nullSuff);
     emptySuff = nullSuff = Suffix_New("");
 
-    SearchPath_AddAll(nullSuff->searchPath, dirSearchPath);
+    SearchPath_AddAll(nullSuff->searchPath, &dirSearchPath);
     nullSuff->flags = SUFF_NULL;
 }
 
@@ -849,7 +849,7 @@
            if (suff->flags & SUFF_LIBRARY)
                SearchPath_AddAll(inLibs, suff->searchPath);
 #endif
-           SearchPath_AddAll(suff->searchPath, dirSearchPath);
+           SearchPath_AddAll(suff->searchPath, &dirSearchPath);
        } else {
            SearchPath_Free(suff->searchPath);
            suff->searchPath = Dir_CopyDirSearchPath();
@@ -1423,7 +1423,7 @@
        return suff->searchPath;
     } else {
        SUFF_DEBUG0("\n");
-       return dirSearchPath;   /* Use default search path */
+       return &dirSearchPath;  /* Use default search path */
     }
 }
 
@@ -1726,7 +1726,7 @@
 
     free(gn->path);
     gn->path = Dir_FindFile(gn->name,
-                           (targ == NULL ? dirSearchPath :
+                           (targ == NULL ? &dirSearchPath :
                             targ->suff->searchPath));
     if (gn->path == NULL)
        return;



Home | Main Index | Thread Index | Old Index