Ignore:
Timestamp:
Jun 16, 2017, 9:07:21 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
42b0d73
Parents:
667c7da
Message:

Added verify macro for asserts only present in debug

Location:
src/libcfa/concurrency
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/alarm.c

    r667c7da r4aa2fb2  
    104104
    105105static inline void remove_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t it ) {
    106         assert( it );
    107         assert( (*it)->next == n );
     106        verify( it );
     107        verify( (*it)->next == n );
    108108
    109109        (*it)->next = n->next;
  • src/libcfa/concurrency/coroutine

    r667c7da r4aa2fb2  
    7171// Suspend implementation inlined for performance
    7272static inline void suspend() {
    73       coroutine_desc * src = this_coroutine();          // optimization
     73        coroutine_desc * src = this_coroutine();                // optimization
    7474
    7575        assertf( src->last != 0,
     
    9191        coroutine_desc * dst = get_coroutine(cor);
    9292
    93       if( unlikely(!dst->stack.base) ) {
     93        if( unlikely(!dst->stack.base) ) {
    9494                create_stack(&dst->stack, dst->stack.size);
    9595                CtxStart(cor, CtxInvokeCoroutine);
    9696        }
    9797
    98       // not resuming self ?
     98        // not resuming self ?
    9999        if ( src != dst ) {
    100100                assertf( dst->state != Halted ,
     
    103103                        src->name, src, dst->name, dst );
    104104
    105             // set last resumer
     105                // set last resumer
    106106                dst->last = src;
    107107        } // if
    108108
    109       // always done for performance testing
     109        // always done for performance testing
    110110        CoroutineCtxSwitch( src, dst );
    111111}
     
    114114        coroutine_desc * src = this_coroutine();                // optimization
    115115
    116       // not resuming self ?
     116        // not resuming self ?
    117117        if ( src != dst ) {
    118118                assertf( dst->state != Halted ,
     
    121121                        src->name, src, dst->name, dst );
    122122
    123             // set last resumer
     123                // set last resumer
    124124                dst->last = src;
    125125        } // if
    126126
    127       // always done for performance testing
     127        // always done for performance testing
    128128        CoroutineCtxSwitch( src, dst );
    129129}
  • src/libcfa/concurrency/kernel.c

    r667c7da r4aa2fb2  
    311311        // appropriate stack.
    312312        proc_cor_storage.__cor.state = Active;
    313       main( &proc_cor_storage );
    314       proc_cor_storage.__cor.state = Halted;
     313        main( &proc_cor_storage );
     314        proc_cor_storage.__cor.state = Halted;
    315315
    316316        // Main routine of the core returned, the core is now fully terminated
     
    333333        if( !thrd ) return;
    334334
    335         assertf( thrd->next == NULL, "Expected null got %p", thrd->next );
     335        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
    336336       
    337337        lock( &systemProcessor->proc.cltr->lock );
     
    577577
    578578void append( __thread_queue_t * this, thread_desc * t ) {
    579         assert(this->tail != NULL);
     579        verify(this->tail != NULL);
    580580        *this->tail = t;
    581581        this->tail = &t->next;
     
    599599
    600600void push( __condition_stack_t * this, __condition_criterion_t * t ) {
    601         assert( !t->next );
     601        verify( !t->next );
    602602        t->next = this->top;
    603603        this->top = t;
  • src/libcfa/concurrency/kernel_private.h

    r667c7da r4aa2fb2  
    2222
    2323#include "alarm.h"
     24
     25#include "libhdr.h"
    2426
    2527//-----------------------------------------------------------------------------
     
    6668
    6769static inline void enable_interrupts_noRF() {
    68         unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );
    69         assert( prev != (unsigned short) 0 );
     70        __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );
     71        verify( prev != (unsigned short) 0 );
    7072}
    7173
    7274static inline void enable_interrupts() {
    73         unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );
    74         assert( prev != (unsigned short) 0 );
     75        __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );
     76        verify( prev != (unsigned short) 0 );
    7577        if( prev == 1 && this_processor->pending_preemption ) {
    7678                ScheduleInternal( this_processor->current_thread );
  • src/libcfa/concurrency/monitor

    r667c7da r4aa2fb2  
    2626static inline void ?{}(monitor_desc * this) {
    2727        this->owner = NULL;
    28       this->stack_owner = NULL;
     28        this->stack_owner = NULL;
    2929        this->recursion = 0;
    3030}
     
    3333        monitor_desc ** m;
    3434        int count;
    35       monitor_desc ** prev_mntrs;
    36       unsigned short  prev_count;
     35        monitor_desc ** prev_mntrs;
     36        unsigned short  prev_count;
    3737};
    3838
  • src/libcfa/concurrency/monitor.c

    r667c7da r4aa2fb2  
    5656                else if( this->owner == thrd) {
    5757                        //We already have the monitor, just not how many times we took it
    58                         assert( this->recursion > 0 );
     58                        verify( this->recursion > 0 );
    5959                        this->recursion += 1;
    6060                }
     
    7878                lock( &this->lock );
    7979
    80                 thread_desc * thrd = this_thread();
    81 
    8280                LIB_DEBUG_PRINT_SAFE("%p Leaving %p (o: %p, r: %i)\n", thrd, this, this->owner, this->recursion);
    83                 assertf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i)", thrd, this->owner, this->recursion );
     81                verifyf( this_thread() == this->owner, "Expected owner to be %p, got %p (r: %i)", this_thread(), this->owner, this->recursion );
    8482
    8583                //Leaving a recursion level, decrement the counter
     
    167165        //Check that everything is as expected
    168166        assertf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );
    169         assertf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
    170         assertf( this->monitor_count < 32u, "Excessive monitor count (%i)", this->monitor_count );
     167        verifyf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
     168        verifyf( this->monitor_count < 32u, "Excessive monitor count (%i)", this->monitor_count );
    171169
    172170        unsigned short count = this->monitor_count;
     
    229227
    230228        //Check that everything is as expected
    231         assert( this->monitors );
    232         assert( this->monitor_count != 0 );
     229        verify( this->monitors );
     230        verify( this->monitor_count != 0 );
    233231
    234232        unsigned short count = this->monitor_count;
     
    278276
    279277        //Check that everything is as expected
    280         assertf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );
    281         assertf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
     278        verifyf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );
     279        verifyf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
    282280
    283281        unsigned short count = this->monitor_count;
     
    327325
    328326uintptr_t front( condition * this ) {
    329         LIB_DEBUG_DO(
    330                 if( is_empty(this) ) {
    331                         abortf( "Attempt to access user data on an empty condition.\n"
    332                     "Possible cause is not checking if the condition is empty before reading stored data." );
    333                 }
     327        verifyf( !is_empty(this),
     328                "Attempt to access user data on an empty condition.\n"
     329                "Possible cause is not checking if the condition is empty before reading stored data."
    334330        );
    335331        return this->blocked.head->user_info;
     
    491487
    492488void append( __condition_blocked_queue_t * this, __condition_node_t * c ) {
    493         assert(this->tail != NULL);
     489        verify(this->tail != NULL);
    494490        *this->tail = c;
    495491        this->tail = &c->next;
Note: See TracChangeset for help on using the changeset viewer.