File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / ntp / ports / winnt / libntp / SetSystemTime.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:08:38 2012 UTC (12 years, 10 months ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5


#include "clockstuff.h"
#include "ntp_stdlib.h"

pset_tod_using		set_tod_using = NULL;

time_stepped_callback	step_callback = NULL;

int
ntp_set_tod(
	struct timeval *tv,
	void *tzp
	)
{
	SYSTEMTIME st;
	union {
		FILETIME ft;
		ULONGLONG ull;
	} t;

	UNUSED_ARG(tzp);

	t.ull = FILETIME_1970 +
		(ULONGLONG)tv->tv_sec * 10 * 1000 * 1000 +
		(ULONGLONG)tv->tv_usec * 10;

	if (!FileTimeToSystemTime(&t.ft, &st) || !SetSystemTime(&st)) {
		msyslog(LOG_ERR, "SetSystemTime failed: %m\n");
		return -1;
	}

	if (step_callback)
		(*step_callback)();

	return 0;
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>