diff options
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -882,17 +882,24 @@ ms_to_timeval(struct timeval *tv, int ms) | |||
882 | time_t | 882 | time_t |
883 | monotime(void) | 883 | monotime(void) |
884 | { | 884 | { |
885 | #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) | 885 | #if defined(HAVE_CLOCK_GETTIME) && \ |
886 | (defined(CLOCK_MONOTONIC) || defined(CLOCK_BOOTTIME)) | ||
886 | struct timespec ts; | 887 | struct timespec ts; |
887 | static int gettime_failed = 0; | 888 | static int gettime_failed = 0; |
888 | 889 | ||
889 | if (!gettime_failed) { | 890 | if (!gettime_failed) { |
891 | #if defined(CLOCK_BOOTTIME) | ||
892 | if (clock_gettime(CLOCK_BOOTTIME, &ts) == 0) | ||
893 | return (ts.tv_sec); | ||
894 | #endif | ||
895 | #if defined(CLOCK_MONOTONIC) | ||
890 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) | 896 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) |
891 | return (ts.tv_sec); | 897 | return (ts.tv_sec); |
898 | #endif | ||
892 | debug3("clock_gettime: %s", strerror(errno)); | 899 | debug3("clock_gettime: %s", strerror(errno)); |
893 | gettime_failed = 1; | 900 | gettime_failed = 1; |
894 | } | 901 | } |
895 | #endif | 902 | #endif /* HAVE_CLOCK_GETTIME && (CLOCK_MONOTONIC || CLOCK_BOOTTIME */ |
896 | 903 | ||
897 | return time(NULL); | 904 | return time(NULL); |
898 | } | 905 | } |