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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
7 | 7 |
8 #include <errno.h> // NOLINT | 8 #include <errno.h> // NOLINT |
9 #include <netdb.h> // NOLINT | 9 #include <netdb.h> // NOLINT |
10 #include <sys/time.h> // NOLINT | 10 #include <sys/time.h> // NOLINT |
11 | 11 |
12 #include "bin/utils.h" | 12 #include "bin/utils.h" |
13 #include "platform/assert.h" | 13 #include "platform/assert.h" |
14 | 14 |
15 | 15 |
16 namespace dart { | 16 namespace dart { |
17 namespace bin { | 17 namespace bin { |
18 | 18 |
19 OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) { | 19 OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) { |
20 set_sub_system(kSystem); | 20 set_sub_system(kSystem); |
21 set_code(errno); | 21 set_code(errno); |
22 SetMessage(strerror(errno)); | 22 const int kBufferSize = 1024; |
| 23 char error_buf[kBufferSize]; |
| 24 SetMessage(strerror_r(errno, error_buf, kBufferSize)); |
23 } | 25 } |
24 | 26 |
25 | 27 |
26 void OSError::SetCodeAndMessage(SubSystem sub_system, int code) { | 28 void OSError::SetCodeAndMessage(SubSystem sub_system, int code) { |
27 set_sub_system(sub_system); | 29 set_sub_system(sub_system); |
28 set_code(code); | 30 set_code(code); |
29 if (sub_system == kSystem) { | 31 if (sub_system == kSystem) { |
30 SetMessage(strerror(code)); | 32 const int kBufferSize = 1024; |
| 33 char error_buf[kBufferSize]; |
| 34 SetMessage(strerror_r(code, error_buf, kBufferSize)); |
31 } else if (sub_system == kGetAddressInfo) { | 35 } else if (sub_system == kGetAddressInfo) { |
32 SetMessage(gai_strerror(code)); | 36 SetMessage(gai_strerror(code)); |
33 } else { | 37 } else { |
34 UNREACHABLE(); | 38 UNREACHABLE(); |
35 } | 39 } |
36 } | 40 } |
37 | 41 |
38 const char* StringUtils::ConsoleStringToUtf8(const char* str) { | 42 const char* StringUtils::ConsoleStringToUtf8(const char* str) { |
39 return str; | 43 return str; |
40 } | 44 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 96 } |
93 | 97 |
94 void TimerUtils::Sleep(int64_t millis) { | 98 void TimerUtils::Sleep(int64_t millis) { |
95 usleep(millis * 1000); | 99 usleep(millis * 1000); |
96 } | 100 } |
97 | 101 |
98 } // namespace bin | 102 } // namespace bin |
99 } // namespace dart | 103 } // namespace dart |
100 | 104 |
101 #endif // defined(TARGET_OS_LINUX) | 105 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |