| 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 <pthread.h> | 8 #include <pthread.h> |
| 9 #include <sched.h> | 9 #include <sched.h> |
| 10 #include <stddef.h> |
| 11 #include <stdint.h> |
| 10 #include <sys/resource.h> | 12 #include <sys/resource.h> |
| 11 #include <sys/time.h> | 13 #include <sys/time.h> |
| 12 | 14 |
| 13 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 14 #include "base/logging.h" | 16 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/threading/platform_thread_internal_posix.h" | 18 #include "base/threading/platform_thread_internal_posix.h" |
| 17 #include "base/threading/thread_id_name_manager.h" | 19 #include "base/threading/thread_id_name_manager.h" |
| 18 #include "base/threading/thread_restrictions.h" | 20 #include "base/threading/thread_restrictions.h" |
| 21 #include "build/build_config.h" |
| 19 | 22 |
| 20 #if defined(OS_LINUX) | 23 #if defined(OS_LINUX) |
| 21 #include <sys/syscall.h> | 24 #include <sys/syscall.h> |
| 22 #elif defined(OS_ANDROID) | 25 #elif defined(OS_ANDROID) |
| 23 #include <sys/types.h> | 26 #include <sys/types.h> |
| 24 #endif | 27 #endif |
| 25 | 28 |
| 26 namespace base { | 29 namespace base { |
| 27 | 30 |
| 28 void InitThreading(); | 31 void InitThreading(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 #elif defined(OS_LINUX) | 132 #elif defined(OS_LINUX) |
| 130 return syscall(__NR_gettid); | 133 return syscall(__NR_gettid); |
| 131 #elif defined(OS_ANDROID) | 134 #elif defined(OS_ANDROID) |
| 132 return gettid(); | 135 return gettid(); |
| 133 #elif defined(OS_SOLARIS) || defined(OS_QNX) | 136 #elif defined(OS_SOLARIS) || defined(OS_QNX) |
| 134 return pthread_self(); | 137 return pthread_self(); |
| 135 #elif defined(OS_NACL) && defined(__GLIBC__) | 138 #elif defined(OS_NACL) && defined(__GLIBC__) |
| 136 return pthread_self(); | 139 return pthread_self(); |
| 137 #elif defined(OS_NACL) && !defined(__GLIBC__) | 140 #elif defined(OS_NACL) && !defined(__GLIBC__) |
| 138 // Pointers are 32-bits in NaCl. | 141 // Pointers are 32-bits in NaCl. |
| 139 return reinterpret_cast<int32>(pthread_self()); | 142 return reinterpret_cast<int32_t>(pthread_self()); |
| 140 #elif defined(OS_POSIX) | 143 #elif defined(OS_POSIX) |
| 141 return reinterpret_cast<int64>(pthread_self()); | 144 return reinterpret_cast<int64_t>(pthread_self()); |
| 142 #endif | 145 #endif |
| 143 } | 146 } |
| 144 | 147 |
| 145 // static | 148 // static |
| 146 PlatformThreadRef PlatformThread::CurrentRef() { | 149 PlatformThreadRef PlatformThread::CurrentRef() { |
| 147 return PlatformThreadRef(pthread_self()); | 150 return PlatformThreadRef(pthread_self()); |
| 148 } | 151 } |
| 149 | 152 |
| 150 // static | 153 // static |
| 151 PlatformThreadHandle PlatformThread::CurrentHandle() { | 154 PlatformThreadHandle PlatformThread::CurrentHandle() { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 return ThreadPriority::NORMAL; | 254 return ThreadPriority::NORMAL; |
| 252 } | 255 } |
| 253 | 256 |
| 254 return internal::NiceValueToThreadPriority(nice_value); | 257 return internal::NiceValueToThreadPriority(nice_value); |
| 255 #endif // !defined(OS_NACL) | 258 #endif // !defined(OS_NACL) |
| 256 } | 259 } |
| 257 | 260 |
| 258 #endif // !defined(OS_MACOSX) | 261 #endif // !defined(OS_MACOSX) |
| 259 | 262 |
| 260 } // namespace base | 263 } // namespace base |
| OLD | NEW |