summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2000-06-07 05:43:37 +0000
committerPaul Smith <psmith@gnu.org>2000-06-07 05:43:37 +0000
commit4a5550c8225d762f684d4047e20cc45274b6a785 (patch)
tree943515aca19373ad0fe0dce0cb852c2eca7b0cab /file.c
parente5c40f6e5ad9d485f7caada51e2361758baa67dd (diff)
downloadgunmake-4a5550c8225d762f684d4047e20cc45274b6a785.tar.gz
* Lots of bug fixes and cleanup; new i18n files, etc.
Diffstat (limited to 'file.c')
-rw-r--r--file.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/file.c b/file.c
index 10ae1b8..daaea69 100644
--- a/file.c
+++ b/file.c
@@ -569,11 +569,29 @@ set_command_state (file, state)
FILE_TIMESTAMP
file_timestamp_now ()
{
+ /* Don't bother with high-resolution clocks if file timestamps have
+ only one-second resolution. The code below should work, but it's
+ not worth the hassle of debugging it on hosts where it fails. */
+ if (1 < FILE_TIMESTAMPS_PER_S)
+ {
#if HAVE_CLOCK_GETTIME && defined CLOCK_REALTIME
- struct timespec timespec;
- if (clock_gettime (CLOCK_REALTIME, &timespec) == 0)
- return FILE_TIMESTAMP_FROM_S_AND_NS (timespec.tv_sec, timespec.tv_nsec);
+ {
+ struct timespec timespec;
+ if (clock_gettime (CLOCK_REALTIME, &timespec) == 0)
+ return FILE_TIMESTAMP_FROM_S_AND_NS (timespec.tv_sec,
+ timespec.tv_nsec);
+ }
+#endif
+#if HAVE_GETTIMEOFDAY
+ {
+ struct timeval timeval;
+ if (gettimeofday (&timeval, 0) == 0)
+ return FILE_TIMESTAMP_FROM_S_AND_NS (timeval.tv_sec,
+ timeval.tv_usec * 1000);
+ }
#endif
+ }
+
return FILE_TIMESTAMP_FROM_S_AND_NS (time ((time_t *) 0), 0);
}