Changes in libcfa/src/bits/locks.hfa [73abe95:3aeee3c]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/locks.hfa
r73abe95 r3aeee3c 10 10 // Created On : Tue Oct 31 15:14:38 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 30 18:18:13201813 // Update Count : 912 // Last Modified On : Sat Aug 11 15:42:24 2018 13 // Update Count : 10 14 14 // 15 15 … … 37 37 #endif 38 38 39 #if defined( __i386 ) || defined( __x86_64 ) || defined( __ARM_ARCH )40 // Intel recommendation41 #define __ALIGN__ __attribute__(( aligned (128) ))42 #elif defined( __sparc )43 #define __ALIGN__ CALIGN44 #else45 #error unsupported architecture46 #endif47 48 39 struct __spinlock_t { 49 40 // 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; 54 42 #ifdef __CFA_DEBUG__ 55 43 // previous function to acquire the lock … … 58 46 void* prev_thrd; 59 47 #endif 60 } __ALIGN__;48 }; 61 49 62 50 #ifdef __cforall … … 64 52 extern void disable_interrupts(); 65 53 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 66 60 } 67 61 … … 72 66 } 73 67 74 75 #ifdef __CFA_DEBUG__76 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name);77 #else78 #define __cfaabi_dbg_record(x, y)79 #endif80 81 68 // 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); 84 71 if( result ) { 85 72 disable_interrupts();
Note: See TracChangeset
for help on using the changeset viewer.