Changes in libcfa/src/bits/locks.hfa [3aeee3c:73abe95]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/locks.hfa
r3aeee3c r73abe95 10 10 // Created On : Tue Oct 31 15:14:38 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 11 15:42:24201813 // Update Count : 1012 // Last Modified On : Fri Mar 30 18:18:13 2018 13 // Update Count : 9 14 14 // 15 15 … … 37 37 #endif 38 38 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 39 48 struct __spinlock_t { 40 49 // Wrap in struct to prevent false sharing with debug info 41 volatile bool lock; 50 struct { 51 // Align lock on 128-bit boundary 52 __ALIGN__ volatile _Bool lock; 53 }; 42 54 #ifdef __CFA_DEBUG__ 43 55 // previous function to acquire the lock … … 46 58 void* prev_thrd; 47 59 #endif 48 } ;60 } __ALIGN__; 49 61 50 62 #ifdef __cforall … … 52 64 extern void disable_interrupts(); 53 65 extern void enable_interrupts_noPoll(); 54 55 #ifdef __CFA_DEBUG__56 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name);57 #else58 #define __cfaabi_dbg_record(x, y)59 #endif60 66 } 61 67 … … 66 72 } 67 73 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 68 81 // Lock the spinlock, return false if already acquired 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);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); 71 84 if( result ) { 72 85 disable_interrupts();
Note: See TracChangeset
for help on using the changeset viewer.