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 "bin/thread.h" | 8 #include "bin/thread.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
11 #include <sys/resource.h> // NOLINT | 11 #include <sys/resource.h> // NOLINT |
12 #include <sys/time.h> // NOLINT | 12 #include <sys/time.h> // NOLINT |
13 | 13 |
14 #include "platform/assert.h" | 14 #include "platform/assert.h" |
| 15 #include "platform/utils.h" |
15 | 16 |
16 namespace dart { | 17 namespace dart { |
17 namespace bin { | 18 namespace bin { |
18 | 19 |
19 #define VALIDATE_PTHREAD_RESULT(result) \ | 20 #define VALIDATE_PTHREAD_RESULT(result) \ |
20 if (result != 0) { \ | 21 if (result != 0) { \ |
21 const int kBufferSize = 1024; \ | 22 const int kBufferSize = 1024; \ |
22 char error_buf[kBufferSize]; \ | 23 char error_buf[kBufferSize]; \ |
23 FATAL2("pthread error: %d (%s)", result, \ | 24 FATAL2("pthread error: %d (%s)", result, \ |
24 strerror_r(result, error_buf, kBufferSize)); \ | 25 Utils::StrError(result, error_buf, kBufferSize)); \ |
25 } | 26 } |
26 | 27 |
27 | 28 |
28 #ifdef DEBUG | 29 #ifdef DEBUG |
29 #define RETURN_ON_PTHREAD_FAILURE(result) \ | 30 #define RETURN_ON_PTHREAD_FAILURE(result) \ |
30 if (result != 0) { \ | 31 if (result != 0) { \ |
31 const int kBufferSize = 1024; \ | 32 const int kBufferSize = 1024; \ |
32 char error_buf[kBufferSize]; \ | 33 char error_buf[kBufferSize]; \ |
33 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ | 34 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ |
34 __FILE__, __LINE__, result, \ | 35 __FILE__, __LINE__, result, \ |
35 strerror_r(result, error_buf, kBufferSize)); \ | 36 Utils::StrError(result, error_buf, kBufferSize)); \ |
36 return result; \ | 37 return result; \ |
37 } | 38 } |
38 #else | 39 #else |
39 #define RETURN_ON_PTHREAD_FAILURE(result) \ | 40 #define RETURN_ON_PTHREAD_FAILURE(result) \ |
40 if (result != 0) return result; | 41 if (result != 0) return result; |
41 #endif | 42 #endif |
42 | 43 |
43 | 44 |
44 static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) { | 45 static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) { |
45 int64_t secs = micros / kMicrosecondsPerSecond; | 46 int64_t secs = micros / kMicrosecondsPerSecond; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 void Monitor::NotifyAll() { | 329 void Monitor::NotifyAll() { |
329 // TODO(iposva): Do we need to track lock owners? | 330 // TODO(iposva): Do we need to track lock owners? |
330 int result = pthread_cond_broadcast(data_.cond()); | 331 int result = pthread_cond_broadcast(data_.cond()); |
331 VALIDATE_PTHREAD_RESULT(result); | 332 VALIDATE_PTHREAD_RESULT(result); |
332 } | 333 } |
333 | 334 |
334 } // namespace bin | 335 } // namespace bin |
335 } // namespace dart | 336 } // namespace dart |
336 | 337 |
337 #endif // defined(TARGET_OS_LINUX) | 338 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |