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

Side by Side Diff: src/base/platform/platform-qnx.cc

Issue 2184673002: [base] Use thread safe localtime_r() instead of localtime(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « src/base/platform/platform-posix.cc ('k') | src/base/platform/platform-solaris.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 QNX goes here. For the POSIX-compatible 5 // Platform-specific code for QNX goes here. For the POSIX-compatible
6 // parts the implementation is in platform-posix.cc. 6 // parts the implementation is in platform-posix.cc.
7 7
8 #include <backtrace.h> 8 #include <backtrace.h>
9 #include <pthread.h> 9 #include <pthread.h>
10 #include <semaphore.h> 10 #include <semaphore.h>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #endif 81 #endif
82 #undef GCC_VERSION 82 #undef GCC_VERSION
83 } 83 }
84 84
85 #endif // __arm__ 85 #endif // __arm__
86 86
87 87
88 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { 88 const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
89 if (std::isnan(time)) return ""; 89 if (std::isnan(time)) return "";
90 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); 90 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
91 struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn) 91 struct tm tm;
92 struct tm* t = localtime_r(&tv, &tm);
92 if (NULL == t) return ""; 93 if (NULL == t) return "";
93 return t->tm_zone; 94 return t->tm_zone;
94 } 95 }
95 96
96 97
97 double OS::LocalTimeOffset(TimezoneCache* cache) { 98 double OS::LocalTimeOffset(TimezoneCache* cache) {
98 time_t tv = time(NULL); 99 time_t tv = time(NULL);
99 struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn) 100 struct tm tm;
101 struct tm* t = localtime_r(&tv, &tm);
100 // tm_gmtoff includes any daylight savings offset, so subtract it. 102 // tm_gmtoff includes any daylight savings offset, so subtract it.
101 return static_cast<double>(t->tm_gmtoff * msPerSecond - 103 return static_cast<double>(t->tm_gmtoff * msPerSecond -
102 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); 104 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
103 } 105 }
104 106
105 107
106 void* OS::Allocate(const size_t requested, 108 void* OS::Allocate(const size_t requested,
107 size_t* allocated, 109 size_t* allocated,
108 bool is_executable) { 110 bool is_executable) {
109 const size_t msize = RoundUp(requested, AllocateAlignment()); 111 const size_t msize = RoundUp(requested, AllocateAlignment());
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 return munmap(base, size) == 0; 309 return munmap(base, size) == 0;
308 } 310 }
309 311
310 312
311 bool VirtualMemory::HasLazyCommits() { 313 bool VirtualMemory::HasLazyCommits() {
312 return false; 314 return false;
313 } 315 }
314 316
315 } // namespace base 317 } // namespace base
316 } // namespace v8 318 } // namespace v8
OLDNEW
« no previous file with comments | « src/base/platform/platform-posix.cc ('k') | src/base/platform/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698