| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef VM_OS_H_ | 5 #ifndef VM_OS_H_ |
| 6 #define VM_OS_H_ | 6 #define VM_OS_H_ |
| 7 | 7 |
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 | 9 |
| 10 // Forward declarations. | 10 // Forward declarations. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 static int NumberOfAvailableProcessors(); | 55 static int NumberOfAvailableProcessors(); |
| 56 | 56 |
| 57 // Sleep the currently executing thread for millis ms. | 57 // Sleep the currently executing thread for millis ms. |
| 58 static void Sleep(int64_t millis); | 58 static void Sleep(int64_t millis); |
| 59 | 59 |
| 60 // Print formatted output to stdout/stderr for debugging. | 60 // Print formatted output to stdout/stderr for debugging. |
| 61 static void Print(const char* format, ...); | 61 static void Print(const char* format, ...); |
| 62 static void PrintErr(const char* format, ...); | 62 static void PrintErr(const char* format, ...); |
| 63 static void VFPrint(FILE* stream, const char* format, va_list args); | 63 static void VFPrint(FILE* stream, const char* format, va_list args); |
| 64 // Print formatted output info a buffer. | 64 // Print formatted output info a buffer. |
| 65 // |
| 65 // Does not write more than size characters (including the trailing '\0'). | 66 // Does not write more than size characters (including the trailing '\0'). |
| 66 // Returns the number of characters (excluding the trailing '\0') that would | 67 // |
| 67 // been written if the buffer had been big enough. | 68 // Returns the number of characters (excluding the trailing '\0') |
| 68 // If the return value is greater or equal than the given size then the output | 69 // that would been written if the buffer had been big enough. If |
| 69 // has been truncated. | 70 // the return value is greater or equal than the given size then the |
| 70 // The buffer will always be terminated by a '\0', unless the buffer is of | 71 // output has been truncated. The return value is never negative. |
| 71 // size 0. | 72 // |
| 72 // The buffer might be NULL if the size is 0. | 73 // The buffer will always be terminated by a '\0', unless the buffer |
| 73 // This specification conforms to C99 standard which is implemented by | 74 // is of size 0. The buffer might be NULL if the size is 0. |
| 74 // glibc 2.1+. | 75 // |
| 76 // This specification conforms to C99 standard which is implemented |
| 77 // by glibc 2.1+ with one exception: the C99 standard allows a |
| 78 // negative return value. We will terminate the vm rather than let |
| 79 // that occur. |
| 75 static int SNPrint(char* str, size_t size, const char* format, ...); | 80 static int SNPrint(char* str, size_t size, const char* format, ...); |
| 76 static int VSNPrint(char* str, size_t size, | 81 static int VSNPrint(char* str, size_t size, |
| 77 const char* format, | 82 const char* format, |
| 78 va_list args); | 83 va_list args); |
| 79 | 84 |
| 80 // Initialize the OS class. | 85 // Initialize the OS class. |
| 81 static void InitOnce(); | 86 static void InitOnce(); |
| 82 | 87 |
| 83 // Shut down the OS class. | 88 // Shut down the OS class. |
| 84 static void Shutdown(); | 89 static void Shutdown(); |
| 85 | 90 |
| 86 static void Abort(); | 91 static void Abort(); |
| 87 | 92 |
| 88 static void Exit(int code); | 93 static void Exit(int code); |
| 89 }; | 94 }; |
| 90 | 95 |
| 91 } // namespace dart | 96 } // namespace dart |
| 92 | 97 |
| 93 #endif // VM_OS_H_ | 98 #endif // VM_OS_H_ |
| OLD | NEW |