Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: runtime/bin/utils_macos.cc

Issue 2480793002: clang-format runtime/bin (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/utils_linux.cc ('k') | runtime/bin/utils_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include <mach/mach_time.h> // NOLINT 11 #include <mach/mach_time.h> // NOLINT
12 #include <netdb.h> // NOLINT 12 #include <netdb.h> // NOLINT
13 #if TARGET_OS_IOS 13 #if TARGET_OS_IOS
14 #include <sys/sysctl.h> // NOLINT 14 #include <sys/sysctl.h> // NOLINT
15 #endif 15 #endif
16 #include <sys/time.h> // NOLINT 16 #include <sys/time.h> // NOLINT
17 #include <time.h> // NOLINT 17 #include <time.h> // NOLINT
18 18
19 #include "bin/utils.h" 19 #include "bin/utils.h"
20 #include "platform/assert.h" 20 #include "platform/assert.h"
21 #include "platform/utils.h" 21 #include "platform/utils.h"
22 22
23 namespace dart { 23 namespace dart {
24 namespace bin { 24 namespace bin {
25 25
26 OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) { 26 OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) {
27 set_sub_system(kSystem); 27 set_sub_system(kSystem);
(...skipping 14 matching lines...) Expand all
42 Utils::StrError(code, error_message, kBufferSize); 42 Utils::StrError(code, error_message, kBufferSize);
43 SetMessage(error_message); 43 SetMessage(error_message);
44 } else if (sub_system == kGetAddressInfo) { 44 } else if (sub_system == kGetAddressInfo) {
45 SetMessage(gai_strerror(code)); 45 SetMessage(gai_strerror(code));
46 } else { 46 } else {
47 UNREACHABLE(); 47 UNREACHABLE();
48 } 48 }
49 } 49 }
50 50
51 51
52 const char* StringUtils::ConsoleStringToUtf8( 52 const char* StringUtils::ConsoleStringToUtf8(const char* str,
53 const char* str, intptr_t len, intptr_t* result_len) { 53 intptr_t len,
54 intptr_t* result_len) {
54 UNIMPLEMENTED(); 55 UNIMPLEMENTED();
55 return NULL; 56 return NULL;
56 } 57 }
57 58
58 59
59 const char* StringUtils::Utf8ToConsoleString( 60 const char* StringUtils::Utf8ToConsoleString(const char* utf8,
60 const char* utf8, intptr_t len, intptr_t* result_len) { 61 intptr_t len,
62 intptr_t* result_len) {
61 UNIMPLEMENTED(); 63 UNIMPLEMENTED();
62 return NULL; 64 return NULL;
63 } 65 }
64 66
65 67
66 char* StringUtils::ConsoleStringToUtf8( 68 char* StringUtils::ConsoleStringToUtf8(char* str,
67 char* str, intptr_t len, intptr_t* result_len) { 69 intptr_t len,
70 intptr_t* result_len) {
68 UNIMPLEMENTED(); 71 UNIMPLEMENTED();
69 return NULL; 72 return NULL;
70 } 73 }
71 74
72 75
73 char* StringUtils::Utf8ToConsoleString( 76 char* StringUtils::Utf8ToConsoleString(char* utf8,
74 char* utf8, intptr_t len, intptr_t* result_len) { 77 intptr_t len,
78 intptr_t* result_len) {
75 UNIMPLEMENTED(); 79 UNIMPLEMENTED();
76 return NULL; 80 return NULL;
77 } 81 }
78 82
79 83
80 char* StringUtils::StrNDup(const char* s, intptr_t n) { 84 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 85 // strndup has only been added to Mac OS X in 10.7. We are supplying
82 // our own copy here if needed. 86 // our own copy here if needed.
83 #if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \ 87 #if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \
84 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1060 88 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1060
85 intptr_t len = strlen(s); 89 intptr_t len = strlen(s);
86 if ((n < 0) || (len < 0)) { 90 if ((n < 0) || (len < 0)) {
87 return NULL; 91 return NULL;
88 } 92 }
89 if (n < len) { 93 if (n < len) {
90 len = n; 94 len = n;
91 } 95 }
92 char* result = reinterpret_cast<char*>(malloc(len + 1)); 96 char* result = reinterpret_cast<char*>(malloc(len + 1));
93 if (result == NULL) { 97 if (result == NULL) {
94 return NULL; 98 return NULL;
95 } 99 }
96 result[len] = '\0'; 100 result[len] = '\0';
97 return reinterpret_cast<char*>(memmove(result, s, len)); 101 return reinterpret_cast<char*>(memmove(result, s, len));
98 #else // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ... 102 #else // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ...
99 return strndup(s, n); 103 return strndup(s, n);
100 #endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ... 104 #endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ...
101 } 105 }
102 106
103 107
104 bool ShellUtils::GetUtf8Argv(int argc, char** argv) { 108 bool ShellUtils::GetUtf8Argv(int argc, char** argv) {
105 return false; 109 return false;
106 } 110 }
107 111
108 112
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 ASSERT(errno == EINTR); 182 ASSERT(errno == EINTR);
179 // Copy remainder into requested and repeat. 183 // Copy remainder into requested and repeat.
180 req = rem; 184 req = rem;
181 } 185 }
182 } 186 }
183 187
184 } // namespace bin 188 } // namespace bin
185 } // namespace dart 189 } // namespace dart
186 190
187 #endif // defined(TARGET_OS_MACOS) 191 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/utils_linux.cc ('k') | runtime/bin/utils_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698