pthread_getcpuclockid() is optional POSIX function present
iff _POSIX_THREAD_CPUTIME >= 0

thanks to Miroslav Zagorac:

https://docs.oracle.com/cd/E88353_01/html/E37842/unistd-3head.html

"If a symbolic constant is defined with the value -1, the option is not
supported. Headers, data types, and function interfaces required only for the
option need not be supplied. An application that attempts to use anything
associated only with the option is considered to be requiring an extension.

If a symbolic constant is defined with a value greater than zero, the option
is always supported when the application is executed. All headers, data types,
and functions are present and operate as specified.

If a symbolic constant is defined with the value zero, all headers, data
types, and functions are present. The application can check at runtime to see
whether the option is supported by calling fpathconf(), pathconf(), or
sysconf() with the indicated name parameter."
---
 include/haproxy/compat.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/haproxy/compat.h b/include/haproxy/compat.h
index 0fe5a0b2a..c3889d507 100644
--- a/include/haproxy/compat.h
+++ b/include/haproxy/compat.h
@@ -32,6 +32,11 @@
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 
+/* This is needed for detecting whether optional pthread_getcpuclockid() is 
implemented or not */
+#ifdef USE_THREAD
+#include <pthread.h>
+#endif
+#include <time.h>
 
 /* These are a few short names for commonly used types whose size and sometimes
  * signedness depends on the architecture. Be careful not to rely on a few
@@ -309,6 +314,10 @@ typedef struct { } empty_t;
 #define queue _queue
 #endif
 
+#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) && 
defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)
+#define HAVE_PTHREAD_GETCPUCLOCKID
+#endif
+
 #endif /* _HAPROXY_COMPAT_H */
 
 /*
-- 
2.43.0.windows.1


Reply via email to