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 | 9 |
10 #include <malloc.h> // NOLINT | 10 #include <malloc.h> // NOLINT |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 __builtin_trap(); | 258 __builtin_trap(); |
259 #else | 259 #else |
260 // Microsoft style assembly. | 260 // Microsoft style assembly. |
261 __asm { | 261 __asm { |
262 int 3 | 262 int 3 |
263 } | 263 } |
264 #endif | 264 #endif |
265 } | 265 } |
266 | 266 |
267 | 267 |
268 DART_NOINLINE uintptr_t OS::GetProgramCounter() { | |
269 return reinterpret_cast<uintptr_t>(_ReturnAddress()); | |
270 } | |
271 | |
272 | |
273 char* OS::StrNDup(const char* s, intptr_t n) { | 268 char* OS::StrNDup(const char* s, intptr_t n) { |
274 intptr_t len = strlen(s); | 269 intptr_t len = strlen(s); |
275 if ((n < 0) || (len < 0)) { | 270 if ((n < 0) || (len < 0)) { |
276 return NULL; | 271 return NULL; |
277 } | 272 } |
278 if (n < len) { | 273 if (n < len) { |
279 len = n; | 274 len = n; |
280 } | 275 } |
281 char* result = reinterpret_cast<char*>(malloc(len + 1)); | 276 char* result = reinterpret_cast<char*>(malloc(len + 1)); |
282 if (result == NULL) { | 277 if (result == NULL) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // TODO(zra): Remove once VM shuts down cleanly. | 445 // TODO(zra): Remove once VM shuts down cleanly. |
451 private_flag_windows_run_tls_destructors = false; | 446 private_flag_windows_run_tls_destructors = false; |
452 // On Windows we use ExitProcess so that threads can't clobber the exit_code. | 447 // On Windows we use ExitProcess so that threads can't clobber the exit_code. |
453 // See: https://code.google.com/p/nativeclient/issues/detail?id=2870 | 448 // See: https://code.google.com/p/nativeclient/issues/detail?id=2870 |
454 ::ExitProcess(code); | 449 ::ExitProcess(code); |
455 } | 450 } |
456 | 451 |
457 } // namespace dart | 452 } // namespace dart |
458 | 453 |
459 #endif // defined(TARGET_OS_WINDOWS) | 454 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |