| 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/os.h" | 5 #include "vm/os.h" |
| 6 | 6 |
| 7 #include <android/log.h> | 7 #include <android/log.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <limits.h> | 9 #include <limits.h> |
| 10 #include <malloc.h> | 10 #include <malloc.h> |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 return sysconf(_SC_NPROCESSORS_ONLN); | 302 return sysconf(_SC_NPROCESSORS_ONLN); |
| 303 } | 303 } |
| 304 | 304 |
| 305 | 305 |
| 306 void OS::Sleep(int64_t millis) { | 306 void OS::Sleep(int64_t millis) { |
| 307 // TODO(5411554): For now just use usleep we may have to revisit this. | 307 // TODO(5411554): For now just use usleep we may have to revisit this. |
| 308 usleep(millis * 1000); | 308 usleep(millis * 1000); |
| 309 } | 309 } |
| 310 | 310 |
| 311 | 311 |
| 312 void OS::DebugBreak() { |
| 313 UNIMPLEMENTED(); |
| 314 } |
| 315 |
| 316 |
| 312 void OS::Print(const char* format, ...) { | 317 void OS::Print(const char* format, ...) { |
| 313 va_list args; | 318 va_list args; |
| 314 va_start(args, format); | 319 va_start(args, format); |
| 315 VFPrint(stdout, format, args); | 320 VFPrint(stdout, format, args); |
| 316 // Forward to the Android log for remote access. | 321 // Forward to the Android log for remote access. |
| 317 __android_log_vprint(ANDROID_LOG_INFO, "DartVM", format, args); | 322 __android_log_vprint(ANDROID_LOG_INFO, "DartVM", format, args); |
| 318 va_end(args); | 323 va_end(args); |
| 319 } | 324 } |
| 320 | 325 |
| 321 | 326 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 void OS::PrintErr(const char* format, ...) { | 386 void OS::PrintErr(const char* format, ...) { |
| 382 va_list args; | 387 va_list args; |
| 383 va_start(args, format); | 388 va_start(args, format); |
| 384 VFPrint(stderr, format, args); | 389 VFPrint(stderr, format, args); |
| 385 // Forward to the Android log for remote access. | 390 // Forward to the Android log for remote access. |
| 386 __android_log_vprint(ANDROID_LOG_ERROR, "DartVM", format, args); | 391 __android_log_vprint(ANDROID_LOG_ERROR, "DartVM", format, args); |
| 387 va_end(args); | 392 va_end(args); |
| 388 } | 393 } |
| 389 | 394 |
| 390 | 395 |
| 396 // Cache the null page size. |
| 397 uword OS::null_page_size_ = 0; |
| 398 |
| 399 |
| 391 void OS::InitOnce() { | 400 void OS::InitOnce() { |
| 392 // TODO(5411554): For now we check that initonce is called only once, | 401 // TODO(5411554): For now we check that initonce is called only once, |
| 393 // Once there is more formal mechanism to call InitOnce we can move | 402 // Once there is more formal mechanism to call InitOnce we can move |
| 394 // this check there. | 403 // this check there. |
| 395 static bool init_once_called = false; | 404 static bool init_once_called = false; |
| 396 ASSERT(init_once_called == false); | 405 ASSERT(init_once_called == false); |
| 397 init_once_called = true; | 406 init_once_called = true; |
| 407 |
| 408 // Initialize the null page size. |
| 409 null_page_size_ = static_cast<uword>(getpagesize()); |
| 398 } | 410 } |
| 399 | 411 |
| 400 | 412 |
| 401 void OS::Shutdown() { | 413 void OS::Shutdown() { |
| 402 } | 414 } |
| 403 | 415 |
| 404 | 416 |
| 405 void OS::Abort() { | 417 void OS::Abort() { |
| 406 abort(); | 418 abort(); |
| 407 } | 419 } |
| 408 | 420 |
| 409 | 421 |
| 410 void OS::Exit(int code) { | 422 void OS::Exit(int code) { |
| 411 exit(code); | 423 exit(code); |
| 412 } | 424 } |
| 413 | 425 |
| 414 } // namespace dart | 426 } // namespace dart |
| OLD | NEW |