Windows: Implement gettimeofday().
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Johannes Sixt committed
Dec 1, 2007 at 21:51 UTC
a42a0c2e715d6783a6f9b75a8f2c9a48bf499c47
1 file changed
+14
-1
compat/mingw.c
+14
-1
@@ -38,7 +38,20 @@ int mkstemp(char *template)
38
39
int gettimeofday(struct timeval *tv, void *tz)
40
{
41
- return -1;
41
+ SYSTEMTIME st;
42
+ struct tm tm;
43
+ GetSystemTime(&st);
44
+ tm.tm_year = st.wYear-1900;
45
+ tm.tm_mon = st.wMonth-1;
46
+ tm.tm_mday = st.wDay;
47
+ tm.tm_hour = st.wHour;
48
+ tm.tm_min = st.wMinute;
49
+ tm.tm_sec = st.wSecond;
50
+ tv->tv_sec = tm_to_time_t(&tm);
51
+ if (tv->tv_sec < 0)
52
+ return -1;
53
+ tv->tv_usec = st.wMilliseconds*1000;
54
+ return 0;
55
}
56
57
int poll(struct pollfd *ufds, unsigned int nfds, int timeout)