]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
windows implementation of isc_time_set
authorMark Andrews <marka@isc.org>
Mon, 8 Sep 2008 06:53:10 +0000 (06:53 +0000)
committerMark Andrews <marka@isc.org>
Mon, 8 Sep 2008 06:53:10 +0000 (06:53 +0000)
lib/isc/win32/include/isc/time.h
lib/isc/win32/libisc.def
lib/isc/win32/time.c

index f346a15219677614cf0c8bea1dca31cdc62c2e85..a8f9b4702e2c4ee6927c94d46e89864355a47394 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: time.h,v 1.31 2007/06/19 23:47:20 tbox Exp $ */
+/* $Id: time.h,v 1.32 2008/09/08 06:53:10 marka Exp $ */
 
 #ifndef ISC_TIME_H
 #define ISC_TIME_H 1
@@ -84,6 +84,17 @@ struct isc_time {
 
 LIBISC_EXTERNAL_DATA extern isc_time_t *isc_time_epoch;
 
+void
+isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds);
+/*%<
+ * Set 't' to a value which represents the given number of seconds and 
+ * nanoseconds since 00:00:00 January 1, 1970, UTC.
+ * 
+ * Requires:
+ *\li   't' is a valid pointer.
+ *\li   nanoseconds < 1000000000.
+ */
+
 void
 isc_time_settoepoch(isc_time_t *t);
 /*
index ddc8d2e48b058e266ba64500bb91361017774137..4e5516ebef07964b24354f67fd42945a61effaf0 100644 (file)
@@ -488,6 +488,7 @@ isc_time_nanoseconds
 isc_time_now
 isc_time_nowplusinterval
 isc_time_seconds
+isc_time_set
 isc_time_settoepoch
 isc_time_subtract
 isc_timer_attach
index 1981a53e92bd30469520f9670329b31e151fe8f7..d77d1bc29956e5bb9d5e097e7322ec4e8a7d3a06 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: time.c,v 1.45 2008/08/29 23:47:22 tbox Exp $ */
+/* $Id: time.c,v 1.46 2008/09/08 06:53:10 marka Exp $ */
 
 #include <config.h>
 
@@ -80,6 +80,27 @@ isc_interval_iszero(const isc_interval_t *i) {
        return (ISC_FALSE);
 }
 
+void
+isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) {
+       SYSTEMTIME epoch = { 1970, 1, 4, 1, 0, 0, 0, 0 };
+       FILETIME temp;
+       ULARGE_INTEGER i1;
+
+       REQUIRE(t != NULL);
+       REQUIRE(nanoseconds < NS_PER_S);
+       
+       SystemTimeToFileTime(&epoch, &temp);
+       i1.LowPart = t->absolute.dwLowDateTime;
+       i1.HighPart = t->absolute.dwHighDateTime;
+
+       i1.QuadPart += (unsigned __int64)nanoseconds/100;
+       i1.QuadPart += (unsigned __int64)seconds*10000000);
+
+       t->absolute.dwLowDateTime = i1.LowPart;
+       t->absolute.dwHighDateTime = i1.HighPart;
+}
+
 void
 isc_time_settoepoch(isc_time_t *t) {
        REQUIRE(t != NULL);