From 8343d55b3d97923fa444ea9b92aae2ec60ffd40f Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 8 Sep 2008 06:53:10 +0000 Subject: [PATCH] windows implementation of isc_time_set --- lib/isc/win32/include/isc/time.h | 13 ++++++++++++- lib/isc/win32/libisc.def | 1 + lib/isc/win32/time.c | 23 ++++++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/isc/win32/include/isc/time.h b/lib/isc/win32/include/isc/time.h index f346a15219..a8f9b4702e 100644 --- a/lib/isc/win32/include/isc/time.h +++ b/lib/isc/win32/include/isc/time.h @@ -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); /* diff --git a/lib/isc/win32/libisc.def b/lib/isc/win32/libisc.def index ddc8d2e48b..4e5516ebef 100644 --- a/lib/isc/win32/libisc.def +++ b/lib/isc/win32/libisc.def @@ -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 diff --git a/lib/isc/win32/time.c b/lib/isc/win32/time.c index 1981a53e92..d77d1bc299 100644 --- a/lib/isc/win32/time.c +++ b/lib/isc/win32/time.c @@ -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 @@ -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);