| 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_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 7 | 7 |
| 8 #include "vm/os_thread.h" | 8 #include "vm/os_thread.h" |
| 9 | 9 |
| 10 #include <sys/errno.h> // NOLINT | 10 #include <sys/errno.h> // NOLINT |
| 11 #include <sys/types.h> // NOLINT | 11 #include <sys/types.h> // NOLINT |
| 12 #include <sys/sysctl.h> // NOLINT | 12 #include <sys/sysctl.h> // NOLINT |
| 13 #include <mach/mach_init.h> // NOLINT | 13 #include <mach/mach_init.h> // NOLINT |
| 14 #include <mach/mach_host.h> // NOLINT | 14 #include <mach/mach_host.h> // NOLINT |
| 15 #include <mach/mach_port.h> // NOLINT | 15 #include <mach/mach_port.h> // NOLINT |
| 16 #include <mach/mach_traps.h> // NOLINT | 16 #include <mach/mach_traps.h> // NOLINT |
| 17 #include <mach/task_info.h> // NOLINT | 17 #include <mach/task_info.h> // NOLINT |
| 18 #include <mach/thread_info.h> // NOLINT | 18 #include <mach/thread_info.h> // NOLINT |
| 19 #include <mach/thread_act.h> // NOLINT | 19 #include <mach/thread_act.h> // NOLINT |
| 20 | 20 |
| 21 #include "platform/assert.h" | 21 #include "platform/assert.h" |
| 22 #include "platform/utils.h" |
| 22 | 23 |
| 23 namespace dart { | 24 namespace dart { |
| 24 | 25 |
| 25 #define VALIDATE_PTHREAD_RESULT(result) \ | 26 #define VALIDATE_PTHREAD_RESULT(result) \ |
| 26 if (result != 0) { \ | 27 if (result != 0) { \ |
| 27 const int kBufferSize = 1024; \ | 28 const int kBufferSize = 1024; \ |
| 28 char error_message[kBufferSize]; \ | 29 char error_message[kBufferSize]; \ |
| 29 strerror_r(result, error_message, kBufferSize); \ | 30 Utils::StrError(result, error_message, kBufferSize); \ |
| 30 FATAL2("pthread error: %d (%s)", result, error_message); \ | 31 FATAL2("pthread error: %d (%s)", result, error_message); \ |
| 31 } | 32 } |
| 32 | 33 |
| 33 | 34 |
| 34 #if defined(DEBUG) | 35 #if defined(DEBUG) |
| 35 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result) | 36 #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result) |
| 36 #else | 37 #else |
| 37 // NOTE: This (currently) expands to a no-op. | 38 // NOTE: This (currently) expands to a no-op. |
| 38 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0) | 39 #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0) |
| 39 #endif | 40 #endif |
| 40 | 41 |
| 41 | 42 |
| 42 #ifdef DEBUG | 43 #ifdef DEBUG |
| 43 #define RETURN_ON_PTHREAD_FAILURE(result) \ | 44 #define RETURN_ON_PTHREAD_FAILURE(result) \ |
| 44 if (result != 0) { \ | 45 if (result != 0) { \ |
| 45 const int kBufferSize = 1024; \ | 46 const int kBufferSize = 1024; \ |
| 46 char error_message[kBufferSize]; \ | 47 char error_message[kBufferSize]; \ |
| 47 strerror_r(result, error_message, kBufferSize); \ | 48 Utils::StrError(result, error_message, kBufferSize); \ |
| 48 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ | 49 fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \ |
| 49 __FILE__, __LINE__, result, error_message); \ | 50 __FILE__, __LINE__, result, error_message); \ |
| 50 return result; \ | 51 return result; \ |
| 51 } | 52 } |
| 52 #else | 53 #else |
| 53 #define RETURN_ON_PTHREAD_FAILURE(result) \ | 54 #define RETURN_ON_PTHREAD_FAILURE(result) \ |
| 54 if (result != 0) return result; | 55 if (result != 0) return result; |
| 55 #endif | 56 #endif |
| 56 | 57 |
| 57 | 58 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 void Monitor::NotifyAll() { | 417 void Monitor::NotifyAll() { |
| 417 // When running with assertions enabled we track the owner. | 418 // When running with assertions enabled we track the owner. |
| 418 ASSERT(IsOwnedByCurrentThread()); | 419 ASSERT(IsOwnedByCurrentThread()); |
| 419 int result = pthread_cond_broadcast(data_.cond()); | 420 int result = pthread_cond_broadcast(data_.cond()); |
| 420 VALIDATE_PTHREAD_RESULT(result); | 421 VALIDATE_PTHREAD_RESULT(result); |
| 421 } | 422 } |
| 422 | 423 |
| 423 } // namespace dart | 424 } // namespace dart |
| 424 | 425 |
| 425 #endif // defined(TARGET_OS_MACOS) | 426 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |