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

Side by Side Diff: src/base/platform/platform-macos.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-linux.cc ('k') | src/base/platform/platform-openbsd.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 // 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 MacOS goes here. For the POSIX-compatible 5 // Platform-specific code for MacOS 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 <dlfcn.h> 8 #include <dlfcn.h>
9 #include <mach/mach_init.h> 9 #include <mach/mach_init.h>
10 #include <mach-o/dyld.h> 10 #include <mach-o/dyld.h>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 96
97 97
98 void OS::SignalCodeMovingGC() { 98 void OS::SignalCodeMovingGC() {
99 } 99 }
100 100
101 101
102 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { 102 const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
103 if (std::isnan(time)) return ""; 103 if (std::isnan(time)) return "";
104 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); 104 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
105 struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn) 105 struct tm tm;
106 struct tm* t = localtime_r(&tv, &tm);
106 if (NULL == t) return ""; 107 if (NULL == t) return "";
107 return t->tm_zone; 108 return t->tm_zone;
108 } 109 }
109 110
110 111
111 double OS::LocalTimeOffset(TimezoneCache* cache) { 112 double OS::LocalTimeOffset(TimezoneCache* cache) {
112 time_t tv = time(NULL); 113 time_t tv = time(NULL);
113 struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn) 114 struct tm tm;
115 struct tm* t = localtime_r(&tv, &tm);
114 // tm_gmtoff includes any daylight savings offset, so subtract it. 116 // tm_gmtoff includes any daylight savings offset, so subtract it.
115 return static_cast<double>(t->tm_gmtoff * msPerSecond - 117 return static_cast<double>(t->tm_gmtoff * msPerSecond -
116 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); 118 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
117 } 119 }
118 120
119 121
120 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } 122 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { }
121 123
122 124
123 VirtualMemory::VirtualMemory(size_t size) 125 VirtualMemory::VirtualMemory(size_t size)
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return munmap(address, size) == 0; 250 return munmap(address, size) == 0;
249 } 251 }
250 252
251 253
252 bool VirtualMemory::HasLazyCommits() { 254 bool VirtualMemory::HasLazyCommits() {
253 return false; 255 return false;
254 } 256 }
255 257
256 } // namespace base 258 } // namespace base
257 } // namespace v8 259 } // namespace v8
OLDNEW
« no previous file with comments | « src/base/platform/platform-linux.cc ('k') | src/base/platform/platform-openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698