Ignore:
Timestamp:
Nov 3, 2017, 5:59:32 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
121ac13
Parents:
c1a9c86
Message:

Converted more shorts to int_fast16_T

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/monitor.c

    rc1a9c86 r59a0bde  
    4646static inline thread_desc *        check_condition   ( __condition_criterion_t * );
    4747static inline void                 brand_condition   ( condition & );
    48 static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc * monitors [], int count );
     48static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc * monitors [], __lock_size_t count );
    4949
    5050forall(dtype T | sized( T ))
    51 static inline short insert_unique( T * array [], short & size, T * val );
    52 static inline short count_max    ( const __waitfor_mask_t & mask );
    53 static inline short aggregate    ( monitor_desc * storage [], const __waitfor_mask_t & mask );
     51static inline __lock_size_t insert_unique( T * array [], __lock_size_t & size, T * val );
     52static inline __lock_size_t count_max    ( const __waitfor_mask_t & mask );
     53static inline __lock_size_t aggregate    ( monitor_desc * storage [], const __waitfor_mask_t & mask );
    5454
    5555//-----------------------------------------------------------------------------
     
    6767#define monitor_ctx( mons, cnt )                                /* Define that create the necessary struct for internal/external scheduling operations */ \
    6868        monitor_desc ** monitors = mons;                          /* Save the targeted monitors                                                          */ \
    69         unsigned short count = cnt;                               /* Save the count to a local variable                                                  */ \
     69        __lock_size_t count = cnt;                                /* Save the count to a local variable                                                  */ \
    7070        unsigned int recursions[ count ];                         /* Save the current recursion levels to restore them later                             */ \
    7171        __waitfor_mask_t masks [ count ];                         /* Save the current waitfor masks to restore them later                                */ \
     
    153153                }
    154154
    155                 int count = 1;
     155                __lock_size_t count = 1;
    156156                monitor_desc ** monitors = &this;
    157157                __monitor_group_t group = { &this, 1, func };
     
    272272// relies on the monitor array being sorted
    273273static inline void enter( __monitor_group_t monitors ) {
    274         for(int i = 0; i < monitors.size; i++) {
     274        for( __lock_size_t i = 0; i < monitors.size; i++) {
    275275                __enter_monitor_desc( monitors.list[i], monitors );
    276276        }
     
    279279// Leave multiple monitor
    280280// relies on the monitor array being sorted
    281 static inline void leave(monitor_desc * monitors [], int count) {
    282         for(int i = count - 1; i >= 0; i--) {
     281static inline void leave(monitor_desc * monitors [], __lock_size_t count) {
     282        for( __lock_size_t i = count - 1; i >= 0; i--) {
    283283                __leave_monitor_desc( monitors[i] );
    284284        }
     
    287287// Ctor for monitor guard
    288288// Sorts monitors before entering
    289 void ?{}( monitor_guard_t & this, monitor_desc * m [], int count, fptr_t func ) {
     289void ?{}( monitor_guard_t & this, monitor_desc * m [], __lock_size_t count, fptr_t func ) {
    290290        // Store current array
    291291        this.m = m;
     
    350350//-----------------------------------------------------------------------------
    351351// Internal scheduling types
    352 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info ) {
     352void ?{}(__condition_node_t & this, thread_desc * waiting_thread, __lock_size_t count, uintptr_t user_info ) {
    353353        this.waiting_thread = waiting_thread;
    354354        this.count = count;
     
    395395
    396396        // Find the next thread(s) to run
    397         short thread_count = 0;
     397        __lock_size_t thread_count = 0;
    398398        thread_desc * threads[ count ];
    399399        __builtin_memset( threads, 0, sizeof( threads ) );
     
    403403
    404404        // Remove any duplicate threads
    405         for( int i = 0; i < count; i++) {
     405        for( __lock_size_t i = 0; i < count; i++) {
    406406                thread_desc * new_owner = next_thread( monitors[i] );
    407407                insert_unique( threads, thread_count, new_owner );
     
    436436        );
    437437
    438         unsigned short count = this.monitor_count;
     438        __lock_size_t count = this.monitor_count;
    439439
    440440        // Lock all monitors
     
    523523        // This statment doesn't have a contiguous list of monitors...
    524524        // Create one!
    525         short max = count_max( mask );
     525        __lock_size_t max = count_max( mask );
    526526        monitor_desc * mon_storage[max];
    527527        __builtin_memset( mon_storage, 0, sizeof( mon_storage ) );
    528         short actual_count = aggregate( mon_storage, mask );
    529 
    530         LIB_DEBUG_PRINT_BUFFER_DECL( "Kernel : waitfor %d (s: %d, m: %d)\n", actual_count, mask.size, (short)max);
     528        __lock_size_t actual_count = aggregate( mon_storage, mask );
     529
     530        LIB_DEBUG_PRINT_BUFFER_DECL( "Kernel : waitfor %d (s: %d, m: %d)\n", actual_count, mask.size, (__lock_size_t)max);
    531531
    532532        if(actual_count == 0) return;
     
    615615        set_mask( monitors, count, mask );
    616616
    617         for(int i = 0; i < count; i++) {
     617        for( __lock_size_t i = 0; i < count; i++) {
    618618                verify( monitors[i]->owner == this_thread );
    619619        }
     
    691691static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & group ) {
    692692        __acceptable_t * it = this->mask.clauses; // Optim
    693         int count = this->mask.size;
     693        __lock_size_t count = this->mask.size;
    694694
    695695        // Check if there are any acceptable functions
     
    700700
    701701        // For all acceptable functions check if this is the current function.
    702         for( short i = 0; i < count; i++, it++ ) {
     702        for( __lock_size_t i = 0; i < count; i++, it++ ) {
    703703                if( *it == group ) {
    704704                        *this->mask.accepted = i;
     
    823823}
    824824
    825 static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor_desc * monitors [], int count ) {
     825static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor_desc * monitors [], __lock_size_t count ) {
    826826
    827827        __thread_queue_t & entry_queue = monitors[0]->entry_queue;
     
    850850
    851851forall(dtype T | sized( T ))
    852 static inline short insert_unique( T * array [], short & size, T * val ) {
     852static inline __lock_size_t insert_unique( T * array [], __lock_size_t & size, T * val ) {
    853853        if( !val ) return size;
    854854
    855         for(int i = 0; i <= size; i++) {
     855        for( __lock_size_t i = 0; i <= size; i++) {
    856856                if( array[i] == val ) return size;
    857857        }
     
    862862}
    863863
    864 static inline short count_max( const __waitfor_mask_t & mask ) {
    865         short max = 0;
    866         for( int i = 0; i < mask.size; i++ ) {
     864static inline __lock_size_t count_max( const __waitfor_mask_t & mask ) {
     865        __lock_size_t max = 0;
     866        for( __lock_size_t i = 0; i < mask.size; i++ ) {
    867867                max += mask.clauses[i].size;
    868868        }
     
    870870}
    871871
    872 static inline short aggregate( monitor_desc * storage [], const __waitfor_mask_t & mask ) {
    873         short size = 0;
    874         for( int i = 0; i < mask.size; i++ ) {
     872static inline __lock_size_t aggregate( monitor_desc * storage [], const __waitfor_mask_t & mask ) {
     873        __lock_size_t size = 0;
     874        for( __lock_size_t i = 0; i < mask.size; i++ ) {
    875875                __libcfa_small_sort( mask.clauses[i].list, mask.clauses[i].size );
    876                 for( int j = 0; j < mask.clauses[i].size; j++) {
     876                for( __lock_size_t j = 0; j < mask.clauses[i].size; j++) {
    877877                        insert_unique( storage, size, mask.clauses[i].list[j] );
    878878                }
Note: See TracChangeset for help on using the changeset viewer.