Stop checking the global thread list in several trivial cases.
Since removing the global thread is hard, let's take the different
groups of functions individually.
The existing code was racy anyway, because the thread might still be
on the list but have exited (leaving tid == 0).
Bug: http://b/19636317
Test: ran tests
Change-Id: Icc0986ff124d5f9b8a653edf718c549d1563973b
diff --git a/libc/bionic/pthread_setname_np.cpp b/libc/bionic/pthread_setname_np.cpp
index 6d2880e..0778a3c 100644
--- a/libc/bionic/pthread_setname_np.cpp
+++ b/libc/bionic/pthread_setname_np.cpp
@@ -43,14 +43,9 @@
#define MAX_TASK_COMM_LEN 16
static int __open_task_comm_fd(pthread_t t, int flags) {
- pthread_internal_t* thread = __pthread_internal_find(t);
- if (thread == nullptr) {
- errno = ENOENT;
- return -1;
- }
-
char comm_name[64];
- snprintf(comm_name, sizeof(comm_name), "/proc/self/task/%d/comm", thread->tid);
+ snprintf(comm_name, sizeof(comm_name), "/proc/self/task/%d/comm",
+ reinterpret_cast<pthread_internal_t*>(t)->tid);
return open(comm_name, O_CLOEXEC | flags);
}