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 "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 Loading... |
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) |
OLD | NEW |