summaryrefslogtreecommitdiff
path: root/src/timer.c
diff options
context:
space:
mode:
authorbustico2013-06-20 17:23:52 +0000
committerbustico2013-06-20 17:23:52 +0000
commit1fb1bb59c936ea4d752a12db3d73f490e5b7b6a1 (patch)
tree011808cf654f382692420188af30e71934180357 /src/timer.c
parentbd89957287441872706432d1e283091b4e5cdbc8 (diff)
downloadivy-c-1fb1bb59c936ea4d752a12db3d73f490e5b7b6a1.zip
ivy-c-1fb1bb59c936ea4d752a12db3d73f490e5b7b6a1.tar.gz
ivy-c-1fb1bb59c936ea4d752a12db3d73f490e5b7b6a1.tar.bz2
ivy-c-1fb1bb59c936ea4d752a12db3d73f490e5b7b6a1.tar.xz
initial windows support for ping/pong implementation, to be tested and validated
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/timer.c b/src/timer.c
index 7f9394a..4864321 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -187,3 +187,49 @@ void TimerScan()
}
}
+
+#ifdef WIN32
+
+#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
+ #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
+#else
+ #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
+#endif
+
+
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ FILETIME ft;
+ unsigned __int64 tmpres = 0;
+ static int tzflag = 0;
+
+ if (NULL != tv)
+ {
+ GetSystemTimeAsFileTime(&ft);
+
+ tmpres |= ft.dwHighDateTime;
+ tmpres <<= 32;
+ tmpres |= ft.dwLowDateTime;
+
+ tmpres /= 10; /*convert into microseconds*/
+ /*converting file time to unix epoch*/
+ tmpres -= DELTA_EPOCH_IN_MICROSECS;
+ tv->tv_sec = (long)(tmpres / 1000000UL);
+ tv->tv_usec = (long)(tmpres % 1000000UL);
+ }
+
+ if (NULL != tz)
+ {
+ if (!tzflag)
+ {
+ _tzset();
+ tzflag++;
+ }
+ tz->tz_minuteswest = _timezone / 60;
+ tz->tz_dsttime = _daylight;
+ }
+
+ return 0;
+}
+
+#endif