| 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 "bin/platform.h" | 5 #include "bin/platform.h" |
| 6 #include "bin/log.h" |
| 6 #include "bin/socket.h" | 7 #include "bin/socket.h" |
| 7 | 8 |
| 8 bool Platform::Initialize() { | 9 bool Platform::Initialize() { |
| 9 // Nothing to do on Windows. | 10 // Nothing to do on Windows. |
| 10 return true; | 11 return true; |
| 11 } | 12 } |
| 12 | 13 |
| 13 | 14 |
| 14 int Platform::NumberOfProcessors() { | 15 int Platform::NumberOfProcessors() { |
| 15 SYSTEM_INFO info; | 16 SYSTEM_INFO info; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 DWORD message_size = | 67 DWORD message_size = |
| 67 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | 68 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 68 NULL, | 69 NULL, |
| 69 error_code, | 70 error_code, |
| 70 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | 71 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
| 71 error, | 72 error, |
| 72 kBufferSize, | 73 kBufferSize, |
| 73 NULL); | 74 NULL); |
| 74 if (message_size == 0) { | 75 if (message_size == 0) { |
| 75 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { | 76 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { |
| 76 fprintf(stderr, "FormatMessage failed %d\n", GetLastError()); | 77 Log::PrintErr("FormatMessage failed %d\n", GetLastError()); |
| 77 } | 78 } |
| 78 snprintf(error, kBufferSize, "OS Error %d", error_code); | 79 snprintf(error, kBufferSize, "OS Error %d", error_code); |
| 79 } | 80 } |
| 80 // Strip out \r\n at the end of the generated message and ensure | 81 // Strip out \r\n at the end of the generated message and ensure |
| 81 // null termination. | 82 // null termination. |
| 82 if (message_size > 2 && | 83 if (message_size > 2 && |
| 83 error[message_size - 2] == '\r' && | 84 error[message_size - 2] == '\r' && |
| 84 error[message_size - 1] == '\n') { | 85 error[message_size - 1] == '\n') { |
| 85 error[message_size - 2] = '\0'; | 86 error[message_size - 2] = '\0'; |
| 86 } else { | 87 } else { |
| 87 error[kBufferSize - 1] = '\0'; | 88 error[kBufferSize - 1] = '\0'; |
| 88 } | 89 } |
| 89 return error; | 90 return error; |
| 90 } | 91 } |
| OLD | NEW |