OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef VM_OS_H_ | 5 #ifndef VM_OS_H_ |
6 #define VM_OS_H_ | 6 #define VM_OS_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 | 9 |
10 // Forward declarations. | 10 // Forward declarations. |
(...skipping 22 matching lines...) Expand all Loading... |
33 static int GetLocalTimeZoneAdjustmentInSeconds(); | 33 static int GetLocalTimeZoneAdjustmentInSeconds(); |
34 | 34 |
35 // Returns the current time in milliseconds measured | 35 // Returns the current time in milliseconds measured |
36 // from midnight January 1, 1970 UTC. | 36 // from midnight January 1, 1970 UTC. |
37 static int64_t GetCurrentTimeMillis(); | 37 static int64_t GetCurrentTimeMillis(); |
38 | 38 |
39 // Returns the current time in microseconds measured | 39 // Returns the current time in microseconds measured |
40 // from midnight January 1, 1970 UTC. | 40 // from midnight January 1, 1970 UTC. |
41 static int64_t GetCurrentTimeMicros(); | 41 static int64_t GetCurrentTimeMicros(); |
42 | 42 |
43 // Returns an aligned array of type T with n entries. | 43 // Returns a cleared aligned array of type T with n entries. |
44 // Alignment must be >= 16 and a power of two. | 44 // Alignment must be >= 16 and a power of two. |
45 template<typename T> | 45 template<typename T> |
46 static T* AllocateAlignedArray(intptr_t n, intptr_t alignment) { | 46 static T* AllocateAlignedArray(intptr_t n, intptr_t alignment) { |
47 T* result = reinterpret_cast<T*>(OS::AlignedAllocate(n * sizeof(*result), | 47 T* result = reinterpret_cast<T*>(OS::AlignedAllocate(n * sizeof(*result), |
48 alignment)); | 48 alignment)); |
| 49 memset(result, 0, n * sizeof(*result)); |
49 return result; | 50 return result; |
50 } | 51 } |
51 | 52 |
52 // Returns an aligned pointer in the C heap with room for size bytes. | 53 // Returns an aligned pointer in the C heap with room for size bytes. |
53 // Alignment must be >= 16 and a power of two. | 54 // Alignment must be >= 16 and a power of two. |
54 static void* AlignedAllocate(intptr_t size, intptr_t alignment); | 55 static void* AlignedAllocate(intptr_t size, intptr_t alignment); |
55 | 56 |
56 // Frees a pointer returned from AlignedAllocate. | 57 // Frees a pointer returned from AlignedAllocate. |
57 static void AlignedFree(void* ptr); | 58 static void AlignedFree(void* ptr); |
58 | 59 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 static void Shutdown(); | 122 static void Shutdown(); |
122 | 123 |
123 static void Abort(); | 124 static void Abort(); |
124 | 125 |
125 static void Exit(int code); | 126 static void Exit(int code); |
126 }; | 127 }; |
127 | 128 |
128 } // namespace dart | 129 } // namespace dart |
129 | 130 |
130 #endif // VM_OS_H_ | 131 #endif // VM_OS_H_ |
OLD | NEW |