On Tue, Jun 21, 2016 at 09:36:11AM -0700, Davidlohr Bueso wrote:
> Sorry, I was also missing the _long variants. While at it I added a missing
> ATOMIC_LONG_FETCH_INC_DEC_OP undef.
> 
> --------------8<-----------------------------
> From: Davidlohr Bueso <[email protected]>
> Subject: [PATCH -v3 01/12] locking/atomic: Introduce inc/dec calls for 
> FETCH-OP flavors
> 
> With the inclusion of atomic FETCH-OP variants, many places in the
> kernel can make use of atomic_fetch_$op() to avoid the hacky callers
> that need to compute the value/state _before_ the operation. Peter
> laid out the machinery but we are still missing the simpler dec,inc
> calls (which future patches will make use of).
> 
> This patch only deals with the generic code, as at least right now
> no arch actually implement them -- which is similar to what the
> OP-RETURN primitives currently do.


Would something like so make sense?

---
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -188,15 +188,18 @@
 #endif
 #endif /* atomic_fetch_add_relaxed */
 
-#ifndef atomic_fetch_inc
-#define atomic_fetch_inc(v)  (atomic_fetch_add(1, v))
-#endif
-
 /* atomic_fetch_inc_relaxed */
 #ifndef atomic_fetch_inc_relaxed
+
+#ifndef atomic_fetch_inc
+#define atomic_fetch_inc_relaxed(v)    atomic_fetch_add_relaxed(1, (v))
+#define atomic_fetch_inc_acquire(v)    atomic_fetch_add_acquire(1, (v))
+#define atomic_fetch_inc_release(v)    atomic_fetch_add_release(1, (v))
+#else /* atomic_fetch_inc */
 #define atomic_fetch_inc_relaxed       atomic_fetch_inc
 #define atomic_fetch_inc_acquire       atomic_fetch_inc
 #define atomic_fetch_inc_release       atomic_fetch_inc
+#endif /* atomic_fetch_inc */
 
 #else /* atomic_fetch_inc_relaxed */
 
@@ -235,15 +238,18 @@
 #endif
 #endif /* atomic_fetch_sub_relaxed */
 
-#ifndef atomic_fetch_dec
-#define atomic_fetch_dec(v)  (atomic_fetch_sub(1, v))
-#endif
-
 /* atomic_fetch_dec_relaxed */
 #ifndef atomic_fetch_dec_relaxed
+
+#ifndef atomic_fetch_dec
+#define atomic_fetch_dec_relaxed(v)    atomic_fetch_sub_relaxed(1, (v))
+#define atomic_fetch_dec_acquire(v)    atomic_fetch_sub_acquire(1, (v))
+#define atomic_fetch_dec_release(v)    atomic_fetch_sub_release(1, (v))
+#else /* atomic_fetch_dec */
 #define atomic_fetch_dec_relaxed       atomic_fetch_dec
 #define atomic_fetch_dec_acquire       atomic_fetch_dec
 #define atomic_fetch_dec_release       atomic_fetch_dec
+#endif /* atomic_fetch_dec */
 
 #else /* atomic_fetch_dec_relaxed */
 
@@ -753,9 +759,16 @@ static inline int atomic_dec_if_positive
 
 /* atomic64_fetch_inc_relaxed */
 #ifndef atomic64_fetch_inc_relaxed
+
+#ifndef atomic64_fetch_inc
+#define atomic64_fetch_inc_relaxed(v)  atomic64_fetch_add_relaxed(1, (v))
+#define atomic64_fetch_inc_acquire(v)  atomic64_fetch_add_acquire(1, (v))
+#define atomic64_fetch_inc_release(v)  atomic64_fetch_add_release(1, (v))
+#else /* atomic64_fetch_inc */
 #define atomic64_fetch_inc_relaxed     atomic64_fetch_inc
 #define atomic64_fetch_inc_acquire     atomic64_fetch_inc
 #define atomic64_fetch_inc_release     atomic64_fetch_inc
+#endif /* atomic64_fetch_inc */
 
 #else /* atomic64_fetch_inc_relaxed */
 
@@ -794,15 +807,18 @@ static inline int atomic_dec_if_positive
 #endif
 #endif /* atomic64_fetch_sub_relaxed */
 
-#ifndef atomic64_fetch_dec
-#define atomic64_fetch_dec(v)  (atomic64_fetch_sub(1, v))
-#endif
-
 /* atomic64_fetch_dec_relaxed */
 #ifndef atomic64_fetch_dec_relaxed
+
+#ifndef atomic64_fetch_dec
+#define atomic64_fetch_dec_relaxed(v)  atomic64_fetch_sub_relaxed(1, (v))
+#define atomic64_fetch_dec_acquire(v)  atomic64_fetch_sub_acquire(1, (v))
+#define atomic64_fetch_dec_release(v)  atomic64_fetch_sub_release(1, (v))
+#else /* atomic64_fetch_dec */
 #define atomic64_fetch_dec_relaxed     atomic64_fetch_dec
 #define atomic64_fetch_dec_acquire     atomic64_fetch_dec
 #define atomic64_fetch_dec_release     atomic64_fetch_dec
+#endif /* atomic64_fetch_dec */
 
 #else /* atomic64_fetch_dec_relaxed */
 

Reply via email to