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

Side by Side Diff: src/base/platform/platform-openbsd.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-macos.cc ('k') | src/base/platform/platform-posix.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 OpenBSD and NetBSD goes here. For the 5 // Platform-specific code for OpenBSD and NetBSD goes here. For the
6 // POSIX-compatible parts, the implementation is in platform-posix.cc. 6 // POSIX-compatible parts, the implementation is in platform-posix.cc.
7 7
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <semaphore.h> 9 #include <semaphore.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 19 matching lines...) Expand all
30 #include "src/base/platform/platform.h" 30 #include "src/base/platform/platform.h"
31 31
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace base { 34 namespace base {
35 35
36 36
37 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { 37 const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
38 if (std::isnan(time)) return ""; 38 if (std::isnan(time)) return "";
39 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); 39 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
40 struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn) 40 struct tm tm;
41 struct tm* t = localtime_r(&tv, &tm);
41 if (NULL == t) return ""; 42 if (NULL == t) return "";
42 return t->tm_zone; 43 return t->tm_zone;
43 } 44 }
44 45
45 46
46 double OS::LocalTimeOffset(TimezoneCache* cache) { 47 double OS::LocalTimeOffset(TimezoneCache* cache) {
47 time_t tv = time(NULL); 48 time_t tv = time(NULL);
48 struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn) 49 struct tm tm;
50 struct tm* t = localtime_r(&tv, &tm);
49 // tm_gmtoff includes any daylight savings offset, so subtract it. 51 // tm_gmtoff includes any daylight savings offset, so subtract it.
50 return static_cast<double>(t->tm_gmtoff * msPerSecond - 52 return static_cast<double>(t->tm_gmtoff * msPerSecond -
51 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); 53 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
52 } 54 }
53 55
54 56
55 void* OS::Allocate(const size_t requested, 57 void* OS::Allocate(const size_t requested,
56 size_t* allocated, 58 size_t* allocated,
57 bool is_executable) { 59 bool is_executable) {
58 const size_t msize = RoundUp(requested, AllocateAlignment()); 60 const size_t msize = RoundUp(requested, AllocateAlignment());
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 283 }
282 284
283 285
284 bool VirtualMemory::HasLazyCommits() { 286 bool VirtualMemory::HasLazyCommits() {
285 // TODO(alph): implement for the platform. 287 // TODO(alph): implement for the platform.
286 return false; 288 return false;
287 } 289 }
288 290
289 } // namespace base 291 } // namespace base
290 } // namespace v8 292 } // namespace v8
OLDNEW
« no previous file with comments | « src/base/platform/platform-macos.cc ('k') | src/base/platform/platform-posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698