OLD | NEW |
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 Cygwin goes here. For the POSIX-compatible | 5 // Platform-specific code for Cygwin 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 <errno.h> | 8 #include <errno.h> |
9 #include <pthread.h> | 9 #include <pthread.h> |
10 #include <semaphore.h> | 10 #include <semaphore.h> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "src/base/platform/platform.h" | 22 #include "src/base/platform/platform.h" |
23 #include "src/base/win32-headers.h" | 23 #include "src/base/win32-headers.h" |
24 | 24 |
25 namespace v8 { | 25 namespace v8 { |
26 namespace base { | 26 namespace base { |
27 | 27 |
28 | 28 |
29 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { | 29 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { |
30 if (std::isnan(time)) return ""; | 30 if (std::isnan(time)) return ""; |
31 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); | 31 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); |
32 struct tm* t = localtime(&tv); | 32 struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn) |
33 if (NULL == t) return ""; | 33 if (NULL == t) return ""; |
34 return tzname[0]; // The location of the timezone string on Cygwin. | 34 return tzname[0]; // The location of the timezone string on Cygwin. |
35 } | 35 } |
36 | 36 |
37 | 37 |
38 double OS::LocalTimeOffset(TimezoneCache* cache) { | 38 double OS::LocalTimeOffset(TimezoneCache* cache) { |
39 // On Cygwin, struct tm does not contain a tm_gmtoff field. | 39 // On Cygwin, struct tm does not contain a tm_gmtoff field. |
40 time_t utc = time(NULL); | 40 time_t utc = time(NULL); |
41 DCHECK(utc != -1); | 41 DCHECK(utc != -1); |
42 struct tm* loc = localtime(&utc); | 42 struct tm* loc = localtime(&utc); // NOLINT(runtime/threadsafe_fn) |
43 DCHECK(loc != NULL); | 43 DCHECK(loc != NULL); |
44 // time - localtime includes any daylight savings offset, so subtract it. | 44 // time - localtime includes any daylight savings offset, so subtract it. |
45 return static_cast<double>((mktime(loc) - utc) * msPerSecond - | 45 return static_cast<double>((mktime(loc) - utc) * msPerSecond - |
46 (loc->tm_isdst > 0 ? 3600 * msPerSecond : 0)); | 46 (loc->tm_isdst > 0 ? 3600 * msPerSecond : 0)); |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 void* OS::Allocate(const size_t requested, | 50 void* OS::Allocate(const size_t requested, |
51 size_t* allocated, | 51 size_t* allocated, |
52 bool is_executable) { | 52 bool is_executable) { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 return VirtualFree(base, 0, MEM_RELEASE) != 0; | 246 return VirtualFree(base, 0, MEM_RELEASE) != 0; |
247 } | 247 } |
248 | 248 |
249 | 249 |
250 bool VirtualMemory::HasLazyCommits() { | 250 bool VirtualMemory::HasLazyCommits() { |
251 // TODO(alph): implement for the platform. | 251 // TODO(alph): implement for the platform. |
252 return false; | 252 return false; |
253 } | 253 } |
254 | 254 |
255 } } // namespace v8::base | 255 } } // namespace v8::base |
OLD | NEW |