OSDN Git Service

merge from open-source master
[android-x86/dalvik.git] / vm / Thread.c
index f15b5dc..50f5416 100644 (file)
@@ -1313,7 +1313,6 @@ static bool createFakeRunFrame(Thread* thread)
  */
 static void setThreadName(const char *threadName)
 {
-#if defined(HAVE_PRCTL)
     int hasAt = 0;
     int hasDot = 0;
     const char *s = threadName;
@@ -1328,7 +1327,13 @@ static void setThreadName(const char *threadName)
     } else {
         s = threadName + len - 15;
     }
+#if defined(HAVE_PTHREAD_SETNAME_NP)
+    if (pthread_setname_np(pthread_self(), s) != 0)
+        LOGW("Unable to set the name of the current thread\n");
+#elif defined(HAVE_PRCTL)
     prctl(PR_SET_NAME, (unsigned long) s, 0, 0, 0);
+#else
+    LOGD("Unable to set current thread's name: %s\n", s);
 #endif
 }