1013
1014 siglongjmp(_jmpbuf, 1);
1015 }
1016
1017 void os::WatcherThreadCrashProtection::check_crash_protection(int sig,
1018 Thread* thread) {
1019
1020 if (thread != NULL &&
1021 thread->is_Watcher_thread() &&
1022 WatcherThread::watcher_thread()->has_crash_protection()) {
1023
1024 if (sig == SIGSEGV || sig == SIGBUS) {
1025 WatcherThread::watcher_thread()->crash_protection()->restore();
1026 }
1027 }
1028 }
1029
1030 #define check_with_errno(check_type, cond, msg) \
1031 do { \
1032 int err = errno; \
1033 check_type(cond, err_msg("%s; error='%s' (errno=%d)", msg, strerror(err), err)); \
1034 } while (false)
1035
1036 #define assert_with_errno(cond, msg) check_with_errno(assert, cond, msg)
1037 #define guarantee_with_errno(cond, msg) check_with_errno(guarantee, cond, msg)
1038
1039 // POSIX unamed semaphores are not supported on OS X.
1040 #ifndef __APPLE__
1041
1042 PosixSemaphore::PosixSemaphore(uint value) {
1043 int ret = sem_init(&_semaphore, 0, value);
1044
1045 guarantee_with_errno(ret == 0, "Failed to initialize semaphore");
1046 }
1047
1048 PosixSemaphore::~PosixSemaphore() {
1049 sem_destroy(&_semaphore);
1050 }
1051
1052 void PosixSemaphore::signal(uint count) {
1053 for (uint i = 0; i < count; i++) {
|
1013
1014 siglongjmp(_jmpbuf, 1);
1015 }
1016
1017 void os::WatcherThreadCrashProtection::check_crash_protection(int sig,
1018 Thread* thread) {
1019
1020 if (thread != NULL &&
1021 thread->is_Watcher_thread() &&
1022 WatcherThread::watcher_thread()->has_crash_protection()) {
1023
1024 if (sig == SIGSEGV || sig == SIGBUS) {
1025 WatcherThread::watcher_thread()->crash_protection()->restore();
1026 }
1027 }
1028 }
1029
1030 #define check_with_errno(check_type, cond, msg) \
1031 do { \
1032 int err = errno; \
1033 check_type(cond, "%s; error='%s' (errno=%d)", msg, strerror(err), err); \
1034 } while (false)
1035
1036 #define assert_with_errno(cond, msg) check_with_errno(assert, cond, msg)
1037 #define guarantee_with_errno(cond, msg) check_with_errno(guarantee, cond, msg)
1038
1039 // POSIX unamed semaphores are not supported on OS X.
1040 #ifndef __APPLE__
1041
1042 PosixSemaphore::PosixSemaphore(uint value) {
1043 int ret = sem_init(&_semaphore, 0, value);
1044
1045 guarantee_with_errno(ret == 0, "Failed to initialize semaphore");
1046 }
1047
1048 PosixSemaphore::~PosixSemaphore() {
1049 sem_destroy(&_semaphore);
1050 }
1051
1052 void PosixSemaphore::signal(uint count) {
1053 for (uint i = 0; i < count; i++) {
|