eal: remove redundant atomic API description
[dpdk.git] / lib / librte_eal / common / include / arch / ppc_64 / rte_atomic.h
index b8bc2c0..d6d4014 100644 (file)
 extern "C" {
 #endif
 
+#include <stdint.h>
 #include "generic/rte_atomic.h"
 
-/**
- * General memory barrier.
- *
- * Guarantees that the LOAD and STORE operations generated before the
- * barrier occur before the LOAD and STORE operations generated after.
- */
-#define        rte_mb()  {asm volatile("sync" : : : "memory"); }
+#define        rte_mb()  asm volatile("sync" : : : "memory")
 
-/**
- * Write memory barrier.
- *
- * Guarantees that the STORE operations generated before the barrier
- * occur before the STORE operations generated after.
- */
-#define        rte_wmb() {asm volatile("sync" : : : "memory"); }
+#define        rte_wmb() asm volatile("sync" : : : "memory")
 
-/**
- * Read memory barrier.
- *
- * Guarantees that the LOAD operations generated before the barrier
- * occur before the LOAD operations generated after.
- */
-#define        rte_rmb() {asm volatile("sync" : : : "memory"); }
+#define        rte_rmb() asm volatile("sync" : : : "memory")
 
 #define rte_smp_mb() rte_mb()
 
-#define rte_smp_wmb() rte_compiler_barrier()
+#define rte_smp_wmb() rte_wmb()
+
+#define rte_smp_rmb() rte_rmb()
+
+#define rte_io_mb() rte_mb()
+
+#define rte_io_wmb() rte_wmb()
+
+#define rte_io_rmb() rte_rmb()
 
-#define rte_smp_rmb() rte_compiler_barrier()
+#define rte_cio_wmb() rte_wmb()
+
+#define rte_cio_rmb() rte_rmb()
 
 /*------------------------- 16 bit atomic operations -------------------------*/
 /* To be compatible with Power7, use GCC built-in functions for 16 bit
@@ -109,12 +102,18 @@ rte_atomic16_dec(rte_atomic16_t *v)
 
 static inline int rte_atomic16_inc_and_test(rte_atomic16_t *v)
 {
-       return (__atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0);
+       return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
 }
 
 static inline int rte_atomic16_dec_and_test(rte_atomic16_t *v)
 {
-       return (__atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0);
+       return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0;
+}
+
+static inline uint16_t
+rte_atomic16_exchange(volatile uint16_t *dst, uint16_t val)
+{
+       return __atomic_exchange_2(dst, val, __ATOMIC_SEQ_CST);
 }
 
 /*------------------------- 32 bit atomic operations -------------------------*/
@@ -198,7 +197,7 @@ static inline int rte_atomic32_inc_and_test(rte_atomic32_t *v)
                        : [cnt] "r" (&v->cnt)
                        : "cc", "xer", "memory");
 
-       return (ret == 0);
+       return ret == 0;
 }
 
 static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)
@@ -216,8 +215,15 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v)
                        : [cnt] "r" (&v->cnt)
                        : "cc", "xer", "memory");
 
-       return (ret == 0);
+       return ret == 0;
+}
+
+static inline uint32_t
+rte_atomic32_exchange(volatile uint32_t *dst, uint32_t val)
+{
+       return __atomic_exchange_4(dst, val, __ATOMIC_SEQ_CST);
 }
+
 /*------------------------- 64 bit atomic operations -------------------------*/
 
 static inline int
@@ -387,7 +393,7 @@ static inline int rte_atomic64_inc_and_test(rte_atomic64_t *v)
                        : [cnt] "r" (&v->cnt)
                        : "cc", "xer", "memory");
 
-       return (ret == 0);
+       return ret == 0;
 }
 
 static inline int rte_atomic64_dec_and_test(rte_atomic64_t *v)
@@ -405,14 +411,13 @@ static inline int rte_atomic64_dec_and_test(rte_atomic64_t *v)
                        : [cnt] "r" (&v->cnt)
                        : "cc", "xer", "memory");
 
-       return (ret == 0);
+       return ret == 0;
 }
 
 static inline int rte_atomic64_test_and_set(rte_atomic64_t *v)
 {
        return rte_atomic64_cmpset((volatile uint64_t *)&v->cnt, 0, 1);
 }
-
 /**
  * Atomically set a 64-bit counter to 0.
  *
@@ -423,6 +428,13 @@ static inline void rte_atomic64_clear(rte_atomic64_t *v)
 {
        v->cnt = 0;
 }
+
+static inline uint64_t
+rte_atomic64_exchange(volatile uint64_t *dst, uint64_t val)
+{
+       return __atomic_exchange_4(dst, val, __ATOMIC_SEQ_CST);
+}
+
 #endif
 
 #ifdef __cplusplus