mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #14714 from jbeich/freebsd
Thread: improve BSD compatibility
This commit is contained in:
commit
f233c77265
1 changed files with 17 additions and 1 deletions
|
@ -33,6 +33,12 @@
|
|||
#include <sys/syscall.h>
|
||||
#endif
|
||||
|
||||
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#include <pthread_np.h>
|
||||
#elif defined(__NetBSD__)
|
||||
#include <lwp.h>
|
||||
#endif
|
||||
|
||||
#ifdef TLS_SUPPORTED
|
||||
static thread_local const char *curThreadName;
|
||||
#endif
|
||||
|
@ -119,6 +125,10 @@ void SetCurrentThreadName(const char* threadName) {
|
|||
pthread_setname_np(pthread_self(), threadName);
|
||||
#elif defined(__APPLE__)
|
||||
pthread_setname_np(threadName);
|
||||
#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
pthread_set_name_np(pthread_self(), threadName);
|
||||
#elif defined(__NetBSD__)
|
||||
pthread_setname_np(pthread_self(), "%s", (void*)threadName);
|
||||
#endif
|
||||
|
||||
// Do nothing
|
||||
|
@ -144,7 +154,7 @@ int GetCurrentThreadIdForDebug() {
|
|||
return 1;
|
||||
#elif PPSSPP_PLATFORM(WINDOWS)
|
||||
return (int)GetCurrentThreadId();
|
||||
#elif PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS) || defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
#elif PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS)
|
||||
uint64_t tid = 0;
|
||||
pthread_threadid_np(NULL, &tid);
|
||||
return (int)tid;
|
||||
|
@ -152,6 +162,12 @@ int GetCurrentThreadIdForDebug() {
|
|||
// See issue 14545
|
||||
return (int)syscall(__NR_gettid);
|
||||
// return (int)gettid();
|
||||
#elif defined(__DragonFly__) || defined(__FreeBSD__)
|
||||
return pthread_getthreadid_np();
|
||||
#elif defined(__NetBSD__)
|
||||
return _lwp_self();
|
||||
#elif defined(__OpenBSD__)
|
||||
return getthrid();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue