Changeset d119d613


Ignore:
Timestamp:
Aug 25, 2020, 3:18:37 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
ceb7db8
Parents:
5fe7322
Message:

Reorganized the exception and concurrency overlap.

Location:
libcfa/src
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    r5fe7322 rd119d613  
    5353
    5454thread_headers = concurrency/coroutine.hfa concurrency/thread.hfa concurrency/kernel.hfa \
    55                 concurrency/monitor.hfa concurrency/mutex.hfa
     55                concurrency/monitor.hfa concurrency/mutex.hfa concurrency/exception.hfa
    5656
    5757thread_libsrc = concurrency/CtxSwitch-@ARCHITECTURE@.S concurrency/alarm.cfa \
  • libcfa/src/concurrency/coroutine.cfa

    r5fe7322 rd119d613  
    215215                return cor;
    216216        }
    217 
    218         struct $coroutine * __cfactx_cor_active(void) {
    219                 return active_coroutine();
    220         }
    221217}
    222218
  • libcfa/src/concurrency/invoke.c

    r5fe7322 rd119d613  
    2929// Called from the kernel when starting a coroutine or task so must switch back to user mode.
    3030
    31 extern struct $coroutine * __cfactx_cor_active(void);
    3231extern struct $coroutine * __cfactx_cor_finish(void);
    3332extern void __cfactx_cor_leave ( struct $coroutine * );
     
    3635extern void disable_interrupts() OPTIONAL_THREAD;
    3736extern void enable_interrupts( __cfaabi_dbg_ctx_param );
    38 
    39 struct exception_context_t * this_exception_context() {
    40         return &__get_stack( __cfactx_cor_active() )->exception_context;
    41 }
    4237
    4338void __cfactx_invoke_coroutine(
  • libcfa/src/concurrency/invoke.h

    r5fe7322 rd119d613  
    9898        }
    9999
    100         struct exception_context_t * this_exception_context();
    101 
    102100        // struct which calls the monitor is accepting
    103101        struct __waitfor_mask_t {
  • libcfa/src/exception.c

    r5fe7322 rd119d613  
    209209                void * stop_param) {
    210210        // Verify actions follow the rules we expect.
    211         verify((actions & _UA_CLEANUP_PHASE) && (actions & _UA_FORCE_UNWIND));
    212         verify(!(actions & (_UA_SEARCH_PHASE | _UA_HANDLER_FRAME)));
     211        verify(actions & _UA_CLEANUP_PHASE);
     212        verify(actions & _UA_FORCE_UNWIND);
     213        verify(!(actions & _UA_SEARCH_PHASE));
     214        verify(!(actions & _UA_HANDLER_FRAME));
    213215
    214216        if ( actions & _UA_END_OF_STACK ) {
    215                 exit(1);
     217                abort();
    216218        } else {
    217219                return _URC_NO_REASON;
     
    219221}
    220222
    221 static struct _Unwind_Exception cancel_exception_storage;
     223__attribute__((weak)) _Unwind_Reason_Code
     224__cfaehm_cancellation_unwind( struct _Unwind_Exception * exception ) {
     225        return _Unwind_ForcedUnwind( exception, _Stop_Fn, (void*)0x22 );
     226}
    222227
    223228// Cancel the current stack, prefroming approprate clean-up and messaging.
    224229void __cfaehm_cancel_stack( exception_t * exception ) {
    225         // TODO: Detect current stack and pick a particular stop-function.
     230        __cfaehm_allocate_exception( exception );
     231
     232        struct exception_context_t * context = this_exception_context();
     233        struct __cfaehm_node * node = EXCEPT_TO_NODE(context->current_exception);
     234
     235        // Preform clean-up of any extra active exceptions.
     236        while ( node->next ) {
     237                struct __cfaehm_node * to_free = node->next;
     238                node->next = to_free->next;
     239                exception_t * except = NODE_TO_EXCEPT( to_free );
     240                except->virtual_table->free( except );
     241            free( to_free );
     242        }
     243
    226244        _Unwind_Reason_Code ret;
    227         ret = _Unwind_ForcedUnwind( &cancel_exception_storage, _Stop_Fn, (void*)0x22 );
     245        ret = __cfaehm_cancellation_unwind( &node->unwind_exception );
    228246        printf("UNWIND ERROR %d after force unwind\n", ret);
    229247        abort();
Note: See TracChangeset for help on using the changeset viewer.