[ovs-dev] [patch v11 5/8] ovs-atomic: Add 64 bit apis.

Darrell Ball dlu998 at gmail.com
Mon Feb 11 01:48:33 UTC 2019


Signed-off-by: Darrell Ball <dlu998 at gmail.com>
---
 lib/ovs-atomic.h | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/lib/ovs-atomic.h b/lib/ovs-atomic.h
index 21e230e..11fa192 100644
--- a/lib/ovs-atomic.h
+++ b/lib/ovs-atomic.h
@@ -479,6 +479,42 @@ atomic_count_set(atomic_count *count, unsigned int value)
     atomic_store_relaxed(&count->count, value);
 }
 
+static inline uint64_t
+atomic_count_inc64(atomic_uint64_t *counter)
+{
+    uint64_t old;
+
+    atomic_add_relaxed(counter, 1ull, &old);
+
+    return old;
+}
+
+static inline uint64_t
+atomic_count_dec64(atomic_uint64_t *counter)
+{
+    uint64_t old;
+
+    atomic_sub_relaxed(counter, 1ull, &old);
+
+    return old;
+}
+
+static inline uint64_t
+atomic_count_get64(atomic_uint64_t *counter)
+{
+    uint64_t value;
+
+    atomic_read_relaxed(counter, &value);
+
+    return value;
+}
+
+static inline void
+atomic_count_set64(atomic_uint64_t *counter, uint64_t value)
+{
+    atomic_store_relaxed(counter, value);
+}
+
 /* Reference count. */
 struct ovs_refcount {
     atomic_uint count;
-- 
1.9.1



More information about the dev mailing list