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/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "vm/os.h" | 8 #include "vm/os.h" |
9 #include "vm/vtune.h" | 9 #include "vm/vtune.h" |
10 | 10 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 asm("int $3"); | 171 asm("int $3"); |
172 #else | 172 #else |
173 // Microsoft style assembly. | 173 // Microsoft style assembly. |
174 __asm { | 174 __asm { |
175 int 3 | 175 int 3 |
176 } | 176 } |
177 #endif | 177 #endif |
178 } | 178 } |
179 | 179 |
180 | 180 |
| 181 char* OS::StrNDup(const char* s, intptr_t n) { |
| 182 intptr_t len = strlen(s); |
| 183 if ((n < 0) || (len < 0)) { |
| 184 return NULL; |
| 185 } |
| 186 if (n < len) { |
| 187 len = n; |
| 188 } |
| 189 char* result = reinterpret_cast<char*>(malloc(len + 1)); |
| 190 if (result == NULL) { |
| 191 return NULL; |
| 192 } |
| 193 result[len] = '\0'; |
| 194 return reinterpret_cast<char*>(memcpy(result, s, len)); |
| 195 } |
| 196 |
| 197 |
181 void OS::Print(const char* format, ...) { | 198 void OS::Print(const char* format, ...) { |
182 va_list args; | 199 va_list args; |
183 va_start(args, format); | 200 va_start(args, format); |
184 VFPrint(stdout, format, args); | 201 VFPrint(stdout, format, args); |
185 va_end(args); | 202 va_end(args); |
186 } | 203 } |
187 | 204 |
188 | 205 |
189 void OS::VFPrint(FILE* stream, const char* format, va_list args) { | 206 void OS::VFPrint(FILE* stream, const char* format, va_list args) { |
190 vfprintf(stream, format, args); | 207 vfprintf(stream, format, args); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 306 } |
290 | 307 |
291 | 308 |
292 void OS::Exit(int code) { | 309 void OS::Exit(int code) { |
293 exit(code); | 310 exit(code); |
294 } | 311 } |
295 | 312 |
296 } // namespace dart | 313 } // namespace dart |
297 | 314 |
298 #endif // defined(TARGET_OS_WINDOWS) | 315 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |