34 #ifndef _RTE_ATOMIC_H_
35 #define _RTE_ATOMIC_H_
56 static inline void rte_mb(
void);
65 static inline void rte_wmb(
void);
74 static inline void rte_rmb(
void);
138 #define rte_compiler_barrier() do { \
139 asm volatile ("" : : : "memory"); \
163 #ifdef RTE_FORCE_INTRINSICS
167 return __sync_bool_compare_and_swap(dst, exp, src);
181 #define RTE_ATOMIC16_INIT(val) { (val) }
203 static inline int16_t
234 __sync_fetch_and_add(&v->
cnt, inc);
248 __sync_fetch_and_sub(&v->
cnt, dec);
260 #ifdef RTE_FORCE_INTRINSICS
277 #ifdef RTE_FORCE_INTRINSICS
298 static inline int16_t
301 return __sync_add_and_fetch(&v->
cnt, inc);
318 static inline int16_t
321 return __sync_sub_and_fetch(&v->
cnt, dec);
337 #ifdef RTE_FORCE_INTRINSICS
340 return __sync_add_and_fetch(&v->
cnt, 1) == 0;
357 #ifdef RTE_FORCE_INTRINSICS
360 return __sync_sub_and_fetch(&v->
cnt, 1) == 0;
377 #ifdef RTE_FORCE_INTRINSICS
416 #ifdef RTE_FORCE_INTRINSICS
420 return __sync_bool_compare_and_swap(dst, exp, src);
434 #define RTE_ATOMIC32_INIT(val) { (val) }
456 static inline int32_t
487 __sync_fetch_and_add(&v->
cnt, inc);
501 __sync_fetch_and_sub(&v->
cnt, dec);
513 #ifdef RTE_FORCE_INTRINSICS
530 #ifdef RTE_FORCE_INTRINSICS
551 static inline int32_t
554 return __sync_add_and_fetch(&v->
cnt, inc);
571 static inline int32_t
574 return __sync_sub_and_fetch(&v->
cnt, dec);
590 #ifdef RTE_FORCE_INTRINSICS
593 return __sync_add_and_fetch(&v->
cnt, 1) == 0;
610 #ifdef RTE_FORCE_INTRINSICS
613 return __sync_sub_and_fetch(&v->
cnt, 1) == 0;
630 #ifdef RTE_FORCE_INTRINSICS
668 #ifdef RTE_FORCE_INTRINSICS
672 return __sync_bool_compare_and_swap(dst, exp, src);
686 #define RTE_ATOMIC64_INIT(val) { (val) }
697 #ifdef RTE_FORCE_INTRINSICS
707 while (success == 0) {
724 static inline int64_t
727 #ifdef RTE_FORCE_INTRINSICS
728 static inline int64_t
737 while (success == 0) {
759 #ifdef RTE_FORCE_INTRINSICS
769 while (success == 0) {
789 #ifdef RTE_FORCE_INTRINSICS
793 __sync_fetch_and_add(&v->
cnt, inc);
808 #ifdef RTE_FORCE_INTRINSICS
812 __sync_fetch_and_sub(&v->
cnt, dec);
825 #ifdef RTE_FORCE_INTRINSICS
842 #ifdef RTE_FORCE_INTRINSICS
863 static inline int64_t
866 #ifdef RTE_FORCE_INTRINSICS
867 static inline int64_t
870 return __sync_add_and_fetch(&v->
cnt, inc);
887 static inline int64_t
890 #ifdef RTE_FORCE_INTRINSICS
891 static inline int64_t
894 return __sync_sub_and_fetch(&v->
cnt, dec);
911 #ifdef RTE_FORCE_INTRINSICS
931 #ifdef RTE_FORCE_INTRINSICS
951 #ifdef RTE_FORCE_INTRINSICS
966 #ifdef RTE_FORCE_INTRINSICS