OLD | NEW |
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 struct rusage usage; | 311 struct rusage usage; |
312 | 312 |
313 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1; | 313 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1; |
314 *secs = usage.ru_utime.tv_sec; | 314 *secs = usage.ru_utime.tv_sec; |
315 *usecs = usage.ru_utime.tv_usec; | 315 *usecs = usage.ru_utime.tv_usec; |
316 return 0; | 316 return 0; |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 double OS::TimeCurrentMillis() { | 320 double OS::TimeCurrentMillis() { |
321 struct timeval tv; | 321 return Time::Now().ToJsTime(); |
322 if (gettimeofday(&tv, NULL) < 0) return 0.0; | |
323 return (static_cast<double>(tv.tv_sec) * 1000) + | |
324 (static_cast<double>(tv.tv_usec) / 1000); | |
325 } | 322 } |
326 | 323 |
327 | 324 |
328 int64_t OS::Ticks() { | |
329 // gettimeofday has microsecond resolution. | |
330 struct timeval tv; | |
331 if (gettimeofday(&tv, NULL) < 0) | |
332 return 0; | |
333 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; | |
334 } | |
335 | |
336 | |
337 double OS::DaylightSavingsOffset(double time) { | 325 double OS::DaylightSavingsOffset(double time) { |
338 if (std::isnan(time)) return nan_value(); | 326 if (std::isnan(time)) return nan_value(); |
339 time_t tv = static_cast<time_t>(floor(time/msPerSecond)); | 327 time_t tv = static_cast<time_t>(floor(time/msPerSecond)); |
340 struct tm* t = localtime(&tv); | 328 struct tm* t = localtime(&tv); |
341 if (NULL == t) return nan_value(); | 329 if (NULL == t) return nan_value(); |
342 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; | 330 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; |
343 } | 331 } |
344 | 332 |
345 | 333 |
346 int OS::GetLastError() { | 334 int OS::GetLastError() { |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 return ntohl(value); | 978 return ntohl(value); |
991 } | 979 } |
992 | 980 |
993 | 981 |
994 Socket* OS::CreateSocket() { | 982 Socket* OS::CreateSocket() { |
995 return new POSIXSocket(); | 983 return new POSIXSocket(); |
996 } | 984 } |
997 | 985 |
998 | 986 |
999 } } // namespace v8::internal | 987 } } // namespace v8::internal |
OLD | NEW |