summaryrefslogtreecommitdiff
path: root/ports/winnt/libntp/SetSystemTime.c
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2015-02-05 20:53:33 +0000
committerCy Schubert <cy@FreeBSD.org>2015-02-05 20:53:33 +0000
commitf7cba3a80d9ebefc57776fffd17a4ae68f72e494 (patch)
treedc1c5074828f0c5fafe2fb8f5599339dfdc5bc97 /ports/winnt/libntp/SetSystemTime.c
parent44a728f815af203cd7a91db83b06325818433463 (diff)
Notes
Diffstat (limited to 'ports/winnt/libntp/SetSystemTime.c')
-rw-r--r--ports/winnt/libntp/SetSystemTime.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/ports/winnt/libntp/SetSystemTime.c b/ports/winnt/libntp/SetSystemTime.c
new file mode 100644
index 0000000000000..8cb43173f22e6
--- /dev/null
+++ b/ports/winnt/libntp/SetSystemTime.c
@@ -0,0 +1,34 @@
+
+#include <config.h>
+
+#include "clockstuff.h"
+#include "ntp_stdlib.h"
+#include "ntp_unixtime.h"
+
+pset_tod_using set_tod_using = 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");
+ return -1;
+ }
+
+ return 0;
+}