From 23f750b068ddf5b20fb5d153a798b22562368992 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 30 Apr 2015 12:52:21 -0700 Subject: [PATCH] Remove libbacktrace definition of gettid. Also simplifies the Darwin implementation of gettid, because apparently libbacktrace had a better way of doing it. Change-Id: I9e14f9176b167405a5aaa5b8a0db0327c7126271 --- libbacktrace/Backtrace.cpp | 2 ++ libbacktrace/BacktraceCurrent.cpp | 2 ++ libbacktrace/backtrace_test.cpp | 17 +++++++++-------- libbacktrace/thread_utils.c | 17 ++--------------- libbacktrace/thread_utils.h | 2 -- libcutils/threads.c | 7 +------ 6 files changed, 16 insertions(+), 31 deletions(-) diff --git a/libbacktrace/Backtrace.cpp b/libbacktrace/Backtrace.cpp index 91ca8b7e5cd0..b2d82976d55a 100644 --- a/libbacktrace/Backtrace.cpp +++ b/libbacktrace/Backtrace.cpp @@ -27,6 +27,8 @@ #include #include +#include + #include "BacktraceLog.h" #include "thread_utils.h" #include "UnwindCurrent.h" diff --git a/libbacktrace/BacktraceCurrent.cpp b/libbacktrace/BacktraceCurrent.cpp index fd1f4da7bcdd..14f04de5eecd 100644 --- a/libbacktrace/BacktraceCurrent.cpp +++ b/libbacktrace/BacktraceCurrent.cpp @@ -29,6 +29,8 @@ #include #include +#include + #include "BacktraceCurrent.h" #include "BacktraceLog.h" #include "ThreadEntry.h" diff --git a/libbacktrace/backtrace_test.cpp b/libbacktrace/backtrace_test.cpp index 4af65923edcb..36c73c5dbbdb 100644 --- a/libbacktrace/backtrace_test.cpp +++ b/libbacktrace/backtrace_test.cpp @@ -30,20 +30,21 @@ #include #include +#include +#include +#include +#include + #include #include -// For the THREAD_SIGNAL definition. -#include "BacktraceCurrent.h" - #include -#include +#include -#include -#include -#include -#include +#include +// For the THREAD_SIGNAL definition. +#include "BacktraceCurrent.h" #include "thread_utils.h" // Number of microseconds per milliseconds. diff --git a/libbacktrace/thread_utils.c b/libbacktrace/thread_utils.c index 6f4cd3c4465f..e75f56e39e39 100644 --- a/libbacktrace/thread_utils.c +++ b/libbacktrace/thread_utils.c @@ -16,25 +16,12 @@ #include "thread_utils.h" -#if defined(__APPLE__) +#if !defined(__BIONIC__) -#include - -// Mac OS >= 10.6 has a system call equivalent to Linux's gettid(). -pid_t gettid() { - return syscall(SYS_thread_selfid); -} - -#elif !defined(__BIONIC__) - -// glibc doesn't implement or export either gettid or tgkill. +// glibc doesn't implement or export tgkill. #include #include -pid_t gettid() { - return syscall(__NR_gettid); -} - int tgkill(int tgid, int tid, int sig) { return syscall(__NR_tgkill, tgid, tid, sig); } diff --git a/libbacktrace/thread_utils.h b/libbacktrace/thread_utils.h index ae4c9290401e..df83581f1620 100644 --- a/libbacktrace/thread_utils.h +++ b/libbacktrace/thread_utils.h @@ -23,8 +23,6 @@ __BEGIN_DECLS int tgkill(int tgid, int tid, int sig); -pid_t gettid(); - __END_DECLS #endif /* _LIBBACKTRACE_THREAD_UTILS_H */ diff --git a/libcutils/threads.c b/libcutils/threads.c index 3d8dd484896c..036f8c5b7ef6 100644 --- a/libcutils/threads.c +++ b/libcutils/threads.c @@ -35,12 +35,7 @@ #ifndef __ANDROID__ pid_t gettid() { #if defined(__APPLE__) - uint64_t owner; - int rc = pthread_threadid_np(NULL, &owner); - if (rc != 0) { - abort(); - } - return owner; + return syscall(SYS_thread_selfid); #elif defined(__linux__) return syscall(__NR_gettid); #elif defined(_WIN32)