| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/os.h" | 5 #include "vm/os.h" |
| 6 | 6 |
| 7 #include <malloc.h> |
| 7 #include <time.h> | 8 #include <time.h> |
| 8 | 9 |
| 9 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| 10 | 11 |
| 11 namespace dart { | 12 namespace dart { |
| 12 | 13 |
| 13 // As a side-effect sets the globals _timezone, _daylight and _tzname. | 14 // As a side-effect sets the globals _timezone, _daylight and _tzname. |
| 14 static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) { | 15 static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) { |
| 15 time_t seconds = static_cast<time_t>(seconds_since_epoch); | 16 time_t seconds = static_cast<time_t>(seconds_since_epoch); |
| 16 if (seconds != seconds_since_epoch) return false; | 17 if (seconds != seconds_since_epoch) return false; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 union TimeStamp { | 96 union TimeStamp { |
| 96 FILETIME ft_; | 97 FILETIME ft_; |
| 97 int64_t t_; | 98 int64_t t_; |
| 98 }; | 99 }; |
| 99 TimeStamp time; | 100 TimeStamp time; |
| 100 GetSystemTimeAsFileTime(&time.ft_); | 101 GetSystemTimeAsFileTime(&time.ft_); |
| 101 return (time.t_ - kTimeEpoc) / kTimeScaler; | 102 return (time.t_ - kTimeEpoc) / kTimeScaler; |
| 102 } | 103 } |
| 103 | 104 |
| 104 | 105 |
| 106 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { |
| 107 const int kMinimumAlignment = 16; |
| 108 ASSERT(Utils::IsPowerOfTwo(alignment)); |
| 109 ASSERT(alignment >= kMinimumAlignment); |
| 110 void* p = _aligned_malloc(size, alignment); |
| 111 if (p == NULL) { |
| 112 UNREACHABLE(); |
| 113 } |
| 114 return p; |
| 115 } |
| 116 |
| 117 |
| 118 void OS::AlignedFree(void* ptr) { |
| 119 _aligned_free(ptr); |
| 120 } |
| 121 |
| 122 |
| 105 word OS::ActivationFrameAlignment() { | 123 word OS::ActivationFrameAlignment() { |
| 106 #ifdef _WIN64 | 124 #ifdef _WIN64 |
| 107 // Windows 64-bit ABI requires the stack to be 16-byte aligned. | 125 // Windows 64-bit ABI requires the stack to be 16-byte aligned. |
| 108 return 16; | 126 return 16; |
| 109 #else | 127 #else |
| 110 // No requirements on Win32. | 128 // No requirements on Win32. |
| 111 return 0; | 129 return 0; |
| 112 #endif | 130 #endif |
| 113 } | 131 } |
| 114 | 132 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 void OS::Abort() { | 259 void OS::Abort() { |
| 242 abort(); | 260 abort(); |
| 243 } | 261 } |
| 244 | 262 |
| 245 | 263 |
| 246 void OS::Exit(int code) { | 264 void OS::Exit(int code) { |
| 247 exit(code); | 265 exit(code); |
| 248 } | 266 } |
| 249 | 267 |
| 250 } // namespace dart | 268 } // namespace dart |
| OLD | NEW |