Changes in / [7a8f62c3:1def117b]
- Files:
-
- 6 added
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/Makefile.am
r7a8f62c3 r1def117b 62 62 iterator.hfa \ 63 63 limits.hfa \ 64 memory.hfa \ 64 65 parseargs.hfa \ 65 66 rational.hfa \ -
libcfa/src/concurrency/monitor.cfa
r7a8f62c3 r1def117b 89 89 __cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner); 90 90 91 if( !this->owner ) { 91 if( unlikely(0 != (0x1 & (uintptr_t)this->owner)) ) { 92 abort( "Attempt by thread \"%.256s\" (%p) to access joined monitor %p.", thrd->self_cor.name, thrd, this ); 93 } 94 else if( !this->owner ) { 92 95 // No one has the monitor, just take it 93 96 __set_owner( this, thrd ); … … 137 140 } 138 141 139 static void __dtor_enter( $monitor * this, fptr_t func ) {142 static void __dtor_enter( $monitor * this, fptr_t func, bool join ) { 140 143 // Lock the monitor spinlock 141 144 lock( this->lock __cfaabi_dbg_ctx2 ); … … 157 160 return; 158 161 } 159 else if( this->owner == thrd ) {162 else if( this->owner == thrd && !join) { 160 163 // We already have the monitor... but where about to destroy it so the nesting will fail 161 164 // Abort! 162 165 abort( "Attempt to destroy monitor %p by thread \"%.256s\" (%p) in nested mutex.", this, thrd->self_cor.name, thrd ); 166 } 167 // SKULLDUGGERY: join will act as a dtor so it would normally trigger to above check 168 // to avoid that it sets the owner to the special value thrd | 1p before exiting 169 else if( this->owner == ($thread*)(1 | (uintptr_t)thrd) ) { 170 // restore the owner and just return 171 __cfaabi_dbg_print_safe( "Kernel : Destroying free mon %p\n", this); 172 173 // No one has the monitor, just take it 174 this->owner = thrd; 175 176 verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 177 178 unlock( this->lock ); 179 return; 163 180 } 164 181 … … 251 268 252 269 // Leave single monitor for the last time 253 void __dtor_leave( $monitor * this ) {270 void __dtor_leave( $monitor * this, bool join ) { 254 271 __cfaabi_dbg_debug_do( 255 272 if( TL_GET( this_thread ) != this->owner ) { 256 273 abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, TL_GET( this_thread ), this->owner); 257 274 } 258 if( this->recursion != 1 ) {275 if( this->recursion != 1 && !join ) { 259 276 abort( "Destroyed monitor %p has %d outstanding nested calls.\n", this, this->recursion - 1); 260 277 } 261 278 ) 279 280 this->owner = ($thread*)(1 | (uintptr_t)this->owner); 262 281 } 263 282 … … 307 326 } 308 327 328 // Join a thread 329 forall( dtype T | is_thread(T) ) 330 T & join( T & this ) { 331 $monitor * m = get_monitor(this); 332 void (*dtor)(T& mutex this) = ^?{}; 333 monitor_dtor_guard_t __guard = { &m, (fptr_t)dtor, true }; 334 { 335 return this; 336 } 337 } 338 309 339 // Enter multiple monitor 310 340 // relies on the monitor array being sorted … … 366 396 // Ctor for monitor guard 367 397 // Sorts monitors before entering 368 void ?{}( monitor_dtor_guard_t & this, $monitor * m [], fptr_t func ) {398 void ?{}( monitor_dtor_guard_t & this, $monitor * m [], fptr_t func, bool join ) { 369 399 // optimization 370 400 $thread * thrd = TL_GET( this_thread ); … … 376 406 this.prev = thrd->monitors; 377 407 408 // Save whether we are in a join or not 409 this.join = join; 410 378 411 // Update thread context (needed for conditions) 379 412 (thrd->monitors){m, 1, func}; 380 413 381 __dtor_enter( this.m, func );414 __dtor_enter( this.m, func, join ); 382 415 } 383 416 … … 385 418 void ^?{}( monitor_dtor_guard_t & this ) { 386 419 // Leave the monitors in order 387 __dtor_leave( this.m );420 __dtor_leave( this.m, this.join ); 388 421 389 422 // Restore thread context -
libcfa/src/concurrency/monitor.hfa
r7a8f62c3 r1def117b 53 53 $monitor * m; 54 54 __monitor_group_t prev; 55 bool join; 55 56 }; 56 57 57 void ?{}( monitor_dtor_guard_t & this, $monitor ** m, void (*func)() );58 void ?{}( monitor_dtor_guard_t & this, $monitor ** m, void (*func)(), bool join ); 58 59 void ^?{}( monitor_dtor_guard_t & this ); 59 60 -
libcfa/src/concurrency/thread.hfa
r7a8f62c3 r1def117b 106 106 void sleep( Duration duration ); 107 107 108 //---------- 109 // join 110 forall( dtype T | is_thread(T) ) 111 T & join( T & this ); 112 108 113 // Local Variables: // 109 114 // mode: c // -
src/Concurrency/Keywords.cc
r7a8f62c3 r1def117b 931 931 { 932 932 new SingleInit( new AddressExpr( new VariableExpr( monitors ) ) ), 933 new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone(), false ) ) 933 new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone(), false ) ), 934 new SingleInit( new ConstantExpr( Constant::from_bool( false ) ) ) 934 935 }, 935 936 noDesignators, -
tests/Makefile.am
r7a8f62c3 r1def117b 38 38 # since automake doesn't have support for CFA we have to 39 39 AM_CFLAGS = $(if $(test), 2> $(test), ) \ 40 -fdebug-prefix-map=$(abspath ${abs_srcdir})= \ 41 -fdebug-prefix-map=/tmp= \ 40 42 -g \ 41 43 -Wall \ … … 110 112 % : %.cfa $(CFACCBIN) 111 113 $(CFACOMPILETEST) -c -o $(abspath ${@}).o 112 $(CFACCLOCAL) $( $(shell echo "${@}_FLAGSLD" | sed 's/-\|\//_/g')) $(abspath ${@}).o -o $(abspath ${@})114 $(CFACCLOCAL) $(if $(test), 2> $(test), ) $($(shell echo "${@}_FLAGSLD" | sed 's/-\|\//_/g')) ${@}.o -o $(abspath ${@}) 113 115 114 116 # implicit rule for c++ test … … 137 139 # CUSTOM TARGET 138 140 #------------------------------------------------------------------------------ 141 # tests that just validate syntax 142 expression : expression.cfa $(CFACCBIN) 143 $(CFACOMPILETEST) -c -fsyntax-only -o $(abspath ${@}) 144 139 145 # expected failures 140 146 # use custom target since they require a custom define and custom dependencies -
tests/pybin/tools.py
r7a8f62c3 r1def117b 120 120 return None 121 121 122 file = open(file, mode )122 file = open(file, mode, encoding="latin-1") # use latin-1 so all chars mean something. 123 123 exitstack.push(file) 124 124 return file -
tests/test.py
r7a8f62c3 r1def117b 207 207 else: 208 208 if os.stat(out_file).st_size < 1048576: 209 with open (out_file, "r" ) as myfile:209 with open (out_file, "r", encoding='latin-1') as myfile: # use latin-1 so all chars mean something. 210 210 error = myfile.read() 211 211 else:
Note: See TracChangeset
for help on using the changeset viewer.