| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 5 #include "base/logging.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 typedef HANDLE FileHandle; | 10 typedef HANDLE FileHandle; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 int32 CurrentThreadId() { | 128 int32 CurrentThreadId() { |
| 129 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
| 130 return GetCurrentThreadId(); | 130 return GetCurrentThreadId(); |
| 131 #elif defined(OS_MACOSX) | 131 #elif defined(OS_MACOSX) |
| 132 return mach_thread_self(); | 132 return mach_thread_self(); |
| 133 #elif defined(OS_LINUX) | 133 #elif defined(OS_LINUX) |
| 134 return syscall(__NR_gettid); | 134 return syscall(__NR_gettid); |
| 135 #elif defined(OS_ANDROID) | 135 #elif defined(OS_ANDROID) |
| 136 return gettid(); | 136 return gettid(); |
| 137 #elif defined(OS_FREEBSD) | |
| 138 // TODO(BSD): find a better thread ID | |
| 139 return reinterpret_cast<int64>(pthread_self()); | |
| 140 #elif defined(OS_NACL) | 137 #elif defined(OS_NACL) |
| 141 return pthread_self(); | 138 return pthread_self(); |
| 139 #elif defined(OS_POSIX) |
| 140 return reinterpret_cast<int64>(pthread_self()); |
| 142 #endif | 141 #endif |
| 143 } | 142 } |
| 144 | 143 |
| 145 uint64 TickCount() { | 144 uint64 TickCount() { |
| 146 #if defined(OS_WIN) | 145 #if defined(OS_WIN) |
| 147 return GetTickCount(); | 146 return GetTickCount(); |
| 148 #elif defined(OS_MACOSX) | 147 #elif defined(OS_MACOSX) |
| 149 return mach_absolute_time(); | 148 return mach_absolute_time(); |
| 150 #elif defined(OS_NACL) | 149 #elif defined(OS_NACL) |
| 151 // NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h | 150 // NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 | 845 |
| 847 // This was defined at the beginnig of this file. | 846 // This was defined at the beginnig of this file. |
| 848 #undef write | 847 #undef write |
| 849 | 848 |
| 850 std::ostream& operator<<(std::ostream& o, const StringPiece& piece) { | 849 std::ostream& operator<<(std::ostream& o, const StringPiece& piece) { |
| 851 o.write(piece.data(), static_cast<std::streamsize>(piece.size())); | 850 o.write(piece.data(), static_cast<std::streamsize>(piece.size())); |
| 852 return o; | 851 return o; |
| 853 } | 852 } |
| 854 | 853 |
| 855 } // namespace base | 854 } // namespace base |
| OLD | NEW |