diff options
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -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, ×pec) == 0) - return FILE_TIMESTAMP_FROM_S_AND_NS (timespec.tv_sec, timespec.tv_nsec); + { + struct timespec timespec; + if (clock_gettime (CLOCK_REALTIME, ×pec) == 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); } |