aboutsummaryrefslogtreecommitdiff
path: root/osdep.h
diff options
context:
space:
mode:
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 748df5416b..970d767078 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
@@ -132,4 +130,21 @@ int qemu_madvise(void *addr, size_t len, int advice);
int qemu_create_pidfile(const char *filename);
int qemu_get_thread_id(void);
+#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