Module Name: src Committed By: christos Date: Sat Apr 7 18:29:08 UTC 2012
Modified Files: src/usr.bin/make: dir.c dir.h job.c make.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/usr.bin/make/dir.c cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/dir.h cvs rdiff -u -r1.160 -r1.161 src/usr.bin/make/job.c cvs rdiff -u -r1.84 -r1.85 src/usr.bin/make/make.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.63 src/usr.bin/make/dir.c:1.64 --- src/usr.bin/make/dir.c:1.63 Sat Mar 5 18:57:05 2011 +++ src/usr.bin/make/dir.c Sat Apr 7 14:29:08 2012 @@ -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 @@ Dir_FindHereOrAbove(char *here, char *se *----------------------------------------------------------------------- */ 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 @@ Dir_MTime(GNode *gn) 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 @@ Dir_MTime(GNode *gn) } 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) { Index: src/usr.bin/make/dir.h diff -u src/usr.bin/make/dir.h:1.14 src/usr.bin/make/dir.h:1.15 --- src/usr.bin/make/dir.h:1.14 Fri Jan 23 16:26:30 2009 +++ src/usr.bin/make/dir.h Sat Apr 7 14:29:08 2012 @@ -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 @@ Boolean Dir_HasWildcards(char *); 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); Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.160 src/usr.bin/make/job.c:1.161 --- src/usr.bin/make/job.c:1.160 Fri Sep 16 11:38:03 2011 +++ src/usr.bin/make/job.c Sat Apr 7 14:29:08 2012 @@ -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 @@ Job_CheckCommands(GNode *gn, void (*abor 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 Index: src/usr.bin/make/make.c diff -u src/usr.bin/make/make.c:1.84 src/usr.bin/make/make.c:1.85 --- src/usr.bin/make/make.c:1.84 Fri Sep 16 11:38:04 2011 +++ src/usr.bin/make/make.c Sat Apr 7 14:29:08 2012 @@ -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 @@ Make_OODate(GNode *gn) * 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 @@ MakeFindChild(void *gnp, void *pgnp) 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 @@ MakeHandleUse(void *cgnp, void *pgnp) 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 @@ Make_ExpandUse(Lst targs) *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);