Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Remove recheck hackery that caused extra stats, ...



details:   https://anonhg.NetBSD.org/src/rev/9337051c58a7
branches:  trunk
changeset: 778670:9337051c58a7
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Apr 07 18:29:08 2012 +0000

description:
Remove recheck hackery that caused extra stats, and explicitly ask for
recheck when needed. Before it used to be the case that we could only
use the cached entry once. Once the cached entry was used, we removed
it from the cache. Now it is kept forever.

diffstat:

 usr.bin/make/dir.c  |  35 ++++++++++++++++++-----------------
 usr.bin/make/dir.h  |   4 ++--
 usr.bin/make/job.c  |   8 ++++----
 usr.bin/make/make.c |  14 +++++++-------
 4 files changed, 31 insertions(+), 30 deletions(-)

diffs (197 lines):

diff -r f78eee451d4b -r 9337051c58a7 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Sat Apr 07 17:30:55 2012 +0000
+++ b/usr.bin/make/dir.c        Sat Apr 07 18:29:08 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.63 2011/03/05 23:57:05 sjg Exp $     */
+/*     $NetBSD: dir.c,v 1.64 2012/04/07 18:29:08 christos Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.63 2011/03/05 23:57:05 sjg Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.64 2012/04/07 18:29:08 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c      8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.63 2011/03/05 23:57:05 sjg Exp $");
+__RCSID("$NetBSD: dir.c,v 1.64 2012/04/07 18:29:08 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1428,7 +1428,7 @@
  *-----------------------------------------------------------------------
  */
 int
-Dir_MTime(GNode *gn)
+Dir_MTime(GNode *gn, Boolean recheck)
 {
     char          *fullName;  /* the full pathname of name */
     struct stat          stb;        /* buffer for finding the mod time */
@@ -1481,19 +1481,16 @@
        fullName = bmake_strdup(gn->name);
     }
 
-    entry = Hash_FindEntry(&mtimes, fullName);
+    if (!recheck)
+       entry = Hash_FindEntry(&mtimes, fullName);
+    else
+       entry = NULL;
     if (entry != NULL) {
-       /*
-        * Only do this once -- the second time folks are checking to
-        * see if the file was actually updated, so we need to actually go
-        * to the file system.
-        */
        if (DEBUG(DIR)) {
            fprintf(debug_file, "Using cached time %s for %s\n",
                    Targ_FmtTime(Hash_GetTimeValue(entry)), fullName);
        }
        stb.st_mtime = Hash_GetTimeValue(entry);
-       Hash_DeleteEntry(&mtimes, entry);
     } else if (stat(fullName, &stb) < 0) {
        if (gn->type & OP_MEMBER) {
            if (fullName != gn->path)
@@ -1502,12 +1499,16 @@
        } else {
            stb.st_mtime = 0;
        }
-    } else if (stb.st_mtime == 0) {
-       /*
-        * 0 handled specially by the code, if the time is really 0, return
-        * something else instead
-        */
-       stb.st_mtime = 1;
+    } else {
+       if (stb.st_mtime == 0) {
+               /*
+                * 0 handled specially by the code, if the time is really 0,
+                * return something else instead
+                */
+               stb.st_mtime = 1;
+       }
+       entry = Hash_CreateEntry(&mtimes, fullName, NULL);
+       Hash_SetTimeValue(entry, stb.st_mtime);
     }
        
     if (fullName && gn->path == NULL) {
diff -r f78eee451d4b -r 9337051c58a7 usr.bin/make/dir.h
--- a/usr.bin/make/dir.h        Sat Apr 07 17:30:55 2012 +0000
+++ b/usr.bin/make/dir.h        Sat Apr 07 18:29:08 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.h,v 1.14 2009/01/23 21:26:30 dsl Exp $     */
+/*     $NetBSD: dir.h,v 1.15 2012/04/07 18:29:08 christos Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 void Dir_Expand(const char *, Lst, Lst);
 char *Dir_FindFile(const char *, Lst);
 int Dir_FindHereOrAbove(char *, char *, char *, int);
-int Dir_MTime(GNode *);
+int Dir_MTime(GNode *, Boolean);
 Path *Dir_AddDir(Lst, const char *);
 char *Dir_MakeFlags(const char *, Lst);
 void Dir_ClearPath(Lst);
diff -r f78eee451d4b -r 9337051c58a7 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat Apr 07 17:30:55 2012 +0000
+++ b/usr.bin/make/job.c        Sat Apr 07 18:29:08 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.160 2011/09/16 15:38:03 joerg Exp $  */
+/*     $NetBSD: job.c,v 1.161 2012/04/07 18:29:08 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.160 2011/09/16 15:38:03 joerg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.161 2012/04/07 18:29:08 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.160 2011/09/16 15:38:03 joerg Exp $");
+__RCSID("$NetBSD: job.c,v 1.161 2012/04/07 18:29:08 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1226,7 +1226,7 @@
            Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn, 0);
            if (p1)
                free(p1);
-       } else if (Dir_MTime(gn) == 0 && (gn->type & OP_SPECIAL) == 0) {
+       } else if (Dir_MTime(gn, 0) == 0 && (gn->type & OP_SPECIAL) == 0) {
            /*
             * The node wasn't the target of an operator we have no .DEFAULT
             * rule to go on and the target doesn't already exist. There's
diff -r f78eee451d4b -r 9337051c58a7 usr.bin/make/make.c
--- a/usr.bin/make/make.c       Sat Apr 07 17:30:55 2012 +0000
+++ b/usr.bin/make/make.c       Sat Apr 07 18:29:08 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.c,v 1.84 2011/09/16 15:38:04 joerg Exp $  */
+/*     $NetBSD: make.c,v 1.85 2012/04/07 18:29:08 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.84 2011/09/16 15:38:04 joerg Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.85 2012/04/07 18:29:08 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)make.c     8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.84 2011/09/16 15:38:04 joerg Exp $");
+__RCSID("$NetBSD: make.c,v 1.85 2012/04/07 18:29:08 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -221,7 +221,7 @@
      * doesn't depend on their modification time...
      */
     if ((gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC)) == 0) {
-       (void)Dir_MTime(gn);
+       (void)Dir_MTime(gn, 0);
        if (DEBUG(MAKE)) {
            if (gn->mtime != 0) {
                fprintf(debug_file, "modified %s...", Targ_FmtTime(gn->mtime));
@@ -406,7 +406,7 @@
     GNode          *gn = (GNode *)gnp;
     GNode          *pgn = (GNode *)pgnp;
 
-    (void)Dir_MTime(gn);
+    (void)Dir_MTime(gn, 0);
     Make_TimeStamp(pgn, gn);
     pgn->unmade--;
 
@@ -574,7 +574,7 @@
 time_t
 Make_Recheck(GNode *gn)
 {
-    time_t mtime = Dir_MTime(gn);
+    time_t mtime = Dir_MTime(gn, 1);
 
 #ifndef RECHECK
     /*
@@ -1336,7 +1336,7 @@
            *eon = ')';
        }
 
-       (void)Dir_MTime(gn);
+       (void)Dir_MTime(gn, 0);
        Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
        Lst_ForEach(gn->children, MakeUnmark, gn);
        Lst_ForEach(gn->children, MakeHandleUse, gn);



Home | Main Index | Thread Index | Old Index