| 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 |
| 10 // Forward declarations. | 11 // Forward declarations. |
| 11 struct tm; | 12 struct tm; |
| 12 | 13 |
| 13 namespace dart { | 14 namespace dart { |
| 14 | 15 |
| 15 // Forward declarations. | 16 // Forward declarations. |
| 16 class Isolate; | 17 class Isolate; |
| 18 class Zone; |
| 17 | 19 |
| 18 // Interface to the underlying OS platform. | 20 // Interface to the underlying OS platform. |
| 19 class OS { | 21 class OS { |
| 20 public: | 22 public: |
| 21 // Returns the name of the given OS. For example "linux". | 23 // Returns the name of the given OS. For example "linux". |
| 22 static const char* Name(); | 24 static const char* Name(); |
| 23 | 25 |
| 24 // Returns the current process id. | 26 // Returns the current process id. |
| 25 static intptr_t ProcessId(); | 27 static intptr_t ProcessId(); |
| 26 | 28 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // This specification conforms to C99 standard which is implemented | 115 // This specification conforms to C99 standard which is implemented |
| 114 // by glibc 2.1+ with one exception: the C99 standard allows a | 116 // by glibc 2.1+ with one exception: the C99 standard allows a |
| 115 // negative return value. We will terminate the vm rather than let | 117 // negative return value. We will terminate the vm rather than let |
| 116 // that occur. | 118 // that occur. |
| 117 static int SNPrint(char* str, size_t size, const char* format, ...) | 119 static int SNPrint(char* str, size_t size, const char* format, ...) |
| 118 PRINTF_ATTRIBUTE(3, 4); | 120 PRINTF_ATTRIBUTE(3, 4); |
| 119 static int VSNPrint(char* str, size_t size, | 121 static int VSNPrint(char* str, size_t size, |
| 120 const char* format, | 122 const char* format, |
| 121 va_list args); | 123 va_list args); |
| 122 | 124 |
| 125 // Allocate a string and print formatted output into the buffer. |
| 126 // Uses the zone for allocation if one if provided, and otherwise uses |
| 127 // malloc. |
| 128 static char* SNCreate(Zone* zone, const char* format, ...) |
| 129 PRINTF_ATTRIBUTE(2, 3); |
| 130 |
| 123 // Converts a C string which represents a valid dart integer into a 64 bit | 131 // Converts a C string which represents a valid dart integer into a 64 bit |
| 124 // value. | 132 // value. |
| 125 // Returns false if it is unable to convert the string to a 64 bit value, | 133 // Returns false if it is unable to convert the string to a 64 bit value, |
| 126 // the failure could be because of underflow/overflow or invalid characters. | 134 // the failure could be because of underflow/overflow or invalid characters. |
| 127 // On success the function returns true and 'value' contains the converted | 135 // On success the function returns true and 'value' contains the converted |
| 128 // value. | 136 // value. |
| 129 static bool StringToInt64(const char* str, int64_t* value); | 137 static bool StringToInt64(const char* str, int64_t* value); |
| 130 | 138 |
| 131 // Register code observers relevant to this OS. | 139 // Register code observers relevant to this OS. |
| 132 static void RegisterCodeObservers(); | 140 static void RegisterCodeObservers(); |
| 133 | 141 |
| 134 // Initialize the OS class. | 142 // Initialize the OS class. |
| 135 static void InitOnce(); | 143 static void InitOnce(); |
| 136 | 144 |
| 137 // Shut down the OS class. | 145 // Shut down the OS class. |
| 138 static void Shutdown(); | 146 static void Shutdown(); |
| 139 | 147 |
| 140 static void Abort(); | 148 static void Abort(); |
| 141 | 149 |
| 142 static void Exit(int code); | 150 static void Exit(int code); |
| 143 }; | 151 }; |
| 144 | 152 |
| 145 } // namespace dart | 153 } // namespace dart |
| 146 | 154 |
| 147 #endif // VM_OS_H_ | 155 #endif // VM_OS_H_ |
| OLD | NEW |