Differences From Artifact [3255d28641]:
- File src/runtime/exception.m — part of check-in [8f271bed22] at 2020-12-20 03:06:55 on branch trunk — Let OF_ENSURE use OBJC_ERROR in runtime (user: js, size: 19870) [annotate] [blame] [check-ins using] [more...]
To Artifact [50eac6751c]:
- File
src/runtime/exception.m
— part of check-in
[5b37fbeb82]
at
2020-12-20 21:26:08
on branch trunk
— Return error instead of using errno for threading
errno is problematic for Amiga libraries and is also not thread-safe on
some systems, even though it should. (user: js, size: 19890) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
244 245 246 247 248 249 250 | static objc_uncaught_exception_handler_t uncaughtExceptionHandler; static struct objc_exception emergencyExceptions[NUM_EMERGENCY_EXCEPTIONS]; #ifdef OF_HAVE_THREADS static of_spinlock_t emergencyExceptionsSpinlock; OF_CONSTRUCTOR() { | | | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | static objc_uncaught_exception_handler_t uncaughtExceptionHandler; static struct objc_exception emergencyExceptions[NUM_EMERGENCY_EXCEPTIONS]; #ifdef OF_HAVE_THREADS static of_spinlock_t emergencyExceptionsSpinlock; OF_CONSTRUCTOR() { if (of_spinlock_new(&emergencyExceptionsSpinlock) != 0) OBJC_ERROR("Cannot create spinlock!"); } #endif static uint64_t readULEB128(const uint8_t **ptr) { |
︙ | ︙ | |||
703 704 705 706 707 708 709 | } static void emergencyExceptionCleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { #ifdef OF_HAVE_THREADS | | | | | | 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | } static void emergencyExceptionCleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { #ifdef OF_HAVE_THREADS if (of_spinlock_lock(&emergencyExceptionsSpinlock) != 0) OBJC_ERROR("Cannot lock spinlock!"); #endif ex->class = 0; #ifdef OF_HAVE_THREADS if (of_spinlock_unlock(&emergencyExceptionsSpinlock) != 0) OBJC_ERROR("Cannot unlock spinlock!"); #endif } void objc_exception_throw(id object) { struct objc_exception *e = calloc(1, sizeof(*e)); bool emergency = false; if (e == NULL) { #ifdef OF_HAVE_THREADS if (of_spinlock_lock(&emergencyExceptionsSpinlock) != 0) OBJC_ERROR("Cannot lock spinlock!"); #endif for (uint_fast8_t i = 0; i < NUM_EMERGENCY_EXCEPTIONS; i++) { if (emergencyExceptions[i].exception.class == 0) { e = &emergencyExceptions[i]; e->exception.class = GNUCOBJC_EXCEPTION_CLASS; emergency = true; break; } } #ifdef OF_HAVE_THREADS if (of_spinlock_unlock(&emergencyExceptionsSpinlock) != 0) OBJC_ERROR("Cannot lock spinlock!"); #endif } if (e == NULL) OBJC_ERROR("Not enough memory to allocate exception!"); |
︙ | ︙ |