Bug 1541216 - Update PR_SetCurrentThreadName() to use prctl(PR_SET_NAME) on Android r=eoger
authorEdouard Oger <eoger@fastmail.com>
Tue, 07 May 2019 15:04:28 +0000
changeset 4814 0f639641dbe69aaa754ea446d52125ba43c2b9a3
parent 4809 d652179bd8258fc9341b2e038783bf78e3531f1b
child 4815 4d940761b90a7a6833a2860de84f940b8856af15
push id319
push userjjones@mozilla.com
push dateTue, 07 May 2019 15:57:50 +0000
reviewerseoger
bugs1541216
Bug 1541216 - Update PR_SetCurrentThreadName() to use prctl(PR_SET_NAME) on Android r=eoger Differential Revision: https://phabricator.services.mozilla.com/D25880
pr/src/pthreads/ptthread.c
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -20,16 +20,20 @@
 #include <string.h>
 #include <signal.h>
 #include <dlfcn.h>
 
 #if defined(OPENBSD) || defined(FREEBSD) || defined(DRAGONFLY)
 #include <pthread_np.h>
 #endif
 
+#if defined(ANDROID)
+#include <sys/prctl.h>
+#endif
+
 #ifdef SYMBIAN
 /* In Open C sched_get_priority_min/max do not work properly, so we undefine
  * _POSIX_THREAD_PRIORITY_SCHEDULING here.
  */
 #undef _POSIX_THREAD_PRIORITY_SCHEDULING
 #endif
 
 #ifdef _PR_NICE_PRIORITY_SCHEDULING
@@ -1628,16 +1632,18 @@ PR_IMPLEMENT(PRStatus) PR_SetCurrentThre
     nameLen = strlen(name);
     thread->name = (char *)PR_Malloc(nameLen + 1);
     if (!thread->name)
         return PR_FAILURE;
     memcpy(thread->name, name, nameLen + 1);
 
 #if defined(OPENBSD) || defined(FREEBSD) || defined(DRAGONFLY)
     pthread_set_name_np(thread->id, name);
+#elif defined(ANDROID)
+    prctl(PR_SET_NAME, (unsigned long)(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
      * for it at runtime.  It also may not be available on all linux distros.
      */
 #if defined(DARWIN)