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_getschedparam.cpp b/libc/bionic/pthread_getschedparam.cpp
index 052fb05..4267a0e 100644
--- a/libc/bionic/pthread_getschedparam.cpp
+++ b/libc/bionic/pthread_getschedparam.cpp
@@ -34,15 +34,11 @@
int pthread_getschedparam(pthread_t t, int* policy, sched_param* param) {
ErrnoRestorer errno_restorer;
- pthread_internal_t* thread = __pthread_internal_find(t);
- if (thread == NULL) {
- return ESRCH;
- }
+ pid_t tid = reinterpret_cast<pthread_internal_t*>(t)->tid;
+ if (tid == 0) return ESRCH;
- int rc = sched_getparam(thread->tid, param);
- if (rc == -1) {
- return errno;
- }
- *policy = sched_getscheduler(thread->tid);
+ if (sched_getparam(tid, param) == -1) return errno;
+
+ *policy = sched_getscheduler(tid);
return 0;
}