Changeset 4aa2fb2 for src/libcfa
- Timestamp:
- Jun 16, 2017, 9:07:21 PM (7 years ago)
- 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
- Location:
- src/libcfa
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/alarm.c
r667c7da r4aa2fb2 104 104 105 105 static 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 ); 108 108 109 109 (*it)->next = n->next; -
src/libcfa/concurrency/coroutine
r667c7da r4aa2fb2 71 71 // Suspend implementation inlined for performance 72 72 static inline void suspend() { 73 73 coroutine_desc * src = this_coroutine(); // optimization 74 74 75 75 assertf( src->last != 0, … … 91 91 coroutine_desc * dst = get_coroutine(cor); 92 92 93 93 if( unlikely(!dst->stack.base) ) { 94 94 create_stack(&dst->stack, dst->stack.size); 95 95 CtxStart(cor, CtxInvokeCoroutine); 96 96 } 97 97 98 98 // not resuming self ? 99 99 if ( src != dst ) { 100 100 assertf( dst->state != Halted , … … 103 103 src->name, src, dst->name, dst ); 104 104 105 105 // set last resumer 106 106 dst->last = src; 107 107 } // if 108 108 109 109 // always done for performance testing 110 110 CoroutineCtxSwitch( src, dst ); 111 111 } … … 114 114 coroutine_desc * src = this_coroutine(); // optimization 115 115 116 116 // not resuming self ? 117 117 if ( src != dst ) { 118 118 assertf( dst->state != Halted , … … 121 121 src->name, src, dst->name, dst ); 122 122 123 123 // set last resumer 124 124 dst->last = src; 125 125 } // if 126 126 127 127 // always done for performance testing 128 128 CoroutineCtxSwitch( src, dst ); 129 129 } -
src/libcfa/concurrency/kernel.c
r667c7da r4aa2fb2 311 311 // appropriate stack. 312 312 proc_cor_storage.__cor.state = Active; 313 314 313 main( &proc_cor_storage ); 314 proc_cor_storage.__cor.state = Halted; 315 315 316 316 // Main routine of the core returned, the core is now fully terminated … … 333 333 if( !thrd ) return; 334 334 335 assertf( thrd->next == NULL, "Expected null got %p", thrd->next );335 verifyf( thrd->next == NULL, "Expected null got %p", thrd->next ); 336 336 337 337 lock( &systemProcessor->proc.cltr->lock ); … … 577 577 578 578 void append( __thread_queue_t * this, thread_desc * t ) { 579 assert(this->tail != NULL);579 verify(this->tail != NULL); 580 580 *this->tail = t; 581 581 this->tail = &t->next; … … 599 599 600 600 void push( __condition_stack_t * this, __condition_criterion_t * t ) { 601 assert( !t->next );601 verify( !t->next ); 602 602 t->next = this->top; 603 603 this->top = t; -
src/libcfa/concurrency/kernel_private.h
r667c7da r4aa2fb2 22 22 23 23 #include "alarm.h" 24 25 #include "libhdr.h" 24 26 25 27 //----------------------------------------------------------------------------- … … 66 68 67 69 static 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 ); 70 72 } 71 73 72 74 static 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 ); 75 77 if( prev == 1 && this_processor->pending_preemption ) { 76 78 ScheduleInternal( this_processor->current_thread ); -
src/libcfa/concurrency/monitor
r667c7da r4aa2fb2 26 26 static inline void ?{}(monitor_desc * this) { 27 27 this->owner = NULL; 28 28 this->stack_owner = NULL; 29 29 this->recursion = 0; 30 30 } … … 33 33 monitor_desc ** m; 34 34 int count; 35 36 35 monitor_desc ** prev_mntrs; 36 unsigned short prev_count; 37 37 }; 38 38 -
src/libcfa/concurrency/monitor.c
r667c7da r4aa2fb2 56 56 else if( this->owner == thrd) { 57 57 //We already have the monitor, just not how many times we took it 58 assert( this->recursion > 0 );58 verify( this->recursion > 0 ); 59 59 this->recursion += 1; 60 60 } … … 78 78 lock( &this->lock ); 79 79 80 thread_desc * thrd = this_thread();81 82 80 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 ); 84 82 85 83 //Leaving a recursion level, decrement the counter … … 167 165 //Check that everything is as expected 168 166 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 ); 171 169 172 170 unsigned short count = this->monitor_count; … … 229 227 230 228 //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 ); 233 231 234 232 unsigned short count = this->monitor_count; … … 278 276 279 277 //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 ); 282 280 283 281 unsigned short count = this->monitor_count; … … 327 325 328 326 uintptr_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." 334 330 ); 335 331 return this->blocked.head->user_info; … … 491 487 492 488 void append( __condition_blocked_queue_t * this, __condition_node_t * c ) { 493 assert(this->tail != NULL);489 verify(this->tail != NULL); 494 490 *this->tail = c; 495 491 this->tail = &c->next; -
src/libcfa/libhdr/libdebug.h
r667c7da r4aa2fb2 18 18 19 19 #ifdef __CFA_DEBUG__ 20 21 20 #define LIB_DEBUG_DO(x) x 21 #define LIB_NO_DEBUG_DO(x) ((void)0) 22 22 #else 23 24 23 #define LIB_DEBUG_DO(x) ((void)0) 24 #define LIB_NO_DEBUG_DO(x) x 25 25 #endif 26 27 #if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__)) 28 #define verify(x) assert(x) 29 #define verifyf(x, ...) assertf(x, __VA_ARGS__) 30 #else 31 #define verify(x) 32 #define verifyf(x, ...) 33 #endif 34 26 35 27 36 #ifdef __cforall
Note: See TracChangeset
for help on using the changeset viewer.