Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: base/time_posix.cc

Issue 10451068: Fixing gcc 4.7 building problems. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Modified per Adam's comments Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698