Ignore:
Timestamp:
Nov 28, 2017, 3:52:06 PM (6 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:
383e159, 8d5b9cf
Parents:
cf966b5 (diff), 8a0a64d9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/invoke.h

    rcf966b5 r6c2ba38  
    1414//
    1515
     16#include "bits/containers.h"
    1617#include "bits/defs.h"
    1718#include "bits/locks.h"
    1819
    19 #ifdef __CFORALL__
     20#ifdef __cforall
    2021extern "C" {
    2122#endif
     
    2526#define _INVOKE_H_
    2627
    27         typedef void (*fptr_t)();
    28         typedef int_fast16_t __lock_size_t;
    29 
    30         struct __thread_queue_t {
    31                 struct thread_desc * head;
    32                 struct thread_desc ** tail;
    33         };
    34 
    35         struct __condition_stack_t {
    36                 struct __condition_criterion_t * top;
    37         };
    38 
    39         #ifdef __CFORALL__
     28        #ifdef __cforall
    4029        extern "Cforall" {
    41                 void ?{}( struct __thread_queue_t & );
    42                 void append( struct __thread_queue_t &, struct thread_desc * );
    43                 struct thread_desc * pop_head( struct __thread_queue_t & );
    44                 struct thread_desc * remove( struct __thread_queue_t &, struct thread_desc ** );
    45 
    46                 void ?{}( struct __condition_stack_t & );
    47                 void push( struct __condition_stack_t &, struct __condition_criterion_t * );
    48                 struct __condition_criterion_t * pop( struct __condition_stack_t & );
     30                static inline struct thread_desc             * & get_next( struct thread_desc             & this );
     31                static inline struct __condition_criterion_t * & get_next( struct __condition_criterion_t & this );
    4932        }
    5033        #endif
     
    10083
    10184                // list of acceptable functions, null if any
    102                 struct __acceptable_t * clauses;
    103 
    104                 // number of acceptable functions
    105                 __lock_size_t size;
     85                __small_array_t(struct __acceptable_t) __cfa_anonymous_object;
    10686        };
    10787
     
    11494
    11595                // queue of threads that are blocked waiting for the monitor
    116                 struct __thread_queue_t entry_queue;
     96                __queue_t(struct thread_desc) entry_queue;
    11797
    11898                // stack of conditions to run next once we exit the monitor
    119                 struct __condition_stack_t signal_stack;
     99                __stack_t(struct __condition_criterion_t) signal_stack;
    120100
    121101                // monitor routines can be called recursively, we need to keep track of that
     
    131111        struct __monitor_group_t {
    132112                // currently held monitors
    133                 struct monitor_desc ** list;
    134 
    135                 // number of currently held monitors
    136                 __lock_size_t size;
     113                __small_array_t(monitor_desc*) __cfa_anonymous_object;
    137114
    138115                // last function that acquired monitors
     
    159136     };
    160137
    161      #ifdef __CFORALL__
     138     #ifdef __cforall
    162139     extern "Cforall" {
    163                 static inline monitor_desc * ?[?]( const __monitor_group_t & this, ptrdiff_t index ) {
    164                         return this.list[index];
     140                static inline thread_desc * & get_next( thread_desc & this ) {
     141                        return this.next;
     142                }
     143
     144                static inline struct __condition_criterion_t * & get_next( struct __condition_criterion_t & this );
     145
     146                static inline void ?{}(__monitor_group_t & this) {
     147                        (this.data){NULL};
     148                        (this.size){0};
     149                        (this.func){NULL};
     150                }
     151
     152                static inline void ?{}(__monitor_group_t & this, struct monitor_desc ** data, __lock_size_t size, fptr_t func) {
     153                        (this.data){data};
     154                        (this.size){size};
     155                        (this.func){func};
    165156                }
    166157
    167158                static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) {
    168                         if( (lhs.list != 0) != (rhs.list != 0) ) return false;
     159                        if( (lhs.data != 0) != (rhs.data != 0) ) return false;
    169160                        if( lhs.size != rhs.size ) return false;
    170161                        if( lhs.func != rhs.func ) return false;
     
    177168
    178169                        return true;
     170                }
     171
     172                static inline void ?=?(__monitor_group_t & lhs, const __monitor_group_t & rhs) {
     173                        lhs.data = rhs.data;
     174                        lhs.size = rhs.size;
     175                        lhs.func = rhs.func;
    179176                }
    180177        }
     
    210207#endif //_INVOKE_PRIVATE_H_
    211208#endif //! defined(__CFA_INVOKE_PRIVATE__)
    212 #ifdef __CFORALL__
     209#ifdef __cforall
    213210}
    214211#endif
Note: See TracChangeset for help on using the changeset viewer.