summaryrefslogtreecommitdiff
path: root/compat/mingw.c
diff options
context:
space:
mode:
authorJohannes Sixt <johannes.sixt@telecom.at>2007-12-01 20:51:20 (GMT)
committerJohannes Sixt <johannes.sixt@telecom.at>2008-06-23 11:40:29 (GMT)
commita42a0c2e715d6783a6f9b75a8f2c9a48bf499c47 (patch)
treec5c51d42b4c32579ba1c7cc3c87dbcd9846d3b39 /compat/mingw.c
parentbb5799d6ef3ad7ee70a138b82e67b93e3aaa8017 (diff)
downloadgit-a42a0c2e715d6783a6f9b75a8f2c9a48bf499c47.zip
git-a42a0c2e715d6783a6f9b75a8f2c9a48bf499c47.tar.gz
git-a42a0c2e715d6783a6f9b75a8f2c9a48bf499c47.tar.bz2
Windows: Implement gettimeofday().
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Diffstat (limited to 'compat/mingw.c')
-rw-r--r--compat/mingw.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index c6a5c1b..57af486 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -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)