Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: runtime/bin/utils_macos.cc

Issue 22634003: Replaced strerror() calls with threadsafe strerror_r() (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/utils_linux.cc ('k') | runtime/platform/thread_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MACOS) 6 #if defined(TARGET_OS_MACOS)
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_message[kBufferSize];
24 strerror_r(errno, error_message, kBufferSize);
25 SetMessage(error_message);
23 } 26 }
24 27
25 28
26 void OSError::SetCodeAndMessage(SubSystem sub_system, int code) { 29 void OSError::SetCodeAndMessage(SubSystem sub_system, int code) {
27 set_sub_system(sub_system); 30 set_sub_system(sub_system);
28 set_code(code); 31 set_code(code);
29 if (sub_system == kSystem) { 32 if (sub_system == kSystem) {
30 SetMessage(strerror(code)); 33 const int kBufferSize = 1024;
34 char error_message[kBufferSize];
35 strerror_r(code, error_message, kBufferSize);
36 SetMessage(error_message);
31 } else if (sub_system == kGetAddressInfo) { 37 } else if (sub_system == kGetAddressInfo) {
32 SetMessage(gai_strerror(code)); 38 SetMessage(gai_strerror(code));
33 } else { 39 } else {
34 UNREACHABLE(); 40 UNREACHABLE();
35 } 41 }
36 } 42 }
37 43
38 const char* StringUtils::ConsoleStringToUtf8(const char* str) { 44 const char* StringUtils::ConsoleStringToUtf8(const char* str) {
39 return str; 45 return str;
40 } 46 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 98 }
93 99
94 void TimerUtils::Sleep(int64_t millis) { 100 void TimerUtils::Sleep(int64_t millis) {
95 usleep(millis * 1000); 101 usleep(millis * 1000);
96 } 102 }
97 103
98 } // namespace bin 104 } // namespace bin
99 } // namespace dart 105 } // namespace dart
100 106
101 #endif // defined(TARGET_OS_MACOS) 107 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/utils_linux.cc ('k') | runtime/platform/thread_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698