mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Merge branch '1679-handle-systems-with-broken-gettimeofday-system-calls' into 'v9_11'
Resolve "Handle systems with broken gettimeofday system calls" See merge request isc-projects/bind9!3232
This commit is contained in:
commit
0fa64e6682
1 changed files with 0 additions and 39 deletions
|
|
@ -24,38 +24,6 @@
|
|||
#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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue