| 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 7 | 7 |
| 8 #include <errno.h> // NOLINT | 8 #include <errno.h> // NOLINT |
| 9 #include <mach/clock.h> // NOLINT | 9 #include <mach/clock.h> // NOLINT |
| 10 #include <mach/mach.h> // NOLINT | 10 #include <mach/mach.h> // NOLINT |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 | 72 |
| 73 char* StringUtils::Utf8ToConsoleString( | 73 char* StringUtils::Utf8ToConsoleString( |
| 74 char* utf8, intptr_t len, intptr_t* result_len) { | 74 char* utf8, intptr_t len, intptr_t* result_len) { |
| 75 UNIMPLEMENTED(); | 75 UNIMPLEMENTED(); |
| 76 return NULL; | 76 return NULL; |
| 77 } | 77 } |
| 78 | 78 |
| 79 | 79 |
| 80 char* StringUtils::StrNDup(const char* s, intptr_t n) { | 80 char* StringUtils::StrNDup(const char* s, intptr_t n) { |
| 81 // strndup has only been added to Mac OS X in 10.7. We are supplying |
| 82 // our own copy here if needed. |
| 83 #if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \ |
| 84 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1060 |
| 85 intptr_t len = strlen(s); |
| 86 if ((n < 0) || (len < 0)) { |
| 87 return NULL; |
| 88 } |
| 89 if (n < len) { |
| 90 len = n; |
| 91 } |
| 92 char* result = reinterpret_cast<char*>(malloc(len + 1)); |
| 93 if (result == NULL) { |
| 94 return NULL; |
| 95 } |
| 96 result[len] = '\0'; |
| 97 return reinterpret_cast<char*>(memmove(result, s, len)); |
| 98 #else // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ... |
| 81 return strndup(s, n); | 99 return strndup(s, n); |
| 100 #endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ... |
| 82 } | 101 } |
| 83 | 102 |
| 84 | 103 |
| 85 bool ShellUtils::GetUtf8Argv(int argc, char** argv) { | 104 bool ShellUtils::GetUtf8Argv(int argc, char** argv) { |
| 86 return false; | 105 return false; |
| 87 } | 106 } |
| 88 | 107 |
| 89 | 108 |
| 90 static mach_timebase_info_data_t timebase_info; | 109 static mach_timebase_info_data_t timebase_info; |
| 91 | 110 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 ASSERT(errno == EINTR); | 178 ASSERT(errno == EINTR); |
| 160 // Copy remainder into requested and repeat. | 179 // Copy remainder into requested and repeat. |
| 161 req = rem; | 180 req = rem; |
| 162 } | 181 } |
| 163 } | 182 } |
| 164 | 183 |
| 165 } // namespace bin | 184 } // namespace bin |
| 166 } // namespace dart | 185 } // namespace dart |
| 167 | 186 |
| 168 #endif // defined(TARGET_OS_MACOS) | 187 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |