From d3e7d196cd14fc3095ce97846a66cd49fc6fee6d Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sat, 9 Oct 1999 02:39:53 +0000 Subject: [PATCH] isc_time_millidiff is now isc_time_microdiff --- lib/isc/win32/condition.c | 11 +++++++++-- lib/isc/win32/include/isc/time.h | 10 ++++------ lib/isc/win32/time.c | 19 +++++-------------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lib/isc/win32/condition.c b/lib/isc/win32/condition.c index ba5d745474..b680b9668c 100644 --- a/lib/isc/win32/condition.c +++ b/lib/isc/win32/condition.c @@ -130,12 +130,19 @@ isc_condition_waituntil(isc_condition_t *cond, isc_mutex_t *mutex, isc_time_t *t) { DWORD milliseconds; - struct isc_time now; + isc_uint64_t microseconds; + isc_time_t now; if (isc_time_now(&now) != ISC_R_SUCCESS) { /* XXX */ return (ISC_R_UNEXPECTED); } - milliseconds = (DWORD)isc_time_millidiff(t, &now); + + microseconds = isc_time_microdiff(t, &now); + if (microseconds > 0xFFFFFFFFi64 * 1000) + milliseconds = 0xFFFFFFFF; + else + milliseconds = (DWORD)(microseconds / 1000); + return (wait(cond, mutex, milliseconds)); } diff --git a/lib/isc/win32/include/isc/time.h b/lib/isc/win32/include/isc/time.h index 29b4f95e74..7c9985a5f0 100644 --- a/lib/isc/win32/include/isc/time.h +++ b/lib/isc/win32/include/isc/time.h @@ -183,12 +183,8 @@ isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result); * t >= epoch + i (comparing times, not pointers) */ -/*** - *** Win32 Only - ***/ - -unsigned int -isc_time_millidiff(isc_time_t *t1, isc_time_t *t2); +isc_uint64_t +isc_time_microdiff(isc_time_t *t1, isc_time_t *t2); /* * Find the difference in milliseconds between time t1 and time t2. * t2 is the subtrahend of t1; ie, difference = t1 - t2. @@ -197,4 +193,6 @@ isc_time_millidiff(isc_time_t *t1, isc_time_t *t2); * No formal requirements are asserted. */ +ISC_LANG_ENDDECLS + #endif /* ISC_TIME_H */ diff --git a/lib/isc/win32/time.c b/lib/isc/win32/time.c index af4a5ad425..30907ea9ba 100644 --- a/lib/isc/win32/time.c +++ b/lib/isc/win32/time.c @@ -181,12 +181,8 @@ isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result) { result->absolute.dwHighDateTime = i2.HighPart; } -/*** - *** Win32 Only - ***/ - -unsigned int -isc_time_millidiff(isc_time_t *t1, isc_time_t *t2) { +isc_uint64_t +isc_time_microdiff(isc_time_t *t1, isc_time_t *t2) { ULARGE_INTEGER i1, i2; LONGLONG i3; @@ -201,14 +197,9 @@ isc_time_millidiff(isc_time_t *t1, isc_time_t *t2) { return (0); /* - * Convert to milliseconds. + * Convert to microseconds. */ - i3 = (i1.QuadPart - i2.QuadPart) / 10000; + i3 = (i1.QuadPart - i2.QuadPart) / 10; -#define _MILLIMAX 1000000000 /* XXX arbitrary! */ - if (i3 > _MILLIMAX) - return (_MILLIMAX); -#undef _MILLIMAX - - return ((unsigned int)(i3)); + return (i3); }