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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // static | 155 // static |
156 PlatformThreadId PlatformThread::CurrentId() { | 156 PlatformThreadId PlatformThread::CurrentId() { |
157 // Pthreads doesn't have the concept of a thread ID, so we have to reach down | 157 // Pthreads doesn't have the concept of a thread ID, so we have to reach down |
158 // into the kernel. | 158 // into the kernel. |
159 #if defined(OS_LINUX) | 159 #if defined(OS_LINUX) |
160 return syscall(__NR_gettid); | 160 return syscall(__NR_gettid); |
161 #elif defined(OS_ANDROID) | 161 #elif defined(OS_ANDROID) |
162 return gettid(); | 162 return gettid(); |
163 #elif defined(OS_SOLARIS) | 163 #elif defined(OS_SOLARIS) |
164 return pthread_self(); | 164 return pthread_self(); |
165 #elif defined(OS_NACL) | 165 #elif defined(OS_NACL) && defined(__GLIBC__) |
| 166 return pthread_self(); |
| 167 #elif defined(OS_NACL) && !defined(__GLIBC__) |
166 // Pointers are 32-bits in NaCl. | 168 // Pointers are 32-bits in NaCl. |
167 return reinterpret_cast<int32>(pthread_self()); | 169 return reinterpret_cast<int32>(pthread_self()); |
168 #elif defined(OS_POSIX) | 170 #elif defined(OS_POSIX) |
169 return reinterpret_cast<int64>(pthread_self()); | 171 return reinterpret_cast<int64>(pthread_self()); |
170 #endif | 172 #endif |
171 } | 173 } |
172 | 174 |
173 // static | 175 // static |
174 void PlatformThread::YieldCurrentThread() { | 176 void PlatformThread::YieldCurrentThread() { |
175 sched_yield(); | 177 sched_yield(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 #if !defined(OS_MACOSX) | 277 #if !defined(OS_MACOSX) |
276 // Mac OS X uses lower-level mach APIs. | 278 // Mac OS X uses lower-level mach APIs. |
277 | 279 |
278 // static | 280 // static |
279 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 281 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
280 // TODO(crogers): Implement, see http://crbug.com/116172 | 282 // TODO(crogers): Implement, see http://crbug.com/116172 |
281 } | 283 } |
282 #endif | 284 #endif |
283 | 285 |
284 } // namespace base | 286 } // namespace base |
OLD | NEW |