File tree Expand file tree Collapse file tree 12 files changed +88
-30
lines changed Expand file tree Collapse file tree 12 files changed +88
-30
lines changed Original file line number Diff line number Diff line change @@ -2507,6 +2507,8 @@ v8_component("v8_libbase") {
25072507
25082508 if (is_posix ) {
25092509 sources += [
2510+ " src/base/platform/platform-posix-time.cc" ,
2511+ " src/base/platform/platform-posix-time.h" ,
25102512 " src/base/platform/platform-posix.cc" ,
25112513 " src/base/platform/platform-posix.h" ,
25122514 ]
Original file line number Diff line number Diff line change 1010// system so their names cannot be changed without changing the scripts.
1111#define V8_MAJOR_VERSION 6
1212#define V8_MINOR_VERSION 0
13- #define V8_BUILD_NUMBER 286
14- #define V8_PATCH_LEVEL 52
13+ #define V8_BUILD_NUMBER 287
14+ #define V8_PATCH_LEVEL 53
1515
1616// Use 1 for candidates and 0 otherwise.
1717// (Boolean macro values are not supported by all preprocessors.)
Original file line number Diff line number Diff line change 2929#undef MAP_TYPE
3030
3131#include " src/base/macros.h"
32+ #include " src/base/platform/platform-posix-time.h"
3233#include " src/base/platform/platform-posix.h"
3334#include " src/base/platform/platform.h"
3435
3536namespace v8 {
3637namespace base {
3738
38- TimezoneCache* OS::CreateTimezoneCache () { return new PosixTimezoneCache (); }
39+ TimezoneCache* OS::CreateTimezoneCache () {
40+ return new PosixDefaultTimezoneCache ();
41+ }
3942
4043void * OS::Allocate (const size_t requested, size_t * allocated,
4144 OS::MemoryPermission access) {
Original file line number Diff line number Diff line change 4444#undef MAP_TYPE
4545
4646#include " src/base/macros.h"
47+ #include " src/base/platform/platform-posix-time.h"
4748#include " src/base/platform/platform-posix.h"
4849#include " src/base/platform/platform.h"
4950
@@ -92,7 +93,9 @@ bool OS::ArmUsingHardFloat() {
9293
9394#endif // def __arm__
9495
95- TimezoneCache* OS::CreateTimezoneCache () { return new PosixTimezoneCache (); }
96+ TimezoneCache* OS::CreateTimezoneCache () {
97+ return new PosixDefaultTimezoneCache ();
98+ }
9699
97100void * OS::Allocate (const size_t requested, size_t * allocated,
98101 OS::MemoryPermission access) {
Original file line number Diff line number Diff line change 3636#undef MAP_TYPE
3737
3838#include " src/base/macros.h"
39+ #include " src/base/platform/platform-posix-time.h"
3940#include " src/base/platform/platform-posix.h"
4041#include " src/base/platform/platform.h"
4142
42-
4343namespace v8 {
4444namespace base {
4545
@@ -97,7 +97,9 @@ std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
9797void OS::SignalCodeMovingGC () {
9898}
9999
100- TimezoneCache* OS::CreateTimezoneCache () { return new PosixTimezoneCache (); }
100+ TimezoneCache* OS::CreateTimezoneCache () {
101+ return new PosixDefaultTimezoneCache ();
102+ }
101103
102104VirtualMemory::VirtualMemory () : address_(NULL ), size_(0 ) { }
103105
Original file line number Diff line number Diff line change 2727#undef MAP_TYPE
2828
2929#include " src/base/macros.h"
30+ #include " src/base/platform/platform-posix-time.h"
3031#include " src/base/platform/platform-posix.h"
3132#include " src/base/platform/platform.h"
3233
3334namespace v8 {
3435namespace base {
3536
36- TimezoneCache* OS::CreateTimezoneCache () { return new PosixTimezoneCache (); }
37+ TimezoneCache* OS::CreateTimezoneCache () {
38+ return new PosixDefaultTimezoneCache ();
39+ }
3740
3841void * OS::Allocate (const size_t requested, size_t * allocated,
3942 OS::MemoryPermission access) {
Original file line number Diff line number Diff line change 1+ // Copyright 2017 the V8 project authors. All rights reserved.
2+ // Use of this source code is governed by a BSD-style license that can be
3+ // found in the LICENSE file.
4+
5+ #include < cmath>
6+
7+ #include " src/base/platform/platform-posix-time.h"
8+
9+ namespace v8 {
10+ namespace base {
11+
12+ const char * PosixDefaultTimezoneCache::LocalTimezone (double time) {
13+ if (std::isnan (time)) return " " ;
14+ time_t tv = static_cast <time_t >(std::floor (time / msPerSecond));
15+ struct tm tm;
16+ struct tm * t = localtime_r (&tv, &tm);
17+ if (!t || !t->tm_zone ) return " " ;
18+ return t->tm_zone ;
19+ }
20+
21+ double PosixDefaultTimezoneCache::LocalTimeOffset () {
22+ time_t tv = time (NULL );
23+ struct tm tm;
24+ struct tm * t = localtime_r (&tv, &tm);
25+ // tm_gmtoff includes any daylight savings offset, so subtract it.
26+ return static_cast <double >(t->tm_gmtoff * msPerSecond -
27+ (t->tm_isdst > 0 ? 3600 * msPerSecond : 0 ));
28+ }
29+
30+ } // namespace base
31+ } // namespace v8
Original file line number Diff line number Diff line change 1+ // Copyright 2017 the V8 project authors. All rights reserved.
2+ // Use of this source code is governed by a BSD-style license that can be
3+ // found in the LICENSE file.
4+
5+ #include " src/base/platform/platform-posix.h"
6+
7+ namespace v8 {
8+ namespace base {
9+
10+ class PosixDefaultTimezoneCache : public PosixTimezoneCache {
11+ public:
12+ const char * LocalTimezone (double time_ms) override ;
13+ double LocalTimeOffset () override ;
14+
15+ ~PosixDefaultTimezoneCache () override {}
16+ };
17+
18+ } // namespace base
19+ } // namespace v8
Original file line number Diff line number Diff line change @@ -388,26 +388,6 @@ double OS::TimeCurrentMillis() {
388388 return Time::Now ().ToJsTime ();
389389}
390390
391- #if !V8_OS_AIX && !V8_OS_SOLARIS && !V8_OS_CYGWIN
392- const char * PosixTimezoneCache::LocalTimezone (double time) {
393- if (std::isnan (time)) return " " ;
394- time_t tv = static_cast <time_t >(std::floor (time / msPerSecond));
395- struct tm tm;
396- struct tm * t = localtime_r (&tv, &tm);
397- if (!t || !t->tm_zone ) return " " ;
398- return t->tm_zone ;
399- }
400-
401- double PosixTimezoneCache::LocalTimeOffset () {
402- time_t tv = time (NULL );
403- struct tm tm;
404- struct tm * t = localtime_r (&tv, &tm);
405- // tm_gmtoff includes any daylight savings offset, so subtract it.
406- return static_cast <double >(t->tm_gmtoff * msPerSecond -
407- (t->tm_isdst > 0 ? 3600 * msPerSecond : 0 ));
408- }
409- #endif
410-
411391double PosixTimezoneCache::DaylightSavingsOffset (double time) {
412392 if (std::isnan (time)) return std::numeric_limits<double >::quiet_NaN ();
413393 time_t tv = static_cast <time_t >(std::floor (time/msPerSecond));
Original file line number Diff line number Diff line change @@ -13,9 +13,7 @@ namespace base {
1313
1414class PosixTimezoneCache : public TimezoneCache {
1515 public:
16- const char * LocalTimezone (double time_ms) override ;
1716 double DaylightSavingsOffset (double time_ms) override ;
18- double LocalTimeOffset () override ;
1917 void Clear () override {}
2018 ~PosixTimezoneCache () override {}
2119
You can’t perform that action at this time.
0 commit comments