[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [PATCH] include/uk: introduce ukarch_dec



This is a function symmetric to ukarch_inc, which we already have. The
ukarch_dec does atomic decrement, applying a full memory barrier.

Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
 include/uk/arch/atomic.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/uk/arch/atomic.h b/include/uk/arch/atomic.h
index ccd44175..6fae1762 100644
--- a/include/uk/arch/atomic.h
+++ b/include/uk/arch/atomic.h
@@ -57,11 +57,13 @@ extern "C" {
        __atomic_fetch_add(src, value, __ATOMIC_SEQ_CST)
 
 /**
- * Perform a atomic increment operation.
+ * Perform a atomic increment/decrement operation and return the
+ * previous value.
  */
 #define ukarch_inc(src) \
        ukarch_fetch_add(src, 1)
-
+#define ukarch_dec(src) \
+       __atomic_fetch_sub(src, 1, __ATOMIC_SEQ_CST)
 /**
  * Writes *src into *dst, and returns the previous contents of *dst.
  */
-- 
2.19.2


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.