aboutsummaryrefslogtreecommitdiff
path: root/lib/timeval.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-06-03 12:46:32 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-06-03 12:46:32 +0000
commit9aec0fc7deaeb3c80ac61d6aeaf2dcc1d8e1e266 (patch)
tree3595b8c88ba186848b63a4d0a3d50ac3b884ec89 /lib/timeval.c
parentbce5e0d82cfde0885e83ddfe1956dbb97ab2b0f3 (diff)
T. Bharath fixed higher resolution time for windows builds
Diffstat (limited to 'lib/timeval.c')
-rw-r--r--lib/timeval.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/lib/timeval.c b/lib/timeval.c
index d076eccdf..140bc5506 100644
--- a/lib/timeval.c
+++ b/lib/timeval.c
@@ -32,22 +32,36 @@
int
gettimeofday (struct timeval *tp, void *nothing)
{
- SYSTEMTIME st;
- time_t tt;
- struct tm tmtm;
- /* mktime converts local to UTC */
- GetLocalTime (&st);
- tmtm.tm_sec = st.wSecond;
- tmtm.tm_min = st.wMinute;
- tmtm.tm_hour = st.wHour;
- tmtm.tm_mday = st.wDay;
- tmtm.tm_mon = st.wMonth - 1;
- tmtm.tm_year = st.wYear - 1900;
- tmtm.tm_isdst = -1;
- tt = mktime (&tmtm);
- tp->tv_sec = tt;
- tp->tv_usec = st.wMilliseconds * 1000;
- return 1;
+#ifdef WITHOUT_MM_LIB
+ SYSTEMTIME st;
+ time_t tt;
+ struct tm tmtm;
+ /* mktime converts local to UTC */
+ GetLocalTime (&st);
+ tmtm.tm_sec = st.wSecond;
+ tmtm.tm_min = st.wMinute;
+ tmtm.tm_hour = st.wHour;
+ tmtm.tm_mday = st.wDay;
+ tmtm.tm_mon = st.wMonth - 1;
+ tmtm.tm_year = st.wYear - 1900;
+ tmtm.tm_isdst = -1;
+ tt = mktime (&tmtm);
+ tp->tv_sec = tt;
+ tp->tv_usec = st.wMilliseconds * 1000;
+#else
+ /**
+ ** The earlier time calculations using GetLocalTime
+ ** had a time resolution of 10ms.The timeGetTime, part
+ ** of multimedia apis offer a better time resolution
+ ** of 1ms.Need to link against winmm.lib for this
+ **/
+ unsigned long Ticks = 0;
+ Ticks = timeGetTime();
+ tp->tv_sec = Ticks%1000;
+ tp->tv_usec = (Ticks - (tp->tv_sec*1000))*1000;
+
+#endif
+ return 1;
}
#define HAVE_GETTIMEOFDAY
#endif