Changeset dca5802 for libcfa/src/bits
- Timestamp:
- Jan 30, 2020, 1:40:05 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b7d6a36
- Parents:
- 75ca7f4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/defs.hfa
r75ca7f4 rdca5802 56 56 // #define __CFA_NO_BIT_TEST_AND_SET__ 57 57 58 static inline bool bts(volatile unsigned long long int * target, unsigned long long int bit ) { 58 #if defined( __i386 ) 59 static inline bool __atomic_bts(volatile unsigned long int * target, unsigned long int bit ) { 60 #if defined(__CFA_NO_BIT_TEST_AND_SET__) 61 unsigned long int mask = 1ul << bit; 62 unsigned long int ret = __atomic_fetch_or(target, mask, (int)__ATOMIC_RELAXED); 63 return (ret & mask) != 0; 64 #else 65 int result = 0; 66 asm volatile( 67 "LOCK btsl %[bit], %[target]\n\t" 68 : "=@ccc" (result) 69 : [target] "m" (*target), [bit] "r" (bit) 70 ); 71 return result != 0; 72 #endif 73 } 74 75 static inline bool __atomic_btr(volatile unsigned long int * target, unsigned long int bit ) { 76 #if defined(__CFA_NO_BIT_TEST_AND_SET__) 77 unsigned long int mask = 1ul << bit; 78 unsigned long int ret = __atomic_fetch_and(target, ~mask, (int)__ATOMIC_RELAXED); 79 return (ret & mask) != 0; 80 #else 81 int result = 0; 82 asm volatile( 83 "LOCK btrl %[bit], %[target]\n\t" 84 :"=@ccc" (result) 85 : [target] "m" (*target), [bit] "r" (bit) 86 ); 87 return result != 0; 88 #endif 89 } 90 #elif defined( __x86_64 ) 91 static inline bool __atomic_bts(volatile unsigned long long int * target, unsigned long long int bit ) { 59 92 #if defined(__CFA_NO_BIT_TEST_AND_SET__) 60 93 unsigned long long int mask = 1ul << bit; … … 72 105 } 73 106 74 static inline bool btr(volatile unsigned long long int * target, unsigned long long int bit ) {107 static inline bool __atomic_btr(volatile unsigned long long int * target, unsigned long long int bit ) { 75 108 #if defined(__CFA_NO_BIT_TEST_AND_SET__) 76 109 unsigned long long int mask = 1ul << bit; … … 87 120 #endif 88 121 } 122 #elif defined( __ARM_ARCH ) 123 #error __atomic_bts and __atomic_btr not implemented for arm 124 #else 125 #error uknown hardware architecture 126 #endif
Note: See TracChangeset
for help on using the changeset viewer.