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