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. |
11 struct tm; | 11 struct tm; |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 // Forward declarations. | 15 // Forward declarations. |
16 class Isolate; | 16 class Isolate; |
| 17 class Zone; |
17 | 18 |
18 // Interface to the underlying OS platform. | 19 // Interface to the underlying OS platform. |
19 class OS { | 20 class OS { |
20 public: | 21 public: |
21 // Returns the name of the given OS. For example "linux". | 22 // Returns the name of the given OS. For example "linux". |
22 static const char* Name(); | 23 static const char* Name(); |
23 | 24 |
24 // Returns the current process id. | 25 // Returns the current process id. |
25 static intptr_t ProcessId(); | 26 static intptr_t ProcessId(); |
26 | 27 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // This specification conforms to C99 standard which is implemented | 114 // This specification conforms to C99 standard which is implemented |
114 // by glibc 2.1+ with one exception: the C99 standard allows a | 115 // by glibc 2.1+ with one exception: the C99 standard allows a |
115 // negative return value. We will terminate the vm rather than let | 116 // negative return value. We will terminate the vm rather than let |
116 // that occur. | 117 // that occur. |
117 static int SNPrint(char* str, size_t size, const char* format, ...) | 118 static int SNPrint(char* str, size_t size, const char* format, ...) |
118 PRINTF_ATTRIBUTE(3, 4); | 119 PRINTF_ATTRIBUTE(3, 4); |
119 static int VSNPrint(char* str, size_t size, | 120 static int VSNPrint(char* str, size_t size, |
120 const char* format, | 121 const char* format, |
121 va_list args); | 122 va_list args); |
122 | 123 |
| 124 // Allocate a string and print formatted output into the buffer. |
| 125 // Uses the zone for allocation if one if provided, and otherwise uses |
| 126 // malloc. |
| 127 static char* SCreate(Zone* zone, const char* format, ...) |
| 128 PRINTF_ATTRIBUTE(2, 3); |
| 129 static char* VSCreate(Zone* zone, const char* format, va_list args); |
| 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 |