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 <errno.h> | 7 #include <errno.h> |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <mach/mach.h> | 9 #include <mach/mach.h> |
10 #include <mach/clock.h> | 10 #include <mach/clock.h> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 return 0; | 65 return 0; |
66 } | 66 } |
67 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; | 67 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; |
68 } | 68 } |
69 | 69 |
70 | 70 |
71 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { | 71 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { |
72 const int kMinimumAlignment = 16; | 72 const int kMinimumAlignment = 16; |
73 ASSERT(Utils::IsPowerOfTwo(alignment)); | 73 ASSERT(Utils::IsPowerOfTwo(alignment)); |
74 ASSERT(alignment >= kMinimumAlignment); | 74 ASSERT(alignment >= kMinimumAlignment); |
75 void* p = NULL; | 75 // Temporary workaround until xcode is upgraded. |
76 int r; | 76 // Mac guarantees malloc returns a 16 byte aligned memory chunk. |
77 r = posix_memalign(&p, alignment, size); | 77 // Currently we only allocate with 16-bye alignment. |
78 if (p == NULL) { | 78 ASSERT(alignment == 16); |
79 UNREACHABLE(); | 79 // TODO(johnmccutchan): Remove hack and switch to posix_memalign. |
80 } | 80 return malloc(size); |
81 return p; | |
82 } | 81 } |
83 | 82 |
84 | 83 |
85 void OS::AlignedFree(void* ptr) { | 84 void OS::AlignedFree(void* ptr) { |
86 free(ptr); | 85 free(ptr); |
87 } | 86 } |
88 | 87 |
89 | 88 |
90 word OS::ActivationFrameAlignment() { | 89 word OS::ActivationFrameAlignment() { |
91 // OS X activation frames must be 16 byte-aligned; see "Mac OS X ABI | 90 // OS X activation frames must be 16 byte-aligned; see "Mac OS X ABI |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void OS::Abort() { | 199 void OS::Abort() { |
201 abort(); | 200 abort(); |
202 } | 201 } |
203 | 202 |
204 | 203 |
205 void OS::Exit(int code) { | 204 void OS::Exit(int code) { |
206 exit(code); | 205 exit(code); |
207 } | 206 } |
208 | 207 |
209 } // namespace dart | 208 } // namespace dart |
OLD | NEW |