bx: support glibc-based BSD platforms

On GNU/kFreeBSD, pthread_setname_np can be found in glibc's pthread.h
(same as on GNU/Linux).  pthread_np.h does not exist there.
This commit is contained in:
Steven Chamberlain 2016-07-13 12:38:20 +01:00
parent 8fb0ab46bb
commit f2ad7351ef

View File

@ -8,7 +8,7 @@
#if BX_PLATFORM_POSIX #if BX_PLATFORM_POSIX
# include <pthread.h> # include <pthread.h>
# if BX_PLATFORM_BSD # if defined(BX_PLATFORM_BSD) && !defined(__GLIBC__)
# include <pthread_np.h> # include <pthread_np.h>
# endif # endif
# if defined(__GLIBC__) && !( (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12) ) ) # if defined(__GLIBC__) && !( (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12) ) )
@ -157,12 +157,10 @@ 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 #elif defined(__GLIBC__) && (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12) )
# if defined(__GLIBC__) && (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12) )
pthread_setname_np(m_handle, _name); pthread_setname_np(m_handle, _name);
# else #elif BX_PLATFORM_LINUX
prctl(PR_SET_NAME,_name, 0, 0, 0); prctl(PR_SET_NAME,_name, 0, 0, 0);
# endif // defined(__GLIBC__) ...
#elif BX_PLATFORM_BSD #elif BX_PLATFORM_BSD
#ifdef __NetBSD__ #ifdef __NetBSD__
pthread_setname_np(m_handle, "%s", (void *)_name); pthread_setname_np(m_handle, "%s", (void *)_name);