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

Side by Side Diff: src/platform-posix.cc

Issue 23490015: Reland^2 "Add Chromium-style TimeDelta, Time and TimeTicks classes, and a new ElapsedTimer class." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some windows cleanup Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/platform-openbsd.cc ('k') | src/platform-win32.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 struct rusage usage; 306 struct rusage usage;
307 307
308 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1; 308 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1;
309 *secs = usage.ru_utime.tv_sec; 309 *secs = usage.ru_utime.tv_sec;
310 *usecs = usage.ru_utime.tv_usec; 310 *usecs = usage.ru_utime.tv_usec;
311 return 0; 311 return 0;
312 } 312 }
313 313
314 314
315 double OS::TimeCurrentMillis() { 315 double OS::TimeCurrentMillis() {
316 struct timeval tv; 316 return Time::Now().ToJsTime();
317 if (gettimeofday(&tv, NULL) < 0) return 0.0;
318 return (static_cast<double>(tv.tv_sec) * 1000) +
319 (static_cast<double>(tv.tv_usec) / 1000);
320 } 317 }
321 318
322 319
323 int64_t OS::Ticks() {
324 // gettimeofday has microsecond resolution.
325 struct timeval tv;
326 if (gettimeofday(&tv, NULL) < 0)
327 return 0;
328 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
329 }
330
331
332 double OS::DaylightSavingsOffset(double time) { 320 double OS::DaylightSavingsOffset(double time) {
333 if (std::isnan(time)) return nan_value(); 321 if (std::isnan(time)) return nan_value();
334 time_t tv = static_cast<time_t>(floor(time/msPerSecond)); 322 time_t tv = static_cast<time_t>(floor(time/msPerSecond));
335 struct tm* t = localtime(&tv); 323 struct tm* t = localtime(&tv);
336 if (NULL == t) return nan_value(); 324 if (NULL == t) return nan_value();
337 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; 325 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0;
338 } 326 }
339 327
340 328
341 int OS::GetLastError() { 329 int OS::GetLastError() {
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 return ntohl(value); 973 return ntohl(value);
986 } 974 }
987 975
988 976
989 Socket* OS::CreateSocket() { 977 Socket* OS::CreateSocket() {
990 return new POSIXSocket(); 978 return new POSIXSocket();
991 } 979 }
992 980
993 981
994 } } // namespace v8::internal 982 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-openbsd.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698