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 #ifndef BIN_PLATFORM_H_ | 5 #ifndef BIN_PLATFORM_H_ |
6 #define BIN_PLATFORM_H_ | 6 #define BIN_PLATFORM_H_ |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 | 9 |
10 class Platform { | 10 class Platform { |
11 public: | 11 public: |
12 // Perform platform specific initialization. | 12 // Perform platform specific initialization. |
13 static bool Initialize(); | 13 static bool Initialize(); |
14 | 14 |
15 // Returns the number of processors on the machine. | 15 // Returns the number of processors on the machine. |
16 static int NumberOfProcessors(); | 16 static int NumberOfProcessors(); |
17 | 17 |
18 // Returns a string representing the operating system ("linux", | 18 // Returns a string representing the operating system ("linux", |
19 // "macos" or "windows"). The returned string should not be | 19 // "macos" or "windows"). The returned string should not be |
20 // deallocated by the caller. | 20 // deallocated by the caller. |
21 static const char* OperatingSystem(); | 21 static const char* OperatingSystem(); |
22 | 22 |
23 // Returns a string representation of an error code. The returned | |
24 // string must be deallocated by the caller. | |
25 static char* StrError(int error_code); | |
26 | |
27 // Extracts the local hostname. | 23 // Extracts the local hostname. |
28 static bool LocalHostname(char* buffer, intptr_t buffer_length); | 24 static bool LocalHostname(char* buffer, intptr_t buffer_length); |
29 | 25 |
30 // Extracts the environment variables for the current process. The | 26 // Extracts the environment variables for the current process. The |
31 // array of strings returned must be deallocated using | 27 // array of strings returned must be deallocated using |
32 // FreeEnvironment. The number of elements in the array is returned | 28 // FreeEnvironment. The number of elements in the array is returned |
33 // in the count argument. | 29 // in the count argument. |
34 static char** Environment(intptr_t* count); | 30 static char** Environment(intptr_t* count); |
35 static void FreeEnvironment(char** env, intptr_t count); | 31 static void FreeEnvironment(char** env, intptr_t count); |
36 | 32 |
37 private: | 33 private: |
38 DISALLOW_ALLOCATION(); | 34 DISALLOW_ALLOCATION(); |
39 DISALLOW_IMPLICIT_CONSTRUCTORS(Platform); | 35 DISALLOW_IMPLICIT_CONSTRUCTORS(Platform); |
40 }; | 36 }; |
41 | 37 |
42 #endif // BIN_PLATFORM_H_ | 38 #endif // BIN_PLATFORM_H_ |
OLD | NEW |