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.h" | 5 #include "base/time.h" |
6 | 6 |
7 #include <sys/time.h> | 7 #include <sys/time.h> |
8 #include <time.h> | 8 #include <time.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 | 27 |
28 struct timespec TimeDelta::ToTimeSpec() const { | 28 struct timespec TimeDelta::ToTimeSpec() const { |
29 int64 microseconds = InMicroseconds(); | 29 int64 microseconds = InMicroseconds(); |
30 time_t seconds = 0; | 30 time_t seconds = 0; |
31 if (microseconds >= Time::kMicrosecondsPerSecond) { | 31 if (microseconds >= Time::kMicrosecondsPerSecond) { |
32 seconds = InSeconds(); | 32 seconds = InSeconds(); |
33 microseconds -= seconds * Time::kMicrosecondsPerSecond; | 33 microseconds -= seconds * Time::kMicrosecondsPerSecond; |
34 } | 34 } |
35 struct timespec result = | 35 struct timespec result = |
36 {seconds, | 36 {seconds, |
37 microseconds * Time::kNanosecondsPerMicrosecond}; | 37 static_cast<long int>(microseconds * Time::kNanosecondsPerMicrosecond)}; |
brettw
2012/05/29 19:30:46
Can you just do "long" here (it's the same, right?
Han
2012/05/29 20:57:04
Yes, 'long' is just an alias for 'long int'.
| |
38 return result; | 38 return result; |
39 } | 39 } |
40 | 40 |
41 #if !defined(OS_MACOSX) | 41 #if !defined(OS_MACOSX) |
42 // The Time routines in this file use standard POSIX routines, or almost- | 42 // The Time routines in this file use standard POSIX routines, or almost- |
43 // standard routines in the case of timegm. We need to use a Mach-specific | 43 // standard routines in the case of timegm. We need to use a Mach-specific |
44 // function for TimeTicks::Now() on Mac OS X. | 44 // function for TimeTicks::Now() on Mac OS X. |
45 | 45 |
46 // Time ----------------------------------------------------------------------- | 46 // Time ----------------------------------------------------------------------- |
47 | 47 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 | 264 |
265 struct timeval Time::ToTimeVal() const { | 265 struct timeval Time::ToTimeVal() const { |
266 struct timeval result; | 266 struct timeval result; |
267 int64 us = us_ - kTimeTToMicrosecondsOffset; | 267 int64 us = us_ - kTimeTToMicrosecondsOffset; |
268 result.tv_sec = us / Time::kMicrosecondsPerSecond; | 268 result.tv_sec = us / Time::kMicrosecondsPerSecond; |
269 result.tv_usec = us % Time::kMicrosecondsPerSecond; | 269 result.tv_usec = us % Time::kMicrosecondsPerSecond; |
270 return result; | 270 return result; |
271 } | 271 } |
272 | 272 |
273 } // namespace base | 273 } // namespace base |
OLD | NEW |