| 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" // NOLINT | 5 #include "platform/globals.h" // NOLINT |
| 6 #if defined(TARGET_OS_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 7 | 7 |
| 8 #include "vm/os_thread.h" | 8 #include "vm/os_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 #include "platform/utils.h" |
| 14 | 15 |
| 15 namespace dart { | 16 namespace dart { |
| 16 | 17 |
| 17 #define VALIDATE_PTHREAD_RESULT(result) \ | 18 #define VALIDATE_PTHREAD_RESULT(result) \ |
| 18 if (result != 0) { \ | 19 if (result != 0) { \ |
| 19 const int kBufferSize = 1024; \ | 20 const int kBufferSize = 1024; \ |
| 20 char error_message[kBufferSize]; \ | 21 char error_message[kBufferSize]; \ |
| 21 strerror_r(result, error_message, kBufferSize); \ | 22 Utils::StrError(result, error_message, kBufferSize); \ |
| 22 FATAL2("pthread error: %d (%s)", result, error_message); \ | 23 FATAL2("pthread error: %d (%s)", result, error_message); \ |
| 23 } | 24 } |
| 24 | 25 |
| 25 | 26 |
| 26 #if defined(DEBUG) | 27 #if defined(DEBUG) |
| 27 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result) | 28 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result) |
| 28 #else | 29 #else |
| 29 // NOTE: This (currently) expands to a no-op. | 30 // NOTE: This (currently) expands to a no-op. |
| 30 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0) | 31 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0) |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 | 34 |
| 34 #ifdef DEBUG | 35 #ifdef DEBUG |
| 35 #define RETURN_ON_PTHREAD_FAILURE(result) \ | 36 #define RETURN_ON_PTHREAD_FAILURE(result) \ |
| 36 if (result != 0) { \ | 37 if (result != 0) { \ |
| 37 const int kBufferSize = 1024; \ | 38 const int kBufferSize = 1024; \ |
| 38 char error_message[kBufferSize]; \ | 39 char error_message[kBufferSize]; \ |
| 39 strerror_r(result, error_message, kBufferSize); \ | 40 Utils::StrError(result, error_message, kBufferSize); \ |
| 40 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ | 41 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ |
| 41 __FILE__, __LINE__, result, error_message); \ | 42 __FILE__, __LINE__, result, error_message); \ |
| 42 return result; \ | 43 return result; \ |
| 43 } | 44 } |
| 44 #else | 45 #else |
| 45 #define RETURN_ON_PTHREAD_FAILURE(result) \ | 46 #define RETURN_ON_PTHREAD_FAILURE(result) \ |
| 46 if (result != 0) return result; | 47 if (result != 0) return result; |
| 47 #endif | 48 #endif |
| 48 | 49 |
| 49 | 50 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 void Monitor::NotifyAll() { | 396 void Monitor::NotifyAll() { |
| 396 // When running with assertions enabled we track the owner. | 397 // When running with assertions enabled we track the owner. |
| 397 ASSERT(IsOwnedByCurrentThread()); | 398 ASSERT(IsOwnedByCurrentThread()); |
| 398 int result = pthread_cond_broadcast(data_.cond()); | 399 int result = pthread_cond_broadcast(data_.cond()); |
| 399 VALIDATE_PTHREAD_RESULT(result); | 400 VALIDATE_PTHREAD_RESULT(result); |
| 400 } | 401 } |
| 401 | 402 |
| 402 } // namespace dart | 403 } // namespace dart |
| 403 | 404 |
| 404 #endif // defined(TARGET_OS_ANDROID) | 405 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |