| 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
| 7 | 7 |
| 8 #include "bin/platform.h" | 8 #include "bin/platform.h" |
| 9 #include "bin/log.h" | 9 #include "bin/log.h" |
| 10 #include "bin/socket.h" | 10 #include "bin/socket.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 return info.dwNumberOfProcessors; | 21 return info.dwNumberOfProcessors; |
| 22 } | 22 } |
| 23 | 23 |
| 24 | 24 |
| 25 const char* Platform::OperatingSystem() { | 25 const char* Platform::OperatingSystem() { |
| 26 return "windows"; | 26 return "windows"; |
| 27 } | 27 } |
| 28 | 28 |
| 29 | 29 |
| 30 bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) { | 30 bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) { |
| 31 static bool socket_initialized = false; | 31 if (!Socket::Initialize()) return false; |
| 32 if (!socket_initialized) { | |
| 33 // Initialize Socket for gethostname. | |
| 34 if (!Socket::Initialize()) return false; | |
| 35 socket_initialized = true; | |
| 36 } | |
| 37 return gethostname(buffer, buffer_length) == 0; | 32 return gethostname(buffer, buffer_length) == 0; |
| 38 } | 33 } |
| 39 | 34 |
| 40 | 35 |
| 41 char** Platform::Environment(intptr_t* count) { | 36 char** Platform::Environment(intptr_t* count) { |
| 42 wchar_t* strings = GetEnvironmentStringsW(); | 37 wchar_t* strings = GetEnvironmentStringsW(); |
| 43 if (strings == NULL) return NULL; | 38 if (strings == NULL) return NULL; |
| 44 wchar_t* tmp = strings; | 39 wchar_t* tmp = strings; |
| 45 intptr_t i = 0; | 40 intptr_t i = 0; |
| 46 while (*tmp != '\0') { | 41 while (*tmp != '\0') { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 return result; | 53 return result; |
| 59 } | 54 } |
| 60 | 55 |
| 61 | 56 |
| 62 void Platform::FreeEnvironment(char** env, int count) { | 57 void Platform::FreeEnvironment(char** env, int count) { |
| 63 for (int i = 0; i < count; i++) free(env[i]); | 58 for (int i = 0; i < count; i++) free(env[i]); |
| 64 delete[] env; | 59 delete[] env; |
| 65 } | 60 } |
| 66 | 61 |
| 67 #endif // defined(TARGET_OS_WINDOWS) | 62 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |