diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-25 19:16:13 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-25 19:16:13 +0000 |
commit | 226122f1fbd6b7ab87aa38649da70c049d6627b3 (patch) | |
tree | f9f43105b022eda61d692373275088e46e53f9eb /base/threading | |
parent | 7c5465cd9e7706d3bee863e82d1edf0c0b22a92e (diff) | |
download | chromium_src-226122f1fbd6b7ab87aa38649da70c049d6627b3.zip chromium_src-226122f1fbd6b7ab87aa38649da70c049d6627b3.tar.gz chromium_src-226122f1fbd6b7ab87aa38649da70c049d6627b3.tar.bz2 |
Go back to using mach_thread_self for Mac thread IDs, sort of.
r118780 (https://codereview.chromium.org/9281011) switched
base::PlatformThread::CurrentId() from using mach_port_t (from
mach_thread_self) to using pthread_t directly. Using pthread_t isn't great for
64-bit Chrome, because it's a 64-bit type (a pointer, actually) and
PlatformThreadId is a 32-bit type (pid_t, actually). There's some quiet
truncation happening, and there shouldn't be.
This switches back to mach_thread_self, but instead of the problems associated
with calling mach_thread_self, it uses the Mach port cached by the pthread
layer, by calling pthread_mach_thread_np. This doesn't do anything with the
reference count of the port itself, so there's no concern about leaking (as
when not calling mach_port_deallocate) or returning a potentially stale value
(as when calling mach_port_deallocate before returning a port).
Review URL: https://codereview.chromium.org/12039073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/threading')
-rw-r--r-- | base/threading/platform_thread_posix.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc index b17c34d..0a6741c 100644 --- a/base/threading/platform_thread_posix.cc +++ b/base/threading/platform_thread_posix.cc @@ -164,7 +164,9 @@ bool CreateThread(size_t stack_size, bool joinable, PlatformThreadId PlatformThread::CurrentId() { // Pthreads doesn't have the concept of a thread ID, so we have to reach down // into the kernel. -#if defined(OS_LINUX) +#if defined(OS_MACOSX) + return pthread_mach_thread_np(pthread_self()); +#elif defined(OS_LINUX) return syscall(__NR_gettid); #elif defined(OS_ANDROID) return gettid(); |