[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH v2 14/24] lock.h: locked_decrement()
+ Wenn man schon locked_increment() hat, dann macht sich
locked_decrement() auch ganz gut.
Signed-off-by: Max Reitz <max@xxxxxxxxxx>
---
src/include/lock.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/include/lock.h b/src/include/lock.h
index fc73b3f..89ddb4a 100644
--- a/src/include/lock.h
+++ b/src/include/lock.h
@@ -63,6 +63,16 @@ static inline uint32_t locked_increment(volatile uint32_t* var)
return __sync_fetch_and_add(var, 1);
}
+/**
+ * Eine Variable dekrementieren, während der Bus gesperrt ist.
+ *
+ * @param var Pointer auf die zu dekrementierende Variable
+ */
+static inline uint32_t locked_decrement(volatile uint32_t* var)
+{
+ return __sync_fetch_and_sub(var, 1);
+}
+
/* Mutexe **************************************/
--
2.6.3