Jelajahi Sumber

Merge pull request #90 from mahlemiut/master

fix building with glibc < 2.12
Branimir Karadžić 10 tahun lalu
induk
melakukan
9ad805f85a
1 mengubah file dengan 12 tambahan dan 1 penghapusan
  1. 12 1
      include/bx/thread.h

+ 12 - 1
include/bx/thread.h

@@ -8,6 +8,11 @@
 
 
 #if BX_PLATFORM_POSIX
 #if BX_PLATFORM_POSIX
 #	include <pthread.h>
 #	include <pthread.h>
+	#if defined(__GLIBC__)
+		#if!((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)))
+			#include <sys/prctl.h>
+		#endif
+	#endif
 #elif BX_PLATFORM_WINRT
 #elif BX_PLATFORM_WINRT
 using namespace Platform;
 using namespace Platform;
 using namespace Windows::Foundation;
 using namespace Windows::Foundation;
@@ -149,7 +154,13 @@ namespace bx
 		{
 		{
 #if BX_PLATFORM_OSX || BX_PLATFORM_IOS
 #if BX_PLATFORM_OSX || BX_PLATFORM_IOS
 			pthread_setname_np(_name);
 			pthread_setname_np(_name);
-#elif (BX_PLATFORM_LINUX && defined(__GLIBC__)) || BX_PLATFORM_BSD
+#elif (BX_PLATFORM_LINUX && defined(__GLIBC__))
+	#if (__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12))
+			pthread_setname_np(m_handle, _name);
+	#else
+			prctl(PR_SET_NAME,_name,0,0,0);
+	#endif
+#elif BX_PLATFORM_BSD
 			pthread_setname_np(m_handle, _name);
 			pthread_setname_np(m_handle, _name);
 #elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC
 #elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC
 #	pragma pack(push, 8)
 #	pragma pack(push, 8)