34 #ifndef _RTE_ATOMIC_H_
35 #define _RTE_ATOMIC_H_
55 static inline void rte_mb(
void);
64 static inline void rte_wmb(
void);
73 static inline void rte_rmb(
void);
110 #define rte_compiler_barrier() do { \
111 asm volatile ("" : : : "memory"); \
135 #ifdef RTE_FORCE_INTRINSICS
139 return __sync_bool_compare_and_swap(dst, exp, src);
153 #define RTE_ATOMIC16_INIT(val) { (val) }
175 static inline int16_t
206 __sync_fetch_and_add(&v->
cnt, inc);
220 __sync_fetch_and_sub(&v->
cnt, dec);
232 #ifdef RTE_FORCE_INTRINSICS
249 #ifdef RTE_FORCE_INTRINSICS
270 static inline int16_t
273 return __sync_add_and_fetch(&v->
cnt, inc);
290 static inline int16_t
293 return __sync_sub_and_fetch(&v->
cnt, dec);
309 #ifdef RTE_FORCE_INTRINSICS
312 return (__sync_add_and_fetch(&v->
cnt, 1) == 0);
329 #ifdef RTE_FORCE_INTRINSICS
332 return (__sync_sub_and_fetch(&v->
cnt, 1) == 0);
349 #ifdef RTE_FORCE_INTRINSICS
388 #ifdef RTE_FORCE_INTRINSICS
392 return __sync_bool_compare_and_swap(dst, exp, src);
406 #define RTE_ATOMIC32_INIT(val) { (val) }
428 static inline int32_t
459 __sync_fetch_and_add(&v->
cnt, inc);
473 __sync_fetch_and_sub(&v->
cnt, dec);
485 #ifdef RTE_FORCE_INTRINSICS
502 #ifdef RTE_FORCE_INTRINSICS
523 static inline int32_t
526 return __sync_add_and_fetch(&v->
cnt, inc);
543 static inline int32_t
546 return __sync_sub_and_fetch(&v->
cnt, dec);
562 #ifdef RTE_FORCE_INTRINSICS
565 return (__sync_add_and_fetch(&v->
cnt, 1) == 0);
582 #ifdef RTE_FORCE_INTRINSICS
585 return (__sync_sub_and_fetch(&v->
cnt, 1) == 0);
602 #ifdef RTE_FORCE_INTRINSICS
640 #ifdef RTE_FORCE_INTRINSICS
644 return __sync_bool_compare_and_swap(dst, exp, src);
658 #define RTE_ATOMIC64_INIT(val) { (val) }
669 #ifdef RTE_FORCE_INTRINSICS
679 while (success == 0) {
696 static inline int64_t
699 #ifdef RTE_FORCE_INTRINSICS
700 static inline int64_t
709 while (success == 0) {
731 #ifdef RTE_FORCE_INTRINSICS
741 while (success == 0) {
761 #ifdef RTE_FORCE_INTRINSICS
765 __sync_fetch_and_add(&v->
cnt, inc);
780 #ifdef RTE_FORCE_INTRINSICS
784 __sync_fetch_and_sub(&v->
cnt, dec);
797 #ifdef RTE_FORCE_INTRINSICS
814 #ifdef RTE_FORCE_INTRINSICS
835 static inline int64_t
838 #ifdef RTE_FORCE_INTRINSICS
839 static inline int64_t
842 return __sync_add_and_fetch(&v->
cnt, inc);
859 static inline int64_t
862 #ifdef RTE_FORCE_INTRINSICS
863 static inline int64_t
866 return __sync_sub_and_fetch(&v->
cnt, dec);
883 #ifdef RTE_FORCE_INTRINSICS
903 #ifdef RTE_FORCE_INTRINSICS
923 #ifdef RTE_FORCE_INTRINSICS
938 #ifdef RTE_FORCE_INTRINSICS