[PATCH 1/5] asm-generic: atomic: implement atomic_inc/dec_return stubs

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

 



We don't have forced preemption in barebox, so we can implement these
functions with normal increment/decrement operators.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 include/asm-generic/atomic.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
index 6e63b8e8e7b9..45fc5da57594 100644
--- a/include/asm-generic/atomic.h
+++ b/include/asm-generic/atomic.h
@@ -77,16 +77,19 @@ static inline void atomic_sub(int i, volatile atomic_t *v)
 	v->counter -= i;
 }
 
-static inline void atomic_inc(volatile atomic_t *v)
+static inline int atomic_inc_return(volatile atomic_t *v)
 {
-	v->counter += 1;
+	return ++v->counter;
 }
 
-static inline void atomic_dec(volatile atomic_t *v)
+static inline int atomic_dec_return(volatile atomic_t *v)
 {
-	v->counter -= 1;
+	return --v->counter;
 }
 
+#define atomic_inc(v) ((void)atomic_inc_return(v))
+#define atomic_dec(v) ((void)atomic_dec_return(v))
+
 static inline int atomic_dec_and_test(volatile atomic_t *v)
 {
 	int val;
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux