Chromium Code Reviews| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 // gettimeofday has microsecond resolution. | 61 // gettimeofday has microsecond resolution. |
| 62 struct timeval tv; | 62 struct timeval tv; |
| 63 if (gettimeofday(&tv, NULL) < 0) { | 63 if (gettimeofday(&tv, NULL) < 0) { |
| 64 UNREACHABLE(); | 64 UNREACHABLE(); |
| 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) { | |
| 72 const int kMinimumAlignment = 16; | |
| 73 ASSERT(Utils::IsPowerOfTwo(alignment)); | |
| 74 ASSERT(alignment >= kMinimumAlignment); | |
| 75 void* p = NULL; | |
| 76 int r; | |
| 77 r = posix_memalign(&p, alignment, size); | |
| 78 if (p == NULL) { | |
| 79 UNREACHABLE(); | |
| 80 return NULL; | |
|
cshapiro
2012/11/30 00:23:25
ditto
Cutch
2012/11/30 04:09:54
Done.
| |
| 81 } | |
| 82 return p; | |
| 83 } | |
| 84 | |
| 85 | |
| 86 void OS::AlignedFree(void* ptr) { | |
| 87 free(ptr); | |
| 88 } | |
| 89 | |
| 90 | |
| 71 word OS::ActivationFrameAlignment() { | 91 word OS::ActivationFrameAlignment() { |
| 72 // OS X activation frames must be 16 byte-aligned; see "Mac OS X ABI | 92 // OS X activation frames must be 16 byte-aligned; see "Mac OS X ABI |
| 73 // Function Call Guide". | 93 // Function Call Guide". |
| 74 return 16; | 94 return 16; |
| 75 } | 95 } |
| 76 | 96 |
| 77 | 97 |
| 78 word OS::PreferredCodeAlignment() { | 98 word OS::PreferredCodeAlignment() { |
| 79 ASSERT(32 <= OS::kMaxPreferredCodeAlignment); | 99 ASSERT(32 <= OS::kMaxPreferredCodeAlignment); |
| 80 return 32; | 100 return 32; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 void OS::Abort() { | 201 void OS::Abort() { |
| 182 abort(); | 202 abort(); |
| 183 } | 203 } |
| 184 | 204 |
| 185 | 205 |
| 186 void OS::Exit(int code) { | 206 void OS::Exit(int code) { |
| 187 exit(code); | 207 exit(code); |
| 188 } | 208 } |
| 189 | 209 |
| 190 } // namespace dart | 210 } // namespace dart |
| OLD | NEW |