From 8d18b8963b6c7d5d6eaae8e17680b5b223fc559d Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Thu, 18 Oct 2012 18:13:47 +0000
Subject: [PATCH] Add support for pthread_setname_np() on systems with GLibC
 2.12 or higher.

---
 src/xpdev/threadwrap.h | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/xpdev/threadwrap.h b/src/xpdev/threadwrap.h
index 17b2c8227b..7665d0751c 100644
--- a/src/xpdev/threadwrap.h
+++ b/src/xpdev/threadwrap.h
@@ -100,14 +100,19 @@ pthread_mutex_t pthread_mutex_initializer_np(BOOL recursive);
 #if defined(_POSIX_THREADS)
 
 #ifdef _DEBUG
-#if defined (__FreeBSD__) || defined (__OpenBSD__)
-#include <pthread_np.h>
-#define	SetThreadName(c)	pthread_set_name_np(pthread_self(),c)
+ #if defined (__FreeBSD__) || defined (__OpenBSD__)
+  #include <pthread_np.h>
+  #define	SetThreadName(c)	pthread_set_name_np(pthread_self(),c)
+ #elsif defined(__GLIBC__)
+  #include <features.h>
+  #if (__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12))
+   #define	SetThreadName(c)	pthread_setname_np(pthread_self(),c)
+  #endif
+ #else
+  #define SetThreadName(c)
+ #endif
 #else
-#define SetThreadName(c)
-#endif
-#else
-#define SetThreadName(c)
+ #define SetThreadName(c)
 #endif
 
 #else
-- 
GitLab