]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: compat: make sure to always define clockid_t
authorWilly Tarreau <w@1wt.eu>
Mon, 20 May 2019 18:18:26 +0000 (20:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 20 May 2019 18:24:10 +0000 (20:24 +0200)
In order to ease the internal time API, we'll have the threads time always
present even when threads are disabled. Let's make sure clockid_t, and the
minimum clock times are defined even on older or non-compatible systems.

include/common/compat.h

index 34d1b35c591097a21423076269074d41ec2f3d7c..d43b89dd614f68b186d1d7f8214a30d7ae2574e4 100644 (file)
@@ -23,6 +23,8 @@
 #define _COMMON_COMPAT_H
 
 #include <limits.h>
+#include <time.h>
+#include <unistd.h>
 /* This is needed on Linux for Netfilter includes */
 #include <sys/param.h>
 #include <sys/types.h>
 #define F_SETPIPE_SZ (1024 + 7)
 #endif
 
+/* systems without such defines do not know clockid_t */
+#if !defined(_POSIX_TIMERS) || (_POSIX_C_SOURCE < 199309L)
+#define clockid_t int
+#undef CLOCK_REALTIME
+#undef CLOCK_MONOTONIC
+#undef CLOCK_THREAD_CPUTIME_ID
+#define CLOCK_REALTIME           0
+#define CLOCK_MONOTONIC          1
+#define CLOCK_THREAD_CPUTIME_ID  2
+#endif
+
 #if defined(TPROXY) && defined(NETFILTER)
 #include <linux/types.h>
 #include <linux/netfilter_ipv6.h>