Remove libbacktrace definition of gettid.

Also simplifies the Darwin implementation of gettid, because
apparently libbacktrace had a better way of doing it.

Bug: 19517541

(cherry picked from commit 23f750b068)

Change-Id: I2f888e8ed7a2f5719973786cbcbb399a81867ee9
This commit is contained in:
Dan Albert 2015-04-30 12:52:21 -07:00 committed by Christopher Ferris
parent cd206b3900
commit 428fad97a0
6 changed files with 17 additions and 32 deletions

View file

@ -27,6 +27,8 @@
#include <backtrace/Backtrace.h>
#include <backtrace/BacktraceMap.h>
#include <cutils/threads.h>
#include "BacktraceLog.h"
#include "thread_utils.h"
#include "UnwindCurrent.h"

View file

@ -29,6 +29,8 @@
#include <backtrace/Backtrace.h>
#include <backtrace/BacktraceMap.h>
#include <cutils/threads.h>
#include "BacktraceCurrent.h"
#include "BacktraceLog.h"
#include "ThreadEntry.h"

View file

@ -30,20 +30,21 @@
#include <time.h>
#include <unistd.h>
#include <backtrace/Backtrace.h>
#include <backtrace/BacktraceMap.h>
// For the THREAD_SIGNAL definition.
#include "BacktraceCurrent.h"
#include <cutils/atomic.h>
#include <gtest/gtest.h>
#include <algorithm>
#include <memory>
#include <string>
#include <vector>
#include <backtrace/Backtrace.h>
#include <backtrace/BacktraceMap.h>
#include <cutils/atomic.h>
#include <cutils/threads.h>
#include <gtest/gtest.h>
// For the THREAD_SIGNAL definition.
#include "BacktraceCurrent.h"
#include "thread_utils.h"
// Number of microseconds per milliseconds.

View file

@ -16,25 +16,12 @@
#include "thread_utils.h"
#if defined(__APPLE__)
#if !defined(__BIONIC__)
#include <sys/syscall.h>
// 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 <unistd.h>
#include <sys/syscall.h>
pid_t gettid() {
return syscall(__NR_gettid);
}
int tgkill(int tgid, int tid, int sig) {
return syscall(__NR_tgkill, tgid, tid, sig);
}

View file

@ -23,8 +23,6 @@ __BEGIN_DECLS
int tgkill(int tgid, int tid, int sig);
pid_t gettid();
__END_DECLS
#endif /* _LIBBACKTRACE_THREAD_UTILS_H */

View file

@ -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)