Commit 8343d55b authored by Mark Andrews's avatar Mark Andrews
Browse files

windows implementation of isc_time_set

parent 66d72002
......@@ -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);
/*
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment