OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 return success; | 127 return success; |
128 } | 128 } |
129 | 129 |
130 } // namespace | 130 } // namespace |
131 | 131 |
132 // static | 132 // static |
133 PlatformThreadId PlatformThread::CurrentId() { | 133 PlatformThreadId PlatformThread::CurrentId() { |
134 // Pthreads doesn't have the concept of a thread ID, so we have to reach down | 134 // Pthreads doesn't have the concept of a thread ID, so we have to reach down |
135 // into the kernel. | 135 // into the kernel. |
136 #if defined(OS_MACOSX) | 136 #if defined(OS_MACOSX) |
137 return mach_thread_self(); | 137 mach_port_t port = mach_thread_self(); |
| 138 mach_port_deallocate(mach_task_self(), port); |
| 139 return port; |
138 #elif defined(OS_LINUX) | 140 #elif defined(OS_LINUX) |
139 return syscall(__NR_gettid); | 141 return syscall(__NR_gettid); |
140 #elif defined(OS_ANDROID) | 142 #elif defined(OS_ANDROID) |
141 return gettid(); | 143 return gettid(); |
142 #elif defined(OS_NACL) || defined(OS_SOLARIS) | 144 #elif defined(OS_NACL) || defined(OS_SOLARIS) |
143 return pthread_self(); | 145 return pthread_self(); |
144 #elif defined(OS_POSIX) | 146 #elif defined(OS_POSIX) |
145 return reinterpret_cast<int64>(pthread_self()); | 147 return reinterpret_cast<int64>(pthread_self()); |
146 #endif | 148 #endif |
147 } | 149 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // Mac OS X uses lower-level mach APIs | 259 // Mac OS X uses lower-level mach APIs |
258 | 260 |
259 // static | 261 // static |
260 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 262 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
261 // TODO(crogers): implement | 263 // TODO(crogers): implement |
262 NOTIMPLEMENTED(); | 264 NOTIMPLEMENTED(); |
263 } | 265 } |
264 #endif | 266 #endif |
265 | 267 |
266 } // namespace base | 268 } // namespace base |
OLD | NEW |