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

Side by Side Diff: base/time_posix.cc

Issue 8564020: define OS_BSD on *BSD and replace the ifdefs to use that (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « base/platform_file_posix.cc ('k') | build/build_config.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 // Adjust from Unix (1970) to Windows (1601) epoch. 165 // Adjust from Unix (1970) to Windows (1601) epoch.
166 return Time((milliseconds * kMicrosecondsPerMillisecond) + 166 return Time((milliseconds * kMicrosecondsPerMillisecond) +
167 kWindowsEpochDeltaMicroseconds); 167 kWindowsEpochDeltaMicroseconds);
168 } 168 }
169 169
170 // TimeTicks ------------------------------------------------------------------ 170 // TimeTicks ------------------------------------------------------------------
171 // FreeBSD 6 has CLOCK_MONOLITHIC but defines _POSIX_MONOTONIC_CLOCK to -1. 171 // FreeBSD 6 has CLOCK_MONOLITHIC but defines _POSIX_MONOTONIC_CLOCK to -1.
172 #if (defined(OS_POSIX) && \ 172 #if (defined(OS_POSIX) && \
173 defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0) || \ 173 defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0) || \
174 defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_ANDROID) 174 defined(OS_BSD) || defined(OS_ANDROID)
175 175
176 // static 176 // static
177 TimeTicks TimeTicks::Now() { 177 TimeTicks TimeTicks::Now() {
178 uint64_t absolute_micro; 178 uint64_t absolute_micro;
179 179
180 struct timespec ts; 180 struct timespec ts;
181 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { 181 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
182 NOTREACHED() << "clock_gettime(CLOCK_MONOTONIC) failed."; 182 NOTREACHED() << "clock_gettime(CLOCK_MONOTONIC) failed.";
183 return TimeTicks(); 183 return TimeTicks();
184 } 184 }
(...skipping 27 matching lines...) Expand all
212 212
213 struct timeval Time::ToTimeVal() const { 213 struct timeval Time::ToTimeVal() const {
214 struct timeval result; 214 struct timeval result;
215 int64 us = us_ - kTimeTToMicrosecondsOffset; 215 int64 us = us_ - kTimeTToMicrosecondsOffset;
216 result.tv_sec = us / Time::kMicrosecondsPerSecond; 216 result.tv_sec = us / Time::kMicrosecondsPerSecond;
217 result.tv_usec = us % Time::kMicrosecondsPerSecond; 217 result.tv_usec = us % Time::kMicrosecondsPerSecond;
218 return result; 218 return result;
219 } 219 }
220 220
221 } // namespace base 221 } // namespace base
OLDNEW
« no previous file with comments | « base/platform_file_posix.cc ('k') | build/build_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698