Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/locks.hfa

    r73abe95 r3aeee3c  
    1010// Created On       : Tue Oct 31 15:14:38 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 30 18:18:13 2018
    13 // Update Count     : 9
     12// Last Modified On : Sat Aug 11 15:42:24 2018
     13// Update Count     : 10
    1414//
    1515
     
    3737#endif
    3838
    39 #if defined( __i386 ) || defined( __x86_64 ) || defined( __ARM_ARCH )
    40         // Intel recommendation
    41         #define __ALIGN__ __attribute__(( aligned (128) ))
    42 #elif defined( __sparc )
    43         #define __ALIGN__ CALIGN
    44 #else
    45         #error unsupported architecture
    46 #endif
    47 
    4839struct __spinlock_t {
    4940        // Wrap in struct to prevent false sharing with debug info
    50         struct {
    51                 // Align lock on 128-bit boundary
    52                 __ALIGN__ volatile _Bool lock;
    53         };
     41        volatile bool lock;
    5442        #ifdef __CFA_DEBUG__
    5543                // previous function to acquire the lock
     
    5846                void* prev_thrd;
    5947        #endif
    60 } __ALIGN__;
     48};
    6149
    6250#ifdef __cforall
     
    6452                extern void disable_interrupts();
    6553                extern void enable_interrupts_noPoll();
     54
     55                #ifdef __CFA_DEBUG__
     56                        void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name);
     57                #else
     58                        #define __cfaabi_dbg_record(x, y)
     59                #endif
    6660        }
    6761
     
    7266        }
    7367
    74 
    75         #ifdef __CFA_DEBUG__
    76                 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name);
    77         #else
    78                 #define __cfaabi_dbg_record(x, y)
    79         #endif
    80 
    8168        // Lock the spinlock, return false if already acquired
    82         static inline _Bool try_lock  ( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) {
    83                 _Bool result = (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0);
     69        static inline bool try_lock  ( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) {
     70                bool result = (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0);
    8471                if( result ) {
    8572                        disable_interrupts();
Note: See TracChangeset for help on using the changeset viewer.