--- /dev/null
+/*\r
+ * timeval.h 1.0 01/12/19\r
+ *\r
+ * Defines gettimeofday, timeval, etc. for Win32\r
+ *\r
+ * By Wu Yongwei\r
+ *\r
+ */\r
+\r
+#ifndef _TIMEVAL_H\r
+#define _TIMEVAL_H\r
+\r
+#ifdef _WIN32\r
+\r
+#define WIN32_LEAN_AND_MEAN\r
+#include <windows.h>\r
+#include <time.h>\r
+\r
+#ifndef __GNUC__\r
+#define EPOCHFILETIME (116444736000000000i64)\r
+#else\r
+#define EPOCHFILETIME (116444736000000000LL)\r
+#endif\r
+\r
+struct timeval {\r
+ long tv_sec; /* seconds */\r
+ long tv_usec; /* microseconds */\r
+};\r
+\r
+struct timezone {\r
+ int tz_minuteswest; /* minutes W of Greenwich */\r
+ int tz_dsttime; /* type of dst correction */\r
+};\r
+\r
+__inline int gettimeofday(struct timeval *tv, struct timezone *tz)\r
+{\r
+ FILETIME ft;\r
+ LARGE_INTEGER li;\r
+ __int64 t;\r
+ static int tzflag;\r
+\r
+ if (tv)\r
+ {\r
+ GetSystemTimeAsFileTime(&ft);\r
+ li.LowPart = ft.dwLowDateTime;\r
+ li.HighPart = ft.dwHighDateTime;\r
+ t = li.QuadPart; /* In 100-nanosecond intervals */\r
+ t -= EPOCHFILETIME; /* Offset to the Epoch time */\r
+ t /= 10; /* In microseconds */\r
+ tv->tv_sec = (long)(t / 1000000);\r
+ tv->tv_usec = (long)(t % 1000000);\r
+ }\r
+\r
+ if (tz)\r
+ {\r
+ if (!tzflag)\r
+ {\r
+ _tzset();\r
+ tzflag++;\r
+ }\r
+ tz->tz_minuteswest = _timezone / 60;\r
+ tz->tz_dsttime = _daylight;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+#else /* _WIN32 */\r
+\r
+#include <sys/time.h>\r
+\r
+#endif /* _WIN32 */\r
+\r
+#endif /* _TIMEVAL_H */\r
+\r
+\r