aboutsummaryrefslogtreecommitdiff
path: root/osdep.h
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2011-03-13 10:30:52 +0000
committerBlue Swirl <blauwirbel@gmail.com>2011-03-15 20:49:56 +0000
commitad620c29c2da573e3a5f13f5b1eb2694fee64cfb (patch)
tree76e294551d7fb7078c676989722b5758d1d8dc81 /osdep.h
parent31d3c9b8c15d7b42f508d5fc2adc4abb7c732b70 (diff)
win32: implement missing timersub
Implement and wrap timersub() for Win32. Acked-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'osdep.h')
-rw-r--r--osdep.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/osdep.h b/osdep.h
index 27eedcf100..5e4886030e 100644
--- a/osdep.h
+++ b/osdep.h
@@ -8,9 +8,7 @@
#include <sys/signal.h>
#endif
-#ifndef _WIN32
#include <sys/time.h>
-#endif
#ifndef glue
#define xglue(x, y) x ## y
@@ -131,4 +129,21 @@ int qemu_madvise(void *addr, size_t len, int advice);
int qemu_create_pidfile(const char *filename);
+#ifdef _WIN32
+static inline void qemu_timersub(const struct timeval *val1,
+ const struct timeval *val2,
+ struct timeval *res)
+{
+ res->tv_sec = val1->tv_sec - val2->tv_sec;
+ if (val1->tv_usec < val2->tv_usec) {
+ res->tv_sec--;
+ res->tv_usec = val1->tv_usec - val2->tv_usec + 1000 * 1000;
+ } else {
+ res->tv_usec = val1->tv_usec - val2->tv_usec;
+ }
+}
+#else
+#define qemu_timersub timersub
+#endif
+
#endif