From 684b442b9faaf0c9f4466ceb7ca915f010f3edf2 Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Sat, 17 Sep 2016 18:29:03 +0200 Subject: [PATCH] libcutils: Fix thread ID on macOS macOS 10.12 / Xcode 8 actively prohibit the syscall(2) usage. Change-Id: I91ff16600a76e97d0b9b5db7e8905b969fb3482f --- base/logging.cpp | 4 +++- libcutils/threads.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/base/logging.cpp b/base/logging.cpp index 6357b4ba7..75078e50e 100644 --- a/base/logging.cpp +++ b/base/logging.cpp @@ -80,7 +80,9 @@ static thread_id GetThreadId() { #if defined(__BIONIC__) return gettid(); #elif defined(__APPLE__) - return syscall(SYS_thread_selfid); + uint64_t tid; + pthread_threadid_np(NULL, &tid); + return tid; #elif defined(__linux__) return syscall(__NR_gettid); #elif defined(_WIN32) diff --git a/libcutils/threads.c b/libcutils/threads.c index 036f8c5b7..4bae39e0f 100644 --- a/libcutils/threads.c +++ b/libcutils/threads.c @@ -35,7 +35,9 @@ #ifndef __ANDROID__ pid_t gettid() { #if defined(__APPLE__) - return syscall(SYS_thread_selfid); + uint64_t tid; + pthread_threadid_np(NULL, &tid); + return tid; #elif defined(__linux__) return syscall(__NR_gettid); #elif defined(_WIN32)