Thread api, macOS implementation completion. ##core

This commit is contained in:
David CARLIER 2019-08-06 20:12:10 +01:00 committed by radare
parent 89325449d5
commit 0c40abc00d
3 changed files with 11 additions and 1 deletions

View File

@ -23,6 +23,9 @@
#else
#define HAVE_PTHREAD_NP 1
#endif
#if __APPLE__
#include <pthread.h>
#endif
#if __FreeBSD__ || __OpenBSD__ || __DragonFly__
#include <pthread_np.h>
#endif

View File

@ -539,6 +539,8 @@ R_API int r_sys_thp_mode(void) {
}
return ret;
#else
return 0;
#endif
}

View File

@ -64,6 +64,11 @@ R_API bool r_th_setname(RThread *th, const char *name) {
eprintf ("Failed to set thread name\n");
return false;
}
#elif __APPLE__
if (pthread_setname_np (name) != 0) {
eprintf ("Failed to set thread name\n");
return false;
}
#elif __FreeBSD__ || __OpenBSD__ || __DragonFly__
pthread_set_name_np (th->tid, name);
#elif __NetBSD__
@ -80,7 +85,7 @@ R_API bool r_th_setname(RThread *th, const char *name) {
R_API bool r_th_getname(RThread *th, char *name, size_t len) {
#if defined(HAVE_PTHREAD_NP) && HAVE_PTHREAD_NP
#if __linux__ || __NetBSD__
#if __linux__ || __NetBSD__ || __APPLE__
if (pthread_getname_np (th->tid, name, len) != 0) {
eprintf ("Failed to get thread name\n");
return false;