Changes in / [1def117b:7a8f62c3]


Ignore:
Files:
1 added
6 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    r1def117b r7a8f62c3  
    6262        iterator.hfa \
    6363        limits.hfa \
    64         memory.hfa \
    6564        parseargs.hfa \
    6665        rational.hfa \
  • libcfa/src/concurrency/monitor.cfa

    r1def117b r7a8f62c3  
    8989        __cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
    9090
    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 ) {
    9592                // No one has the monitor, just take it
    9693                __set_owner( this, thrd );
     
    140137}
    141138
    142 static void __dtor_enter( $monitor * this, fptr_t func, bool join ) {
     139static void __dtor_enter( $monitor * this, fptr_t func ) {
    143140        // Lock the monitor spinlock
    144141        lock( this->lock __cfaabi_dbg_ctx2 );
     
    160157                return;
    161158        }
    162         else if( this->owner == thrd && !join) {
     159        else if( this->owner == thrd) {
    163160                // We already have the monitor... but where about to destroy it so the nesting will fail
    164161                // Abort!
    165162                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;
    180163        }
    181164
     
    268251
    269252// Leave single monitor for the last time
    270 void __dtor_leave( $monitor * this, bool join ) {
     253void __dtor_leave( $monitor * this ) {
    271254        __cfaabi_dbg_debug_do(
    272255                if( TL_GET( this_thread ) != this->owner ) {
    273256                        abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, TL_GET( this_thread ), this->owner);
    274257                }
    275                 if( this->recursion != 1  && !join ) {
     258                if( this->recursion != 1 ) {
    276259                        abort( "Destroyed monitor %p has %d outstanding nested calls.\n", this, this->recursion - 1);
    277260                }
    278261        )
    279 
    280         this->owner = ($thread*)(1 | (uintptr_t)this->owner);
    281262}
    282263
     
    326307}
    327308
    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 
    339309// Enter multiple monitor
    340310// relies on the monitor array being sorted
     
    396366// Ctor for monitor guard
    397367// Sorts monitors before entering
    398 void ?{}( monitor_dtor_guard_t & this, $monitor * m [], fptr_t func, bool join ) {
     368void ?{}( monitor_dtor_guard_t & this, $monitor * m [], fptr_t func ) {
    399369        // optimization
    400370        $thread * thrd = TL_GET( this_thread );
     
    406376        this.prev = thrd->monitors;
    407377
    408         // Save whether we are in a join or not
    409         this.join = join;
    410 
    411378        // Update thread context (needed for conditions)
    412379        (thrd->monitors){m, 1, func};
    413380
    414         __dtor_enter( this.m, func, join );
     381        __dtor_enter( this.m, func );
    415382}
    416383
     
    418385void ^?{}( monitor_dtor_guard_t & this ) {
    419386        // Leave the monitors in order
    420         __dtor_leave( this.m, this.join );
     387        __dtor_leave( this.m );
    421388
    422389        // Restore thread context
  • libcfa/src/concurrency/monitor.hfa

    r1def117b r7a8f62c3  
    5353        $monitor *    m;
    5454        __monitor_group_t prev;
    55         bool join;
    5655};
    5756
    58 void ?{}( monitor_dtor_guard_t & this, $monitor ** m, void (*func)(), bool join );
     57void ?{}( monitor_dtor_guard_t & this, $monitor ** m, void (*func)() );
    5958void ^?{}( monitor_dtor_guard_t & this );
    6059
  • libcfa/src/concurrency/thread.hfa

    r1def117b r7a8f62c3  
    106106void sleep( Duration duration );
    107107
    108 //----------
    109 // join
    110 forall( dtype T | is_thread(T) )
    111 T & join( T & this );
    112 
    113108// Local Variables: //
    114109// mode: c //
  • src/Concurrency/Keywords.cc

    r1def117b r7a8f62c3  
    931931                                        {
    932932                                                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 ) )
    935934                                        },
    936935                                        noDesignators,
  • tests/Makefile.am

    r1def117b r7a8f62c3  
    3838# since automake doesn't have support for CFA we have to
    3939AM_CFLAGS = $(if $(test), 2> $(test), ) \
    40         -fdebug-prefix-map=$(abspath ${abs_srcdir})= \
    41         -fdebug-prefix-map=/tmp= \
    4240        -g \
    4341        -Wall \
     
    112110% : %.cfa $(CFACCBIN)
    113111        $(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 ${@})
    115113
    116114# implicit rule for c++ test
     
    139137# CUSTOM TARGET
    140138#------------------------------------------------------------------------------
    141 # tests that just validate syntax
    142 expression : expression.cfa $(CFACCBIN)
    143         $(CFACOMPILETEST) -c -fsyntax-only -o $(abspath ${@})
    144 
    145139# expected failures
    146140# use custom target since they require a custom define and custom dependencies
  • tests/pybin/tools.py

    r1def117b r7a8f62c3  
    120120                return None
    121121
    122         file = open(file, mode, encoding="latin-1") # use latin-1 so all chars mean something.
     122        file = open(file, mode)
    123123        exitstack.push(file)
    124124        return file
  • tests/test.py

    r1def117b r7a8f62c3  
    207207                else:
    208208                        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:
    210210                                        error = myfile.read()
    211211                        else:
Note: See TracChangeset for help on using the changeset viewer.