diff options
Diffstat (limited to 'src/util/u_thread.h')
-rw-r--r-- | src/util/u_thread.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/u_thread.h b/src/util/u_thread.h index 8eab3a5b94a..6b5458af86a 100644 --- a/src/util/u_thread.h +++ b/src/util/u_thread.h @@ -28,6 +28,7 @@ #define U_THREAD_H_ #include <stdint.h> +#include <stdbool.h> #include "c11/threads.h" @@ -88,4 +89,15 @@ u_thread_get_time_nano(thrd_t thread) #endif } +static inline bool u_thread_is_self(thrd_t thread) +{ +#if defined(HAVE_PTHREAD) +# if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \ + (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12)) + return pthread_equal(pthread_self(), thread); +# endif +#endif + return false; +} + #endif /* U_THREAD_H_ */ |