Merge "Use gettid directly in frameworks JNI."

This commit is contained in:
Elliott Hughes
2014-08-18 17:40:42 +00:00
committed by Gerrit Code Review
2 changed files with 5 additions and 12 deletions

View File

@@ -1036,16 +1036,9 @@ static void conditionally_log_binder_call(int64_t start_millis,
} }
// We only measure binder call durations to potentially log them if // We only measure binder call durations to potentially log them if
// we're on the main thread. Unfortunately sim-eng doesn't seem to // we're on the main thread.
// have gettid, so we just ignore this and don't log if we can't
// get the thread id.
static bool should_time_binder_calls() { static bool should_time_binder_calls() {
#ifdef HAVE_GETTID return (getpid() == gettid());
return (getpid() == androidGetTid());
#else
#warning no gettid(), so not logging Binder calls...
return false;
#endif
} }
static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj, static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj,

View File

@@ -268,7 +268,7 @@ static void android_os_Process_setCanSelfBackground(JNIEnv* env, jobject clazz,
// Establishes the calling thread as illegal to put into the background. // Establishes the calling thread as illegal to put into the background.
// Typically used only for the system process's main looper. // Typically used only for the system process's main looper.
#if GUARD_THREAD_PRIORITY #if GUARD_THREAD_PRIORITY
ALOGV("Process.setCanSelfBackground(%d) : tid=%d", bgOk, androidGetTid()); ALOGV("Process.setCanSelfBackground(%d) : tid=%d", bgOk, gettid());
{ {
Mutex::Autolock _l(gKeyCreateMutex); Mutex::Autolock _l(gKeyCreateMutex);
if (gBgKey == -1) { if (gBgKey == -1) {
@@ -303,7 +303,7 @@ void android_os_Process_setThreadPriority(JNIEnv* env, jobject clazz,
// if we're putting the current thread into the background, check the TLS // if we're putting the current thread into the background, check the TLS
// to make sure this thread isn't guarded. If it is, raise an exception. // to make sure this thread isn't guarded. If it is, raise an exception.
if (pri >= ANDROID_PRIORITY_BACKGROUND) { if (pri >= ANDROID_PRIORITY_BACKGROUND) {
if (pid == androidGetTid()) { if (pid == gettid()) {
void* bgOk = pthread_getspecific(gBgKey); void* bgOk = pthread_getspecific(gBgKey);
if (bgOk == ((void*)0xbaad)) { if (bgOk == ((void*)0xbaad)) {
ALOGE("Thread marked fg-only put self in background!"); ALOGE("Thread marked fg-only put self in background!");
@@ -330,7 +330,7 @@ void android_os_Process_setThreadPriority(JNIEnv* env, jobject clazz,
void android_os_Process_setCallingThreadPriority(JNIEnv* env, jobject clazz, void android_os_Process_setCallingThreadPriority(JNIEnv* env, jobject clazz,
jint pri) jint pri)
{ {
android_os_Process_setThreadPriority(env, clazz, androidGetTid(), pri); android_os_Process_setThreadPriority(env, clazz, gettid(), pri);
} }
jint android_os_Process_getThreadPriority(JNIEnv* env, jobject clazz, jint android_os_Process_getThreadPriority(JNIEnv* env, jobject clazz,