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>
31typedef struct __rte_lockable {
32 volatile RTE_ATOMIC(
int) locked;
38#define RTE_SPINLOCK_INITIALIZER { 0 }
60 __rte_exclusive_lock_function(sl);
62#ifdef RTE_FORCE_INTRINSICS
65 __rte_no_thread_safety_analysis
69 while (!rte_atomic_compare_exchange_strong_explicit(&sl->locked, &exp, 1,
70 rte_memory_order_acquire, rte_memory_order_relaxed)) {
72 0, rte_memory_order_relaxed);
86 __rte_unlock_function(sl);
88#ifdef RTE_FORCE_INTRINSICS
91 __rte_no_thread_safety_analysis
93 rte_atomic_store_explicit(&sl->locked, 0, rte_memory_order_release);
108 __rte_exclusive_trylock_function(1, sl);
110#ifdef RTE_FORCE_INTRINSICS
113 __rte_no_thread_safety_analysis
116 return rte_atomic_compare_exchange_strong_explicit(&sl->locked, &exp, 1,
117 rte_memory_order_acquire, rte_memory_order_relaxed);
131 return rte_atomic_load_explicit(&sl->locked, rte_memory_order_acquire);
157 __rte_exclusive_lock_function(sl);
168 __rte_unlock_function(sl);
189 __rte_exclusive_trylock_function(1, sl);
203#define RTE_SPINLOCK_RECURSIVE_INITIALIZER {RTE_SPINLOCK_INITIALIZER, -1, 0}
225 __rte_no_thread_safety_analysis
229 if (slr->user !=
id) {
242 __rte_no_thread_safety_analysis
244 if (--(slr->count) == 0) {
261 __rte_no_thread_safety_analysis
265 if (slr->user !=
id) {
#define __rte_warn_unused_result
static int rte_gettid(void)
static __rte_always_inline void rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected, rte_memory_order memorder)
static __rte_warn_unused_result int rte_spinlock_trylock(rte_spinlock_t *sl) sl)
static int rte_tm_supported(void)
static __rte_warn_unused_result int rte_spinlock_recursive_trylock_tm(rte_spinlock_recursive_t *slr)
static void rte_spinlock_recursive_lock_tm(rte_spinlock_recursive_t *slr)
static void rte_spinlock_unlock(rte_spinlock_t *sl)
static void rte_spinlock_recursive_unlock_tm(rte_spinlock_recursive_t *slr)
static void rte_spinlock_lock(rte_spinlock_t *sl)
static void rte_spinlock_lock_tm(rte_spinlock_t *sl)
static void rte_spinlock_recursive_init(rte_spinlock_recursive_t *slr)
static __rte_warn_unused_result int rte_spinlock_recursive_trylock(rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysis
static void rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr) __rte_no_thread_safety_analysis
static void rte_spinlock_unlock_tm(rte_spinlock_t *sl)
static __rte_warn_unused_result int rte_spinlock_trylock_tm(rte_spinlock_t *sl) sl)
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_init(rte_spinlock_t *sl)