From 0ddfa675e4e10096df4b8780280d335c0ccf3163 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 16 Mar 2020 12:47:40 +1100 Subject: [PATCH] Just return tv_sec field --- lib/isc/unix/stdtime.c | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/lib/isc/unix/stdtime.c b/lib/isc/unix/stdtime.c index 989bde4620..5da65cc141 100644 --- a/lib/isc/unix/stdtime.c +++ b/lib/isc/unix/stdtime.c @@ -24,38 +24,6 @@ #include #include -#ifndef ISC_FIX_TV_USEC -#define ISC_FIX_TV_USEC 1 -#endif - -#define US_PER_S 1000000 - -#if ISC_FIX_TV_USEC -static inline void -fix_tv_usec(struct timeval *tv) { - bool fixed = false; - - if (tv->tv_usec < 0) { - fixed = true; - do { - tv->tv_sec -= 1; - tv->tv_usec += US_PER_S; - } while (tv->tv_usec < 0); - } else if (tv->tv_usec >= US_PER_S) { - fixed = true; - do { - tv->tv_sec += 1; - tv->tv_usec -= US_PER_S; - } while (tv->tv_usec >=US_PER_S); - } - /* - * Call syslog directly as we are called from the logging functions. - */ - if (fixed) - (void)syslog(LOG_ERR, "gettimeofday returned bad tv_usec: corrected"); -} -#endif - void isc_stdtime_get(isc_stdtime_t *t) { struct timeval tv; @@ -69,12 +37,5 @@ isc_stdtime_get(isc_stdtime_t *t) { RUNTIME_CHECK(gettimeofday(&tv, NULL) != -1); -#if ISC_FIX_TV_USEC - fix_tv_usec(&tv); - INSIST(tv.tv_usec >= 0); -#else - INSIST(tv.tv_usec >= 0 && tv.tv_usec < US_PER_S); -#endif - *t = (unsigned int)tv.tv_sec; }