Skip to content

Commit

Permalink
Windows: Implement gettimeofday().
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
  • Loading branch information
Johannes Sixt committed Jun 23, 2008
1 parent bb5799d commit a42a0c2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,20 @@ int mkstemp(char *template)

int gettimeofday(struct timeval *tv, void *tz)
{
return -1;
SYSTEMTIME st;
struct tm tm;
GetSystemTime(&st);
tm.tm_year = st.wYear-1900;
tm.tm_mon = st.wMonth-1;
tm.tm_mday = st.wDay;
tm.tm_hour = st.wHour;
tm.tm_min = st.wMinute;
tm.tm_sec = st.wSecond;
tv->tv_sec = tm_to_time_t(&tm);
if (tv->tv_sec < 0)
return -1;
tv->tv_usec = st.wMilliseconds*1000;
return 0;
}

int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
Expand Down

0 comments on commit a42a0c2

Please sign in to comment.