]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2648. [port] win32: isc_time_seconds() was broken. [RT #19900]
authorMark Andrews <marka@isc.org>
Thu, 13 Aug 2009 03:42:27 +0000 (03:42 +0000)
committerMark Andrews <marka@isc.org>
Thu, 13 Aug 2009 03:42:27 +0000 (03:42 +0000)
CHANGES
lib/isc/win32/time.c

diff --git a/CHANGES b/CHANGES
index 727e2ef8ed3035d911484c015a61f878a1fe95bb..e52d2b8c1a8c357c6a695e2699d33088ff9675b1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+2648.  [port]          win32: isc_time_seconds() was broken. [RT #19900]
+
 2646.  [bug]           Incorrect cleanup on error in socket.c. [RT #19987]
 
 2642.  [bug]           nsupdate could dump core on solaris when reading
index 35796f8438f7e36e72f1650731631a6f088d735b..2690318e9e08b62849ec7ba227b3e98db5e59eeb 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: time.c,v 1.38.18.2 2008/08/29 23:46:17 tbox Exp $ */
+/* $Id: time.c,v 1.38.18.3 2009/08/13 03:42:27 marka Exp $ */
 
 #include <config.h>
 
@@ -205,28 +205,30 @@ isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
 
 isc_uint32_t
 isc_time_seconds(const isc_time_t *t) {
-       SYSTEMTIME st;
+       SYSTEMTIME epoch = { 1970, 1, 4, 1, 0, 0, 0, 0 };
+       FILETIME temp;
+       ULARGE_INTEGER i1, i2;
+       LONGLONG i3;
 
-       /*
-        * Convert the time to a SYSTEMTIME structure and the grab the
-        * milliseconds
-        */
-       FileTimeToSystemTime(&t->absolute, &st);
+       SystemTimeToFileTime(&epoch, &temp);
+
+       i1.LowPart  = t->absolute.dwLowDateTime;
+       i1.HighPart = t->absolute.dwHighDateTime;
+       i2.LowPart  = temp.dwLowDateTime;
+       i2.HighPart = temp.dwHighDateTime;
+
+       i3 = (i1.QuadPart - i2.QuadPart) / 10000000;
 
-       return ((isc_uint32_t)(st.wMilliseconds / 1000));
+       return ((isc_uint32_t)i3)
 }
 
 isc_uint32_t
 isc_time_nanoseconds(const isc_time_t *t) {
-       SYSTEMTIME st;
-
-       /*
-        * Convert the time to a SYSTEMTIME structure and the grab the
-        * milliseconds
-        */
-       FileTimeToSystemTime(&t->absolute, &st);
+       ULARGE_INTEGER i;
 
-       return ((isc_uint32_t)(st.wMilliseconds * 1000000));
+       i.LowPart  = t->absolute.dwLowDateTime;
+       i.HighPart = t->absolute.dwHighDateTime;
+       return ((isc_uint32_t)(i.QuadPart % 10000000) * 100);
 }
 
 void