| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 <windows.h> | 8 #include <windows.h> |
| 9 typedef HANDLE FileHandle; | 9 typedef HANDLE FileHandle; |
| 10 typedef HANDLE MutexHandle; | 10 typedef HANDLE MutexHandle; |
| 11 #elif defined(OS_MACOSX) | 11 #elif defined(OS_MACOSX) |
| 12 #include <CoreFoundation/CoreFoundation.h> | 12 #include <CoreFoundation/CoreFoundation.h> |
| 13 #include <mach/mach.h> | 13 #include <mach/mach.h> |
| 14 #include <mach/mach_time.h> | 14 #include <mach/mach_time.h> |
| 15 #include <mach-o/dyld.h> | 15 #include <mach-o/dyld.h> |
| 16 #elif defined(OS_LINUX) | 16 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
| 17 #include <sys/syscall.h> | 17 #include <sys/syscall.h> |
| 18 #include <time.h> | 18 #include <time.h> |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 #if defined(OS_POSIX) | 21 #if defined(OS_POSIX) |
| 22 #include <fcntl.h> | 22 #include <fcntl.h> |
| 23 #include <stdlib.h> | 23 #include <stdlib.h> |
| 24 #include <stdio.h> | 24 #include <stdio.h> |
| 25 #include <string.h> | 25 #include <string.h> |
| 26 #include <sys/types.h> | 26 #include <sys/types.h> |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 #endif | 122 #endif |
| 123 } | 123 } |
| 124 | 124 |
| 125 int32 CurrentThreadId() { | 125 int32 CurrentThreadId() { |
| 126 #if defined(OS_WIN) | 126 #if defined(OS_WIN) |
| 127 return GetCurrentThreadId(); | 127 return GetCurrentThreadId(); |
| 128 #elif defined(OS_MACOSX) | 128 #elif defined(OS_MACOSX) |
| 129 return mach_thread_self(); | 129 return mach_thread_self(); |
| 130 #elif defined(OS_LINUX) | 130 #elif defined(OS_LINUX) |
| 131 return syscall(__NR_gettid); | 131 return syscall(__NR_gettid); |
| 132 #elif defined(OS_OPENBSD) |
| 133 return (int32)pthread_self(); |
| 132 #endif | 134 #endif |
| 133 } | 135 } |
| 134 | 136 |
| 135 uint64 TickCount() { | 137 uint64 TickCount() { |
| 136 #if defined(OS_WIN) | 138 #if defined(OS_WIN) |
| 137 return GetTickCount(); | 139 return GetTickCount(); |
| 138 #elif defined(OS_MACOSX) | 140 #elif defined(OS_MACOSX) |
| 139 return mach_absolute_time(); | 141 return mach_absolute_time(); |
| 140 #elif defined(OS_LINUX) | 142 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
| 141 struct timespec ts; | 143 struct timespec ts; |
| 142 clock_gettime(CLOCK_MONOTONIC, &ts); | 144 clock_gettime(CLOCK_MONOTONIC, &ts); |
| 143 | 145 |
| 144 uint64 absolute_micro = | 146 uint64 absolute_micro = |
| 145 static_cast<int64>(ts.tv_sec) * 1000000 + | 147 static_cast<int64>(ts.tv_sec) * 1000000 + |
| 146 static_cast<int64>(ts.tv_nsec) / 1000; | 148 static_cast<int64>(ts.tv_nsec) / 1000; |
| 147 | 149 |
| 148 return absolute_micro; | 150 return absolute_micro; |
| 149 #endif | 151 #endif |
| 150 } | 152 } |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 589 |
| 588 CloseFile(log_file); | 590 CloseFile(log_file); |
| 589 log_file = NULL; | 591 log_file = NULL; |
| 590 } | 592 } |
| 591 | 593 |
| 592 } // namespace logging | 594 } // namespace logging |
| 593 | 595 |
| 594 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { | 596 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { |
| 595 return out << base::SysWideToUTF8(std::wstring(wstr)); | 597 return out << base::SysWideToUTF8(std::wstring(wstr)); |
| 596 } | 598 } |
| OLD | NEW |