Revert "Stop checking the global thread list in several trivial cases."
This reverts commit f5a4992b7186c01b98cb9400b2b5b490805a87bb.
Breaks OMX_ImgEnc in cameraserver (http://b/35088254).
Change-Id: I6dcf12706a184b0b8b72451584567a42dfa1bb4f
diff --git a/libc/bionic/pthread_getcpuclockid.cpp b/libc/bionic/pthread_getcpuclockid.cpp
index dbfb7d4..2bf2004 100644
--- a/libc/bionic/pthread_getcpuclockid.cpp
+++ b/libc/bionic/pthread_getcpuclockid.cpp
@@ -31,11 +31,13 @@
#include "pthread_internal.h"
int pthread_getcpuclockid(pthread_t t, clockid_t* clockid) {
- pid_t tid = reinterpret_cast<pthread_internal_t*>(t)->tid;
- if (tid == 0) return ESRCH;
+ pthread_internal_t* thread = __pthread_internal_find(t);
+ if (thread == NULL) {
+ return ESRCH;
+ }
// The tid is stored in the top bits, but negated.
- clockid_t result = ~static_cast<clockid_t>(tid) << 3;
+ clockid_t result = ~static_cast<clockid_t>(thread->tid) << 3;
// Bits 0 and 1: clock type (0 = CPUCLOCK_PROF, 1 = CPUCLOCK_VIRT, 2 = CPUCLOCK_SCHED).
result |= 2;
// Bit 2: thread (set) or process (clear)?