5 #ifndef _RTE_SPINLOCK_H_ 6 #define _RTE_SPINLOCK_H_ 21 #ifdef RTE_FORCE_INTRINSICS 24 #include <rte_lock_annotations.h> 26 #include <rte_stdatomic.h> 35 typedef struct __rte_lockable {
36 volatile RTE_ATOMIC(
int) locked;
42 #define RTE_SPINLOCK_INITIALIZER { 0 } 64 __rte_exclusive_lock_function(sl);
66 #ifdef RTE_FORCE_INTRINSICS 69 __rte_no_thread_safety_analysis
73 while (!rte_atomic_compare_exchange_strong_explicit(&sl->locked, &exp, 1,
74 rte_memory_order_acquire, rte_memory_order_relaxed)) {
76 0, rte_memory_order_relaxed);
90 __rte_unlock_function(sl);
92 #ifdef RTE_FORCE_INTRINSICS 95 __rte_no_thread_safety_analysis
97 rte_atomic_store_explicit(&sl->locked, 0, rte_memory_order_release);
112 __rte_exclusive_trylock_function(1, sl);
114 #ifdef RTE_FORCE_INTRINSICS 117 __rte_no_thread_safety_analysis
120 return rte_atomic_compare_exchange_strong_explicit(&sl->locked, &exp, 1,
121 rte_memory_order_acquire, rte_memory_order_relaxed);
135 return rte_atomic_load_explicit(&sl->locked, rte_memory_order_acquire);
161 __rte_exclusive_lock_function(sl);
172 __rte_unlock_function(sl);
193 __rte_exclusive_trylock_function(1, sl);
207 #define RTE_SPINLOCK_RECURSIVE_INITIALIZER {RTE_SPINLOCK_INITIALIZER, -1, 0} 229 __rte_no_thread_safety_analysis
233 if (slr->user !=
id) {
246 __rte_no_thread_safety_analysis
248 if (--(slr->count) == 0) {
265 __rte_no_thread_safety_analysis
269 if (slr->user !=
id) {
static __rte_warn_unused_result int rte_spinlock_trylock_tm(rte_spinlock_t *sl) sl)
static void rte_spinlock_recursive_lock_tm(rte_spinlock_recursive_t *slr)
static void rte_spinlock_lock(rte_spinlock_t *sl)
static __rte_always_inline void rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected, rte_memory_order memorder)
static void rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysis
static __rte_warn_unused_result int rte_spinlock_recursive_trylock_tm(rte_spinlock_recursive_t *slr)
static void rte_spinlock_recursive_init(rte_spinlock_recursive_t *slr)
static void rte_spinlock_unlock(rte_spinlock_t *sl)
static void rte_spinlock_unlock_tm(rte_spinlock_t *sl)
static __rte_warn_unused_result int rte_spinlock_recursive_trylock(rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysis
static void rte_spinlock_init(rte_spinlock_t *sl)
static int rte_tm_supported(void)
static __rte_warn_unused_result int rte_spinlock_trylock(rte_spinlock_t *sl) sl)
static void rte_spinlock_recursive_unlock_tm(rte_spinlock_recursive_t *slr)
static int rte_spinlock_is_locked(rte_spinlock_t *sl)
static void rte_spinlock_recursive_lock(rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysis
static void rte_spinlock_lock_tm(rte_spinlock_t *sl)
static int rte_gettid(void)
#define __rte_warn_unused_result