diff options
author | Jan Beich <jbeich@tormail.org> | 2016-01-31 12:35:58 -0800 |
---|---|---|
committer | Jan Beich <jbeich@tormail.org> | 2016-01-31 12:35:58 -0800 |
commit | 5357a91ace3e188943437e7db8abc0cae1f65a89 (patch) | |
tree | 17227d71186dda7fd08bde65f553f50e03b40b82 | |
parent | a35aa51d69b5f4af2ff5821d78f6cf1af0faf398 (diff) | |
download | nspr-hg-5357a91ace3e188943437e7db8abc0cae1f65a89.tar.gz |
Bug 782111: Fix usage of pthread_set_name_np() on BSDs. r=wtcNSPR_4_12_BETA2
-rw-r--r-- | pr/src/pthreads/ptthread.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pr/src/pthreads/ptthread.c b/pr/src/pthreads/ptthread.c index de90e4d3..9e12606e 100644 --- a/pr/src/pthreads/ptthread.c +++ b/pr/src/pthreads/ptthread.c @@ -21,6 +21,10 @@ #include <signal.h> #include <dlfcn.h> +#if defined(OPENBSD) || defined(FREEBSD) || defined(DRAGONFLY) +#include <pthread_np.h> +#endif + #ifdef SYMBIAN /* In Open C sched_get_priority_min/max do not work properly, so we undefine * _POSIX_THREAD_PRIORITY_SCHEDULING here. @@ -1733,7 +1737,7 @@ PR_IMPLEMENT(PRStatus) PR_SetCurrentThreadName(const char *name) { PRThread *thread; size_t nameLen; - int result; + int result = 0; if (!name) { PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); @@ -1751,8 +1755,10 @@ PR_IMPLEMENT(PRStatus) PR_SetCurrentThreadName(const char *name) return PR_FAILURE; memcpy(thread->name, name, nameLen + 1); -#if defined(OPENBSD) || defined(FREEBSD) - result = pthread_set_name_np(thread->id, name); +#if defined(OPENBSD) || defined(FREEBSD) || defined(DRAGONFLY) + pthread_set_name_np(thread->id, name); +#elif defined(NETBSD) + result = pthread_setname_np(thread->id, "%s", (void *)name); #else /* not BSD */ /* * On OSX, pthread_setname_np is only available in 10.6 or later, so test |