Use GetSystemTimePreciseAsFileTime() for gettimeofday().
GetSystemTimePreciseAsFileTime() provides the result that is more
high resolution than just the microsecond that gittimeofday() in
Linux provides. So we need to remove some additional precision.

Signed-off-by: Gurucharan Shetty <[email protected]>
---
 lib/timeval.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/timeval.c b/lib/timeval.c
index 07abb4c..5af891a 100644
--- a/lib/timeval.c
+++ b/lib/timeval.c
@@ -392,9 +392,17 @@ clock_gettime(clock_t id, struct timespec *ts)
 void
 xgettimeofday(struct timeval *tv)
 {
+#ifndef _WIN32
     if (gettimeofday(tv, NULL) == -1) {
         VLOG_FATAL("gettimeofday failed (%s)", ovs_strerror(errno));
     }
+#else
+    ULARGE_INTEGER current_time = xgetfiletime();
+
+    tv->tv_sec = (current_time.QuadPart - unix_epoch.QuadPart) / 10000000;
+    tv->tv_usec = ((current_time.QuadPart - unix_epoch.QuadPart) %
+                   10000000) / 10;
+#endif
 }
 
 void
-- 
1.7.9.5

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to