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

Side by Side Diff: runtime/platform/thread_linux.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/platform/thread_android.cc ('k') | runtime/platform/thread_macos.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_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "platform/thread.h" 8 #include "platform/thread.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
11 #include <sys/time.h> // NOLINT 11 #include <sys/time.h> // NOLINT
12 12
13 #include "platform/assert.h" 13 #include "platform/assert.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 #define VALIDATE_PTHREAD_RESULT(result) \ 17 #define VALIDATE_PTHREAD_RESULT(result) \
18 if (result != 0) { \ 18 if (result != 0) { \
19 FATAL2("pthread error: %d (%s)", result, strerror(result)); \ 19 const int kBufferSize = 1024; \
20 char error_buf[kBufferSize]; \
21 FATAL2("pthread error: %d (%s)", result, \
22 strerror_r(result, error_buf, kBufferSize)); \
20 } 23 }
21 24
22 25
23 #ifdef DEBUG 26 #ifdef DEBUG
24 #define RETURN_ON_PTHREAD_FAILURE(result) \ 27 #define RETURN_ON_PTHREAD_FAILURE(result) \
25 if (result != 0) { \ 28 if (result != 0) { \
29 const int kBufferSize = 1024; \
30 char error_buf[kBufferSize]; \
26 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ 31 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \
27 __FILE__, __LINE__, result, strerror(result)); \ 32 __FILE__, __LINE__, result, \
33 strerror_r(result, error_buf, kBufferSize)); \
28 return result; \ 34 return result; \
29 } 35 }
30 #else 36 #else
31 #define RETURN_ON_PTHREAD_FAILURE(result) \ 37 #define RETURN_ON_PTHREAD_FAILURE(result) \
32 if (result != 0) return result; 38 if (result != 0) return result;
33 #endif 39 #endif
34 40
35 41
36 static void ComputeTimeSpec(struct timespec* ts, int64_t millis) { 42 static void ComputeTimeSpec(struct timespec* ts, int64_t millis) {
37 int64_t secs = millis / kMillisecondsPerSecond; 43 int64_t secs = millis / kMillisecondsPerSecond;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 283
278 void Monitor::NotifyAll() { 284 void Monitor::NotifyAll() {
279 // TODO(iposva): Do we need to track lock owners? 285 // TODO(iposva): Do we need to track lock owners?
280 int result = pthread_cond_broadcast(data_.cond()); 286 int result = pthread_cond_broadcast(data_.cond());
281 VALIDATE_PTHREAD_RESULT(result); 287 VALIDATE_PTHREAD_RESULT(result);
282 } 288 }
283 289
284 } // namespace dart 290 } // namespace dart
285 291
286 #endif // defined(TARGET_OS_LINUX) 292 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/platform/thread_android.cc ('k') | runtime/platform/thread_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698