Bug 1541216 - Update PR_SetCurrentThreadName() to use prctl(PR_SET_NAME) on Android r=eoger NSPR_4_21_BRANCH
☠☠ backed out by bca82e260d71 ☠ ☠
authorEdouard Oger <eoger@fastmail.com>
Tue, 07 May 2019 15:04:28 +0000
branchNSPR_4_21_BRANCH
changeset 4812 3262b1497babd06aa111be048ff514092c2d6f87
parent 4811 fee3785aed00c5056946df0c70f04b53eb0b4077
child 4813 bca82e260d71437fb6f74e1dd2fcdecbffda20d4
push id318
push userjjones@mozilla.com
push dateTue, 07 May 2019 15:05:20 +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)