diff options
Diffstat (limited to 'platform/linux-generic/include/odp_bitset.h')
-rw-r--r-- | platform/linux-generic/include/odp_bitset.h | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/platform/linux-generic/include/odp_bitset.h b/platform/linux-generic/include/odp_bitset.h index 5c10ef9e5..0931fb337 100644 --- a/platform/linux-generic/include/odp_bitset.h +++ b/platform/linux-generic/include/odp_bitset.h @@ -24,39 +24,8 @@ * (lock-free) max is 128 */ -/* Find a suitable data type that supports lock-free atomic operations */ -#if defined(__aarch64__) && defined(__SIZEOF_INT128__) && \ - __SIZEOF_INT128__ == 16 -#define LOCKFREE16 -typedef __int128 bitset_t; -#define ATOM_BITSET_SIZE (CHAR_BIT * __SIZEOF_INT128__) - -#elif __GCC_ATOMIC_LLONG_LOCK_FREE == 2 && \ - __SIZEOF_LONG_LONG__ != __SIZEOF_LONG__ -typedef unsigned long long bitset_t; -#define ATOM_BITSET_SIZE (CHAR_BIT * __SIZEOF_LONG_LONG__) - -#elif __GCC_ATOMIC_LONG_LOCK_FREE == 2 && __SIZEOF_LONG__ != __SIZEOF_INT__ -typedef unsigned long bitset_t; -#define ATOM_BITSET_SIZE (CHAR_BIT * __SIZEOF_LONG__) - -#elif __GCC_ATOMIC_INT_LOCK_FREE == 2 -typedef unsigned int bitset_t; -#define ATOM_BITSET_SIZE (CHAR_BIT * __SIZEOF_INT__) - -#else -/* Target does not support lock-free atomic operations */ -typedef unsigned int bitset_t; -#define ATOM_BITSET_SIZE (CHAR_BIT * __SIZEOF_INT__) -#endif - #if ATOM_BITSET_SIZE <= 32 -static inline bitset_t bitset_mask(uint32_t bit) -{ - return 1UL << bit; -} - /* Return first-bit-set with StdC ffs() semantics */ static inline uint32_t bitset_ffs(bitset_t b) { @@ -71,11 +40,6 @@ static inline bitset_t bitset_monitor(bitset_t *bs, int mo) #elif ATOM_BITSET_SIZE <= 64 -static inline bitset_t bitset_mask(uint32_t bit) -{ - return 1ULL << bit; -} - /* Return first-bit-set with StdC ffs() semantics */ static inline uint32_t bitset_ffs(bitset_t b) { @@ -90,14 +54,6 @@ static inline bitset_t bitset_monitor(bitset_t *bs, int mo) #elif ATOM_BITSET_SIZE <= 128 -static inline bitset_t bitset_mask(uint32_t bit) -{ - if (bit < 64) - return 1ULL << bit; - else - return (unsigned __int128)(1ULL << (bit - 64)) << 64; -} - /* Return first-bit-set with StdC ffs() semantics */ static inline uint32_t bitset_ffs(bitset_t b) { @@ -119,60 +75,6 @@ static inline bitset_t bitset_monitor(bitset_t *bs, int mo) #error Unsupported size of bit sets (ATOM_BITSET_SIZE) #endif -/* Atomic load with memory ordering */ -static inline bitset_t atom_bitset_load(bitset_t *bs, int mo) -{ -#ifdef LOCKFREE16 - return __lockfree_load_16(bs, mo); -#else - return __atomic_load_n(bs, mo); -#endif -} - -/* Atomic bit set with memory ordering */ -static inline void atom_bitset_set(bitset_t *bs, uint32_t bit, int mo) -{ -#ifdef LOCKFREE16 - (void)__lockfree_fetch_or_16(bs, bitset_mask(bit), mo); -#else - (void)__atomic_fetch_or(bs, bitset_mask(bit), mo); -#endif -} - -/* Atomic bit clear with memory ordering */ -static inline void atom_bitset_clr(bitset_t *bs, uint32_t bit, int mo) -{ -#ifdef LOCKFREE16 - (void)__lockfree_fetch_and_16(bs, ~bitset_mask(bit), mo); -#else - (void)__atomic_fetch_and(bs, ~bitset_mask(bit), mo); -#endif -} - -/* Atomic exchange with memory ordering */ -static inline bitset_t atom_bitset_xchg(bitset_t *bs, bitset_t neu, int mo) -{ -#ifdef LOCKFREE16 - return __lockfree_exchange_16(bs, neu, mo); -#else - return __atomic_exchange_n(bs, neu, mo); -#endif -} - -/* Atomic compare&exchange with memory ordering */ -static inline bitset_t atom_bitset_cmpxchg(bitset_t *bs, bitset_t *old, - bitset_t neu, bool weak, - int mo_success, int mo_failure) -{ -#ifdef LOCKFREE16 - return __lockfree_compare_exchange_16(bs, old, neu, weak, mo_success, - mo_failure); -#else - return __atomic_compare_exchange_n(bs, old, neu, weak, mo_success, - mo_failure); -#endif -} - /* Return a & ~b */ static inline bitset_t bitset_andn(bitset_t a, bitset_t b) { |