diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2000-11-24 14:36:36 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2000-11-24 14:36:36 +0000 |
commit | e929152d444d933415d0c0df0aa6b4fae922fe43 (patch) | |
tree | 33342bdce3651572ab9711803cbdd75bb4150d02 /usr.bin/make/make.h | |
parent | 2cee9a585ea175c769b7222ead016577e476d8e3 (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/make.h')
-rw-r--r-- | usr.bin/make/make.h | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index 72c97b199a5..87b1f8cd5df 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -1,4 +1,4 @@ -/* $OpenBSD: make.h,v 1.28 2000/11/24 14:27:19 espie Exp $ */ +/* $OpenBSD: make.h,v 1.29 2000/11/24 14:36:35 espie Exp $ */ /* $NetBSD: make.h,v 1.15 1997/03/10 21:20:00 christos Exp $ */ /* @@ -90,6 +90,34 @@ #include "config.h" #include "buf.h" +#ifdef USE_TIMESPEC +#include <sys/time.h> +typedef struct timespec TIMESTAMP; +#define set_out_of_date(t) (t).tv_sec = INT_MIN, (t).tv_nsec = 0 +#define is_out_of_date(t) ((t).tv_sec == INT_MIN && (t).tv_nsec == 0) +#define grab_stat(s, t) \ +do { \ + (t).tv_sec = (s).st_mtime; \ + (t).tv_nsec = (s).st_mtimensec; \ + if (is_out_of_date(t)) \ + (t).tv_nsec++; \ +} while (0) +#define is_before(t1, t2) timespeccmp(&(t1), &(t2), <) +#define grab_date(d, t) \ +do { \ + (t).tv_sec = d; \ + (t).tv_nsec = 0; \ + if (is_out_of_date(t)) \ + (t).tv_nsec++; \ +} while (0) +#define grab(n) \ +do { \ + struct timeval tv; \ + gettimeofday(&tv, NULL); \ + TIMEVAL_TO_TIMESPEC(&(tv), &n); \ +} while (0) +#define timestamp2time_t(t) ((t).tv_sec) +#else typedef time_t TIMESTAMP; #define is_out_of_date(t) ((t) == INT_MIN) #define set_out_of_date(t) (t) = INT_MIN @@ -108,8 +136,7 @@ do { \ } while (0) #define grab(n) time(&(n)) #define timestamp2time_t(t) (t) - -#define OUT_OF_DATE INT_MIN +#endif /* Variables that are kept in local GNodes. */ #define TARGET_INDEX 0 @@ -191,8 +218,8 @@ typedef struct GNode_ { * made */ int unmade; /* The number of unmade children */ - time_t mtime; /* Its modification time */ - time_t cmtime; /* The modification time of its youngest + TIMESTAMP mtime; /* Its modification time */ + TIMESTAMP cmtime; /* The modification time of its youngest * child */ LIST iParents; /* Links to parents for which this is an @@ -395,7 +422,7 @@ extern char var_Error[]; /* Value returned by Var_Parse when an error * an empty string, so naive callers needn't * worry about it. */ -extern time_t now; /* The time at the start of this whole +extern TIMESTAMP now; /* The time at the start of this whole * process */ extern Boolean oldVars; /* Do old-style variable substitution */ |