Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Merge "Remove libbacktrace definition of gettid."
Browse files Browse the repository at this point in the history
  • Loading branch information
DanAlbert authored and Gerrit Code Review committed Apr 30, 2015
2 parents f24e49a + 23f750b commit 4d66c9e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 31 deletions.
2 changes: 2 additions & 0 deletions libbacktrace/Backtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions libbacktrace/BacktraceCurrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 9 additions & 8 deletions libbacktrace/backtrace_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@
#include <time.h>
#include <unistd.h>

#include <algorithm>
#include <memory>
#include <string>
#include <vector>

#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 <cutils/threads.h>

#include <algorithm>
#include <memory>
#include <string>
#include <vector>
#include <gtest/gtest.h>

// For the THREAD_SIGNAL definition.
#include "BacktraceCurrent.h"
#include "thread_utils.h"

// Number of microseconds per milliseconds.
Expand Down
17 changes: 2 additions & 15 deletions libbacktrace/thread_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions libbacktrace/thread_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ __BEGIN_DECLS

int tgkill(int tgid, int tid, int sig);

pid_t gettid();

__END_DECLS

#endif /* _LIBBACKTRACE_THREAD_UTILS_H */
7 changes: 1 addition & 6 deletions libcutils/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4d66c9e

Please sign in to comment.