]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Just return tv_sec field
authorMark Andrews <marka@isc.org>
Mon, 16 Mar 2020 01:47:40 +0000 (12:47 +1100)
committerMark Andrews <marka@isc.org>
Wed, 18 Mar 2020 06:36:10 +0000 (06:36 +0000)
lib/isc/unix/stdtime.c

index 989bde4620884fa001e708c692592a0ba8d28012..5da65cc141c64dc4b2049aa6527051c9d1b500d2 100644 (file)
 #include <isc/stdtime.h>
 #include <isc/util.h>
 
-#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;
 }