Chromium Code Reviews| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 } // namespace | 153 } // namespace |
| 154 | 154 |
| 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_NACL) || defined(OS_SOLARIS) | 163 #elif defined(OS_SOLARIS) |
| 164 return pthread_self(); | 164 return pthread_self(); |
| 165 #elif defined(OS_NACL) | |
| 166 // Pointers are 32-bits in NaCl. | |
|
Mark Seaborn
2012/05/22 16:39:39
You might also comment that we're assuming nacl-ne
| |
| 167 return reinterpret_cast<int32>(pthread_self()); | |
|
Mark Seaborn
2012/05/22 16:39:39
FYI, this would break again if nacl-newlib's libpt
| |
| 165 #elif defined(OS_POSIX) | 168 #elif defined(OS_POSIX) |
| 166 return reinterpret_cast<int64>(pthread_self()); | 169 return reinterpret_cast<int64>(pthread_self()); |
| 167 #endif | 170 #endif |
| 168 } | 171 } |
| 169 | 172 |
| 170 // static | 173 // static |
| 171 void PlatformThread::YieldCurrentThread() { | 174 void PlatformThread::YieldCurrentThread() { |
| 172 sched_yield(); | 175 sched_yield(); |
| 173 } | 176 } |
| 174 | 177 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 #if !defined(OS_MACOSX) | 282 #if !defined(OS_MACOSX) |
| 280 // Mac OS X uses lower-level mach APIs. | 283 // Mac OS X uses lower-level mach APIs. |
| 281 | 284 |
| 282 // static | 285 // static |
| 283 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 286 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
| 284 // TODO(crogers): Implement, see http://crbug.com/116172 | 287 // TODO(crogers): Implement, see http://crbug.com/116172 |
| 285 } | 288 } |
| 286 #endif | 289 #endif |
| 287 | 290 |
| 288 } // namespace base | 291 } // namespace base |
| OLD | NEW |