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

Side by Side Diff: src/base/platform/platform-posix.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-openbsd.cc ('k') | src/base/platform/platform-qnx.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 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 392
393 void OS::ClearTimezoneCache(TimezoneCache* cache) { 393 void OS::ClearTimezoneCache(TimezoneCache* cache) {
394 DCHECK(cache == NULL); 394 DCHECK(cache == NULL);
395 } 395 }
396 396
397 397
398 double OS::DaylightSavingsOffset(double time, TimezoneCache*) { 398 double OS::DaylightSavingsOffset(double time, TimezoneCache*) {
399 if (std::isnan(time)) return std::numeric_limits<double>::quiet_NaN(); 399 if (std::isnan(time)) return std::numeric_limits<double>::quiet_NaN();
400 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); 400 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
401 struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn) 401 struct tm tm;
402 struct tm* t = localtime_r(&tv, &tm);
402 if (NULL == t) return std::numeric_limits<double>::quiet_NaN(); 403 if (NULL == t) return std::numeric_limits<double>::quiet_NaN();
403 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; 404 return t->tm_isdst > 0 ? 3600 * msPerSecond : 0;
404 } 405 }
405 406
406 407
407 int OS::GetLastError() { 408 int OS::GetLastError() {
408 return errno; 409 return errno;
409 } 410 }
410 411
411 412
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 764
764 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { 765 void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
765 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); 766 pthread_key_t pthread_key = LocalKeyToPthreadKey(key);
766 int result = pthread_setspecific(pthread_key, value); 767 int result = pthread_setspecific(pthread_key, value);
767 DCHECK_EQ(0, result); 768 DCHECK_EQ(0, result);
768 USE(result); 769 USE(result);
769 } 770 }
770 771
771 } // namespace base 772 } // namespace base
772 } // namespace v8 773 } // namespace v8
OLDNEW
« no previous file with comments | « src/base/platform/platform-openbsd.cc ('k') | src/base/platform/platform-qnx.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698