OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 AIX goes here. For the POSIX comaptible parts | 5 // Platform specific code for AIX goes here. For the POSIX comaptible parts |
6 // the implementation is in platform-posix.cc. | 6 // 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 28 matching lines...) Expand all Loading... |
39 static inline void* mmapHelper(size_t len, int prot, int flags, int fildes, | 39 static inline void* mmapHelper(size_t len, int prot, int flags, int fildes, |
40 off_t off) { | 40 off_t off) { |
41 void* addr = OS::GetRandomMmapAddr(); | 41 void* addr = OS::GetRandomMmapAddr(); |
42 return mmap(addr, len, prot, flags, fildes, off); | 42 return mmap(addr, len, prot, flags, fildes, off); |
43 } | 43 } |
44 | 44 |
45 | 45 |
46 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { | 46 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { |
47 if (std::isnan(time)) return ""; | 47 if (std::isnan(time)) return ""; |
48 time_t tv = static_cast<time_t>(floor(time / msPerSecond)); | 48 time_t tv = static_cast<time_t>(floor(time / msPerSecond)); |
49 struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn) | 49 struct tm tm; |
| 50 struct tm* t = localtime_r(&tv, &tm); |
50 if (NULL == t) return ""; | 51 if (NULL == t) return ""; |
51 return tzname[0]; // The location of the timezone string on AIX. | 52 return tzname[0]; // The location of the timezone string on AIX. |
52 } | 53 } |
53 | 54 |
54 | 55 |
55 double OS::LocalTimeOffset(TimezoneCache* cache) { | 56 double OS::LocalTimeOffset(TimezoneCache* cache) { |
56 // On AIX, struct tm does not contain a tm_gmtoff field. | 57 // On AIX, struct tm does not contain a tm_gmtoff field. |
57 time_t utc = time(NULL); | 58 time_t utc = time(NULL); |
58 DCHECK(utc != -1); | 59 DCHECK(utc != -1); |
59 struct tm* loc = localtime(&utc); // NOLINT(runtime/threadsafe_fn) | 60 struct tm tm; |
| 61 struct tm* loc = localtime_r(&utc, &tm); |
60 DCHECK(loc != NULL); | 62 DCHECK(loc != NULL); |
61 return static_cast<double>((mktime(loc) - utc) * msPerSecond); | 63 return static_cast<double>((mktime(loc) - utc) * msPerSecond); |
62 } | 64 } |
63 | 65 |
64 | 66 |
65 void* OS::Allocate(const size_t requested, size_t* allocated, bool executable) { | 67 void* OS::Allocate(const size_t requested, size_t* allocated, bool executable) { |
66 const size_t msize = RoundUp(requested, getpagesize()); | 68 const size_t msize = RoundUp(requested, getpagesize()); |
67 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); | 69 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); |
68 void* mbase = mmapHelper(msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 70 void* mbase = mmapHelper(msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
69 | 71 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 241 |
240 | 242 |
241 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { | 243 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { |
242 return munmap(base, size) == 0; | 244 return munmap(base, size) == 0; |
243 } | 245 } |
244 | 246 |
245 | 247 |
246 bool VirtualMemory::HasLazyCommits() { return true; } | 248 bool VirtualMemory::HasLazyCommits() { return true; } |
247 } // namespace base | 249 } // namespace base |
248 } // namespace v8 | 250 } // namespace v8 |
OLD | NEW |