summaryrefslogtreecommitdiff
path: root/usr.bin/make/dir.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2000-11-24 14:36:36 +0000
committerMarc Espie <espie@cvs.openbsd.org>2000-11-24 14:36:36 +0000
commite929152d444d933415d0c0df0aa6b4fae922fe43 (patch)
tree33342bdce3651572ab9711803cbdd75bb4150d02 /usr.bin/make/dir.c
parent2cee9a585ea175c769b7222ead016577e476d8e3 (diff)
Change the time stamp interface to use an abstract datatype.
Define two possible interfaces: the classic one, and the new one (used where available) that depends on timespec. Better granularity, make is now able to distinguish between files that were built during the same second.
Diffstat (limited to 'usr.bin/make/dir.c')
-rw-r--r--usr.bin/make/dir.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index 18140e01047..36d45ff2253 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.28 2000/11/24 14:27:19 espie Exp $ */
+/* $OpenBSD: dir.c,v 1.29 2000/11/24 14:36:33 espie Exp $ */
/* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */
/*
@@ -96,7 +96,7 @@
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
UNUSED
-static char rcsid[] = "$OpenBSD: dir.c,v 1.28 2000/11/24 14:27:19 espie Exp $";
+static char rcsid[] = "$OpenBSD: dir.c,v 1.29 2000/11/24 14:36:33 espie Exp $";
#endif
#endif /* not lint */
@@ -874,7 +874,7 @@ Dir_FindFile(name, path)
/* Save the modification time so if it's needed, we don't have
* to fetch it again. */
if (DEBUG(DIR))
- printf("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
+ printf("Caching %s for %s\n", Targ_FmtTime(mtime),
file);
record_stamp(file, mtime);
nearmisses += 1;
@@ -938,7 +938,7 @@ Dir_FindFile(name, path)
grab_stat(stb, mtime);
if (DEBUG(DIR))
- printf("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
+ printf("Caching %s for %s\n", Targ_FmtTime(mtime),
name);
record_stamp(name, mtime);
return estrdup(name);
@@ -1004,7 +1004,7 @@ Dir_MTime(gn)
if (gn->type & OP_MEMBER) {
if (fullName != gn->path)
free(fullName);
- return Arch_MemMTime (gn);
+ return Arch_MemMTime(gn);
} else
set_out_of_date(mtime);
}
@@ -1272,3 +1272,25 @@ Dir_PrintPath(path)
{
Lst_Every(path, DirPrintDir);
}
+
+#ifndef USE_TIMESPEC
+#include <sys/types.h>
+#include <utime.h>
+#endif
+int
+set_times(f)
+ const char *f;
+{
+#ifdef USE_TIMESPEC
+ struct timeval tv[2];
+
+ TIMESPEC_TO_TIMEVAL(&tv[0], &now);
+ TIMESPEC_TO_TIMEVAL(&tv[1], &now);
+ return utimes(f, tv);
+#else
+ struct utimbuf times;
+
+ times.actime = times.modtime = now;
+ return utime(f, &times);
+#endif
+}