OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project 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 // Platform-specific code for POSIX goes here. This is not a platform on its | 5 // Platform-specific code for POSIX goes here. This is not a platform on its |
6 // own, but contains the parts which are the same across the POSIX platforms | 6 // own, but contains the parts which are the same across the POSIX platforms |
7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. | 7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. |
8 | 8 |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 *secs = static_cast<uint32_t>(usage.ru_utime.tv_sec); | 375 *secs = static_cast<uint32_t>(usage.ru_utime.tv_sec); |
376 *usecs = static_cast<uint32_t>(usage.ru_utime.tv_usec); | 376 *usecs = static_cast<uint32_t>(usage.ru_utime.tv_usec); |
377 return 0; | 377 return 0; |
378 } | 378 } |
379 | 379 |
380 | 380 |
381 double OS::TimeCurrentMillis() { | 381 double OS::TimeCurrentMillis() { |
382 return Time::Now().ToJsTime(); | 382 return Time::Now().ToJsTime(); |
383 } | 383 } |
384 | 384 |
| 385 #if !V8_OS_AIX && !V8_OS_SOLARIS && !V8_OS_CYGWIN |
385 const char* PosixTimezoneCache::LocalTimezone(double time) { | 386 const char* PosixTimezoneCache::LocalTimezone(double time) { |
386 if (std::isnan(time)) return ""; | 387 if (std::isnan(time)) return ""; |
387 time_t tv = static_cast<time_t>(std::floor(time / msPerSecond)); | 388 time_t tv = static_cast<time_t>(std::floor(time / msPerSecond)); |
388 struct tm tm; | 389 struct tm tm; |
389 struct tm* t = localtime_r(&tv, &tm); | 390 struct tm* t = localtime_r(&tv, &tm); |
390 if (!t || !t->tm_zone) return ""; | 391 if (!t || !t->tm_zone) return ""; |
391 return t->tm_zone; | 392 return t->tm_zone; |
392 } | 393 } |
393 | 394 |
394 double PosixTimezoneCache::LocalTimeOffset() { | 395 double PosixTimezoneCache::LocalTimeOffset() { |
395 time_t tv = time(NULL); | 396 time_t tv = time(NULL); |
396 struct tm tm; | 397 struct tm tm; |
397 struct tm* t = localtime_r(&tv, &tm); | 398 struct tm* t = localtime_r(&tv, &tm); |
398 // tm_gmtoff includes any daylight savings offset, so subtract it. | 399 // tm_gmtoff includes any daylight savings offset, so subtract it. |
399 return static_cast<double>(t->tm_gmtoff * msPerSecond - | 400 return static_cast<double>(t->tm_gmtoff * msPerSecond - |
400 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); | 401 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); |
401 } | 402 } |
| 403 #endif |
402 | 404 |
403 double PosixTimezoneCache::DaylightSavingsOffset(double time) { | 405 double PosixTimezoneCache::DaylightSavingsOffset(double time) { |
404 if (std::isnan(time)) return std::numeric_limits<double>::quiet_NaN(); | 406 if (std::isnan(time)) return std::numeric_limits<double>::quiet_NaN(); |
405 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); | 407 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); |
406 struct tm tm; | 408 struct tm tm; |
407 struct tm* t = localtime_r(&tv, &tm); | 409 struct tm* t = localtime_r(&tv, &tm); |
408 if (NULL == t) return std::numeric_limits<double>::quiet_NaN(); | 410 if (NULL == t) return std::numeric_limits<double>::quiet_NaN(); |
409 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; | 411 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; |
410 } | 412 } |
411 | 413 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 | 771 |
770 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 772 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
771 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 773 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
772 int result = pthread_setspecific(pthread_key, value); | 774 int result = pthread_setspecific(pthread_key, value); |
773 DCHECK_EQ(0, result); | 775 DCHECK_EQ(0, result); |
774 USE(result); | 776 USE(result); |
775 } | 777 } |
776 | 778 |
777 } // namespace base | 779 } // namespace base |
778 } // namespace v8 | 780 } // namespace v8 |
OLD | NEW |