mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
windows implementation of isc_time_set
This commit is contained in:
parent
66d720025d
commit
8343d55b3d
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user