OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/threading/platform_thread.h" | 5 #include "base/threading/platform_thread.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sched.h> | 8 #include <sched.h> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return success; | 126 return success; |
127 } | 127 } |
128 | 128 |
129 } // namespace | 129 } // namespace |
130 | 130 |
131 // static | 131 // static |
132 PlatformThreadId PlatformThread::CurrentId() { | 132 PlatformThreadId PlatformThread::CurrentId() { |
133 // Pthreads doesn't have the concept of a thread ID, so we have to reach down | 133 // Pthreads doesn't have the concept of a thread ID, so we have to reach down |
134 // into the kernel. | 134 // into the kernel. |
135 #if defined(OS_MACOSX) | 135 #if defined(OS_MACOSX) |
136 return mach_thread_self(); | 136 mach_port_t port = mach_thread_self(); |
| 137 mach_port_deallocate(mach_task_self(), port); |
| 138 return port; |
137 #elif defined(OS_LINUX) | 139 #elif defined(OS_LINUX) |
138 return syscall(__NR_gettid); | 140 return syscall(__NR_gettid); |
139 #elif defined(OS_ANDROID) | 141 #elif defined(OS_ANDROID) |
140 return gettid(); | 142 return gettid(); |
141 #elif defined(OS_NACL) || defined(OS_SOLARIS) | 143 #elif defined(OS_NACL) || defined(OS_SOLARIS) |
142 return pthread_self(); | 144 return pthread_self(); |
143 #elif defined(OS_POSIX) | 145 #elif defined(OS_POSIX) |
144 return reinterpret_cast<int64>(pthread_self()); | 146 return reinterpret_cast<int64>(pthread_self()); |
145 #endif | 147 #endif |
146 } | 148 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // Mac OS X uses lower-level mach APIs | 252 // Mac OS X uses lower-level mach APIs |
251 | 253 |
252 // static | 254 // static |
253 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 255 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
254 // TODO(crogers): implement | 256 // TODO(crogers): implement |
255 NOTIMPLEMENTED(); | 257 NOTIMPLEMENTED(); |
256 } | 258 } |
257 #endif | 259 #endif |
258 | 260 |
259 } // namespace base | 261 } // namespace base |
OLD | NEW |