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 mach_port_t port = mach_thread_self(); | 136 return mach_thread_self(); |
137 mach_port_deallocate(mach_task_self(), port); | |
138 return port; | |
139 #elif defined(OS_LINUX) | 137 #elif defined(OS_LINUX) |
140 return syscall(__NR_gettid); | 138 return syscall(__NR_gettid); |
141 #elif defined(OS_ANDROID) | 139 #elif defined(OS_ANDROID) |
142 return gettid(); | 140 return gettid(); |
143 #elif defined(OS_NACL) || defined(OS_SOLARIS) | 141 #elif defined(OS_NACL) || defined(OS_SOLARIS) |
144 return pthread_self(); | 142 return pthread_self(); |
145 #elif defined(OS_POSIX) | 143 #elif defined(OS_POSIX) |
146 return reinterpret_cast<int64>(pthread_self()); | 144 return reinterpret_cast<int64>(pthread_self()); |
147 #endif | 145 #endif |
148 } | 146 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 // Mac OS X uses lower-level mach APIs | 250 // Mac OS X uses lower-level mach APIs |
253 | 251 |
254 // static | 252 // static |
255 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 253 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
256 // TODO(crogers): implement | 254 // TODO(crogers): implement |
257 NOTIMPLEMENTED(); | 255 NOTIMPLEMENTED(); |
258 } | 256 } |
259 #endif | 257 #endif |
260 | 258 |
261 } // namespace base | 259 } // namespace base |
OLD | NEW |