| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_OS_FUCHSIA) | 6 #if defined(TARGET_OS_FUCHSIA) |
| 7 | 7 |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 | 9 |
| 10 #include <errno.h> | 10 #include <errno.h> |
| 11 #include <magenta/syscalls.h> | 11 #include <magenta/syscalls.h> |
| 12 #include <magenta/types.h> | 12 #include <magenta/types.h> |
| 13 #include <runtime/sysinfo.h> |
| 13 | 14 |
| 14 #include "platform/assert.h" | 15 #include "platform/assert.h" |
| 15 #include "vm/zone.h" | 16 #include "vm/zone.h" |
| 16 | 17 |
| 17 namespace dart { | 18 namespace dart { |
| 18 | 19 |
| 19 #ifndef PRODUCT | 20 #ifndef PRODUCT |
| 20 | 21 |
| 21 DEFINE_FLAG(bool, generate_perf_events_symbols, false, | 22 DEFINE_FLAG(bool, generate_perf_events_symbols, false, |
| 22 "Generate events symbols for profiling with perf"); | 23 "Generate events symbols for profiling with perf"); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 80 } |
| 80 | 81 |
| 81 | 82 |
| 82 int64_t OS::GetCurrentThreadCPUMicros() { | 83 int64_t OS::GetCurrentThreadCPUMicros() { |
| 83 UNIMPLEMENTED(); | 84 UNIMPLEMENTED(); |
| 84 return 0; | 85 return 0; |
| 85 } | 86 } |
| 86 | 87 |
| 87 | 88 |
| 88 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { | 89 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { |
| 89 UNIMPLEMENTED(); | 90 const int kMinimumAlignment = 16; |
| 90 return NULL; | 91 ASSERT(Utils::IsPowerOfTwo(alignment)); |
| 92 ASSERT(alignment >= kMinimumAlignment); |
| 93 void* p = memalign(alignment, size); |
| 94 if (p == NULL) { |
| 95 UNREACHABLE(); |
| 96 } |
| 97 return p; |
| 91 } | 98 } |
| 92 | 99 |
| 93 | 100 |
| 94 void OS::AlignedFree(void* ptr) { | 101 void OS::AlignedFree(void* ptr) { |
| 95 UNIMPLEMENTED(); | 102 free(ptr); |
| 96 } | 103 } |
| 97 | 104 |
| 98 | 105 |
| 99 // TODO(5411554): May need to hoist these architecture dependent code | 106 // TODO(5411554): May need to hoist these architecture dependent code |
| 100 // into a architecture specific file e.g: os_ia32_fuchsia.cc | 107 // into a architecture specific file e.g: os_ia32_fuchsia.cc |
| 101 intptr_t OS::ActivationFrameAlignment() { | 108 intptr_t OS::ActivationFrameAlignment() { |
| 102 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) || \ | 109 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) || \ |
| 103 defined(TARGET_ARCH_ARM64) | 110 defined(TARGET_ARCH_ARM64) |
| 104 const int kMinimumAlignment = 16; | 111 const int kMinimumAlignment = 16; |
| 105 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_DBC) | 112 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_DBC) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 146 } |
| 140 | 147 |
| 141 | 148 |
| 142 bool OS::AllowStackFrameIteratorFromAnotherThread() { | 149 bool OS::AllowStackFrameIteratorFromAnotherThread() { |
| 143 UNIMPLEMENTED(); | 150 UNIMPLEMENTED(); |
| 144 return false; | 151 return false; |
| 145 } | 152 } |
| 146 | 153 |
| 147 | 154 |
| 148 int OS::NumberOfAvailableProcessors() { | 155 int OS::NumberOfAvailableProcessors() { |
| 149 UNIMPLEMENTED(); | 156 return mxr_get_nprocs_conf(); |
| 150 return 0; | |
| 151 } | 157 } |
| 152 | 158 |
| 153 | 159 |
| 154 void OS::Sleep(int64_t millis) { | 160 void OS::Sleep(int64_t millis) { |
| 155 UNIMPLEMENTED(); | 161 mx_nanosleep( |
| 162 millis * kMicrosecondsPerMillisecond * kNanosecondsPerMicrosecond); |
| 156 } | 163 } |
| 157 | 164 |
| 158 | 165 |
| 159 void OS::SleepMicros(int64_t micros) { | 166 void OS::SleepMicros(int64_t micros) { |
| 160 UNIMPLEMENTED(); | 167 mx_nanosleep( |
| 168 micros * kNanosecondsPerMicrosecond); |
| 161 } | 169 } |
| 162 | 170 |
| 163 | 171 |
| 164 void OS::DebugBreak() { | 172 void OS::DebugBreak() { |
| 165 UNIMPLEMENTED(); | 173 UNIMPLEMENTED(); |
| 166 } | 174 } |
| 167 | 175 |
| 168 | 176 |
| 169 char* OS::StrNDup(const char* s, intptr_t n) { | 177 char* OS::StrNDup(const char* s, intptr_t n) { |
| 170 return strndup(s, n); | 178 return strndup(s, n); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 304 } |
| 297 | 305 |
| 298 | 306 |
| 299 void OS::Exit(int code) { | 307 void OS::Exit(int code) { |
| 300 UNIMPLEMENTED(); | 308 UNIMPLEMENTED(); |
| 301 } | 309 } |
| 302 | 310 |
| 303 } // namespace dart | 311 } // namespace dart |
| 304 | 312 |
| 305 #endif // defined(TARGET_OS_FUCHSIA) | 313 #endif // defined(TARGET_OS_FUCHSIA) |
| OLD | NEW |