summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/config.h2
-rw-r--r--utils/utils.h25
2 files changed, 26 insertions, 1 deletions
diff --git a/utils/config.h b/utils/config.h
index b05785390..8b6ce900a 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -50,7 +50,7 @@ char *strchrnul(const char *s, int c);
#define HAVE_INETATON
#if (defined(_WIN32))
#undef HAVE_INETATON
-#include <winsock.h>
+#include <winsock2.h>
#define EAFNOSUPPORT WSAEAFNOSUPPORT
int inet_aton(const char *cp, struct in_addr *inp);
#else
diff --git a/utils/utils.h b/utils/utils.h
index 84322156e..079708843 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -91,6 +91,31 @@ typedef struct
#define nsmkdir(dir, mode) mkdir((dir))
#endif
+#ifndef timeradd
+#define timeradd(a, aa, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec + (aa)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec + (aa)->tv_usec; \
+ if ((result)->tv_usec >= 1000000) { \
+ ++(result)->tv_sec; \
+ (result)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#endif
+
+#ifndef timersub
+#define timersub(a, aa, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (aa)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (aa)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif
+
+
/**
* Private-word-capable realloc() implementation which
* behaves as most NS libraries expect in the face of