5#ifndef _RTE_TICKETLOCK_H_
6#define _RTE_TICKETLOCK_H_
43#define RTE_TICKETLOCK_INITIALIZER { 0 }
54 __atomic_store_n(&tl->tickets, 0, __ATOMIC_RELAXED);
66 uint16_t me = __atomic_fetch_add(&tl->s.next, 1, __ATOMIC_RELAXED);
79 uint16_t i = __atomic_load_n(&tl->s.current, __ATOMIC_RELAXED);
80 __atomic_store_n(&tl->s.current, i + 1, __ATOMIC_RELEASE);
95 oldl.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
96 newl.tickets = oldl.tickets;
98 if (oldl.s.next == oldl.s.current) {
99 if (__atomic_compare_exchange_n(&tl->tickets, &oldl.tickets,
100 newl.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
119 tic.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_ACQUIRE);
120 return (tic.s.current != tic.s.next);
126#define TICKET_LOCK_INVALID_ID -1
132} rte_ticketlock_recursive_t;
137#define RTE_TICKETLOCK_RECURSIVE_INITIALIZER {RTE_TICKETLOCK_INITIALIZER, \
138 TICKET_LOCK_INVALID_ID, 0}
165 if (__atomic_load_n(&tlr->user, __ATOMIC_RELAXED) !=
id) {
167 __atomic_store_n(&tlr->user,
id, __ATOMIC_RELAXED);
181 if (--(tlr->count) == 0) {
201 if (__atomic_load_n(&tlr->user, __ATOMIC_RELAXED) !=
id) {
204 __atomic_store_n(&tlr->user,
id, __ATOMIC_RELAXED);
static int rte_gettid(void)
static __rte_always_inline void rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected, int memorder)
#define TICKET_LOCK_INVALID_ID
static void rte_ticketlock_recursive_init(rte_ticketlock_recursive_t *tlr)
static void rte_ticketlock_init(rte_ticketlock_t *tl)
static void rte_ticketlock_unlock(rte_ticketlock_t *tl)
static void rte_ticketlock_recursive_lock(rte_ticketlock_recursive_t *tlr)
static void rte_ticketlock_lock(rte_ticketlock_t *tl)
static void rte_ticketlock_recursive_unlock(rte_ticketlock_recursive_t *tlr)
static int rte_ticketlock_is_locked(rte_ticketlock_t *tl)
static int rte_ticketlock_recursive_trylock(rte_ticketlock_recursive_t *tlr)
static int rte_ticketlock_trylock(rte_ticketlock_t *tl)