| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/safe_strerror_posix.h" | 13 #include "base/safe_strerror_posix.h" |
| 14 #include "base/threading/thread_local.h" | 14 #include "base/threading/thread_local.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/tracked_objects.h" | 16 #include "base/tracked_objects.h" |
| 17 | 17 |
| 18 #if defined(OS_MACOSX) | 18 #if defined(OS_MACOSX) |
| 19 #include <mach/mach.h> | |
| 20 #include <sys/resource.h> | 19 #include <sys/resource.h> |
| 21 #include <algorithm> | 20 #include <algorithm> |
| 22 #endif | 21 #endif |
| 23 | 22 |
| 24 #if defined(OS_LINUX) | 23 #if defined(OS_LINUX) |
| 25 #include <sys/prctl.h> | 24 #include <sys/prctl.h> |
| 26 #include <sys/syscall.h> | 25 #include <sys/syscall.h> |
| 27 #include <unistd.h> | 26 #include <unistd.h> |
| 28 #endif | 27 #endif |
| 29 | 28 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 delete params; | 124 delete params; |
| 126 return success; | 125 return success; |
| 127 } | 126 } |
| 128 | 127 |
| 129 } // namespace | 128 } // namespace |
| 130 | 129 |
| 131 // static | 130 // static |
| 132 PlatformThreadId PlatformThread::CurrentId() { | 131 PlatformThreadId PlatformThread::CurrentId() { |
| 133 // Pthreads doesn't have the concept of a thread ID, so we have to reach down | 132 // Pthreads doesn't have the concept of a thread ID, so we have to reach down |
| 134 // into the kernel. | 133 // into the kernel. |
| 135 #if defined(OS_MACOSX) | 134 #if defined(OS_LINUX) |
| 136 mach_port_t port = mach_thread_self(); | |
| 137 mach_port_deallocate(mach_task_self(), port); | |
| 138 return port; | |
| 139 #elif defined(OS_LINUX) | |
| 140 return syscall(__NR_gettid); | 135 return syscall(__NR_gettid); |
| 141 #elif defined(OS_ANDROID) | 136 #elif defined(OS_ANDROID) |
| 142 return gettid(); | 137 return gettid(); |
| 143 #elif defined(OS_NACL) || defined(OS_SOLARIS) | 138 #elif defined(OS_NACL) || defined(OS_SOLARIS) |
| 144 return pthread_self(); | 139 return pthread_self(); |
| 145 #elif defined(OS_POSIX) | 140 #elif defined(OS_POSIX) |
| 146 return reinterpret_cast<int64>(pthread_self()); | 141 return reinterpret_cast<int64>(pthread_self()); |
| 147 #endif | 142 #endif |
| 148 } | 143 } |
| 149 | 144 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // Mac OS X uses lower-level mach APIs | 247 // Mac OS X uses lower-level mach APIs |
| 253 | 248 |
| 254 // static | 249 // static |
| 255 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 250 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
| 256 // TODO(crogers): implement | 251 // TODO(crogers): implement |
| 257 NOTIMPLEMENTED(); | 252 NOTIMPLEMENTED(); |
| 258 } | 253 } |
| 259 #endif | 254 #endif |
| 260 | 255 |
| 261 } // namespace base | 256 } // namespace base |
| OLD | NEW |