From 75c619e372f02f8225d158fd514f01bd04857d3b Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 3 Dec 2012 10:41:28 +0100 Subject: [PATCH] More fixes for Windows. In particular, Windows does support many of the timer* macros, except timeradd and timersub. --- src/dropin.h | 18 ++++++++++++++++++ src/event.c | 1 + src/process.c | 1 + 3 files changed, 20 insertions(+) diff --git a/src/dropin.h b/src/dropin.h index c6cabba..61143eb 100644 --- a/src/dropin.h +++ b/src/dropin.h @@ -45,4 +45,22 @@ extern int gettimeofday(struct timeval *, void *); extern int usleep(long long usec); #endif +#ifndef timeradd +#define timeradd(a, b, r) do {\ + (r)->tv_sec = (a)->tv_sec + (b)->tv_sec;\ + (r)->tv_usec = (a)->tv_usec + (b)->tv_usec;\ + if((r)->tv_usec >= 1000000)\ + (r)->tv_sec++, (r)->tv_usec -= 1000000;\ +} while (0) +#endif + +#ifndef timersub +#define timersub(a, b, r) do {\ + (r)->tv_sec = (a)->tv_sec - (b)->tv_sec;\ + (r)->tv_usec = (a)->tv_usec - (b)->tv_usec;\ + if((r)->tv_usec < 1000000)\ + (r)->tv_sec--, (r)->tv_usec += 1000000;\ +} while (0) +#endif + #endif /* __DROPIN_H__ */ diff --git a/src/event.c b/src/event.c index 44a1f87..0dde994 100644 --- a/src/event.c +++ b/src/event.c @@ -19,6 +19,7 @@ #include "system.h" +#include "dropin.h" #include "event.h" #include "net.h" #include "utils.h" diff --git a/src/process.c b/src/process.c index 1093ea8..2fd3d93 100644 --- a/src/process.c +++ b/src/process.c @@ -25,6 +25,7 @@ #include "control.h" #include "device.h" #include "edge.h" +#include "event.h" #include "logger.h" #include "net.h" #include "node.h" -- 2.25.1