| 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/time/time.h" | 5 #include "base/time/time.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <sys/time.h> | 8 #include <sys/time.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 #if defined(OS_ANDROID) && !defined(__LP64__) | 10 #if defined(OS_ANDROID) && !defined(__LP64__) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #if !defined(OS_MACOSX) | 28 #if !defined(OS_MACOSX) |
| 29 #include "base/synchronization/lock.h" | 29 #include "base/synchronization/lock.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 #if !defined(OS_MACOSX) | 34 #if !defined(OS_MACOSX) |
| 35 // This prevents a crash on traversing the environment global and looking up | 35 // This prevents a crash on traversing the environment global and looking up |
| 36 // the 'TZ' variable in libc. See: crbug.com/390567. | 36 // the 'TZ' variable in libc. See: crbug.com/390567. |
| 37 base::Lock* GetSysTimeToTimeStructLock() { | 37 base::Lock* GetSysTimeToTimeStructLock() { |
| 38 static auto lock = new base::Lock(); | 38 static auto* lock = new base::Lock(); |
| 39 return lock; | 39 return lock; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Define a system-specific SysTime that wraps either to a time_t or | 42 // Define a system-specific SysTime that wraps either to a time_t or |
| 43 // a time64_t depending on the host system, and associated convertion. | 43 // a time64_t depending on the host system, and associated convertion. |
| 44 // See crbug.com/162007 | 44 // See crbug.com/162007 |
| 45 #if defined(OS_ANDROID) && !defined(__LP64__) | 45 #if defined(OS_ANDROID) && !defined(__LP64__) |
| 46 typedef time64_t SysTime; | 46 typedef time64_t SysTime; |
| 47 | 47 |
| 48 SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) { | 48 SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) { |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; | 420 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; |
| 421 return result; | 421 return result; |
| 422 } | 422 } |
| 423 int64_t us = us_ - kTimeTToMicrosecondsOffset; | 423 int64_t us = us_ - kTimeTToMicrosecondsOffset; |
| 424 result.tv_sec = us / Time::kMicrosecondsPerSecond; | 424 result.tv_sec = us / Time::kMicrosecondsPerSecond; |
| 425 result.tv_usec = us % Time::kMicrosecondsPerSecond; | 425 result.tv_usec = us % Time::kMicrosecondsPerSecond; |
| 426 return result; | 426 return result; |
| 427 } | 427 } |
| 428 | 428 |
| 429 } // namespace base | 429 } // namespace base |
| OLD | NEW |