5 #ifndef _RTE_TICKETLOCK_H_
6 #define _RTE_TICKETLOCK_H_
43 #define RTE_TICKETLOCK_INITIALIZER { 0 }
51 static inline __rte_experimental
void
54 __atomic_store_n(&tl->tickets, 0, __ATOMIC_RELAXED);
63 static inline __rte_experimental
void
66 uint16_t me = __atomic_fetch_add(&tl->s.next, 1, __ATOMIC_RELAXED);
67 while (__atomic_load_n(&tl->s.current, __ATOMIC_ACQUIRE) != me)
77 static inline __rte_experimental
void
80 uint16_t i = __atomic_load_n(&tl->s.current, __ATOMIC_RELAXED);
81 __atomic_store_n(&tl->s.current, i + 1, __ATOMIC_RELEASE);
92 static inline __rte_experimental
int
96 old.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
97 new.tickets = old.tickets;
99 if (old.s.next == old.s.current) {
100 if (__atomic_compare_exchange_n(&tl->tickets, &old.tickets,
101 new.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
116 static inline __rte_experimental
int
120 tic.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_ACQUIRE);
121 return (tic.s.current != tic.s.next);
127 #define TICKET_LOCK_INVALID_ID -1
133 } rte_ticketlock_recursive_t;
138 #define RTE_TICKETLOCK_RECURSIVE_INITIALIZER {RTE_TICKETLOCK_INITIALIZER, \
139 TICKET_LOCK_INVALID_ID, 0}
147 static inline __rte_experimental
void
161 static inline __rte_experimental
void
166 if (__atomic_load_n(&tlr->user, __ATOMIC_RELAXED) !=
id) {
168 __atomic_store_n(&tlr->user,
id, __ATOMIC_RELAXED);
179 static inline __rte_experimental
void
182 if (--(tlr->count) == 0) {
197 static inline __rte_experimental
int
202 if (__atomic_load_n(&tlr->user, __ATOMIC_RELAXED) !=
id) {
205 __atomic_store_n(&tlr->user,
id, __ATOMIC_RELAXED);