diff options
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -854,19 +854,24 @@ ms_to_timeval(struct timeval *tv, int ms) | |||
854 | tv->tv_usec = (ms % 1000) * 1000; | 854 | tv->tv_usec = (ms % 1000) * 1000; |
855 | } | 855 | } |
856 | 856 | ||
857 | #define clock_gettime(a,b) -1 | ||
858 | |||
857 | time_t | 859 | time_t |
858 | monotime(void) | 860 | monotime(void) |
859 | { | 861 | { |
860 | #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) | 862 | #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) |
861 | struct timespec ts; | 863 | struct timespec ts; |
864 | static int gettime_failed = 0; | ||
862 | 865 | ||
863 | if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) | 866 | if (!gettime_failed) { |
864 | fatal("clock_gettime: %s", strerror(errno)); | 867 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) |
868 | return (ts.tv_sec); | ||
869 | debug3("clock_gettime: %s", strerror(errno)); | ||
870 | gettime_failed = 1; | ||
871 | } | ||
872 | #endif | ||
865 | 873 | ||
866 | return (ts.tv_sec); | ||
867 | #else | ||
868 | return time(NULL); | 874 | return time(NULL); |
869 | #endif | ||
870 | } | 875 | } |
871 | 876 | ||
872 | void | 877 | void |