Skip to contentSkip to conversation

asm-generic: fix local_add_unless macro

PATCH In review Roel Kluin 2 participants 5 messages Jan 22, 2009 – May 12, 2009 Generic include/asm header files

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 asm-generic: fix local_add_unless macro

When this macro isn't called with 'a' this will
result in a build failure.

---

include/asm-generic/local.h +1 -1
index dbd6150..fc21844 100644
@@ -42,7 +42,7 @@ typedef struct
 
 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
-#define local_add_unless(l, a, u) atomic_long_add_unless((&(l)->a), (a), (u))
+#define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
 
 /* Non-atomic variants, ie. preemption disabled and won't be touched
#1 lore raw
Quoted 3 lines · * Roel Kluin ([email protected]) wrote:

When this macro isn't called with 'a' this will
result in a build failure.

Can I have a look at the offending calling code and the build failure output ? We might consider changing these for static inlines instead. And clearly, just changing a single primitive is not going to work. We need to address the other similar in the same file at the very least.

Mathieu

Quoted 15 lines

---

include/asm-generic/local.h +1 -1
index dbd6150..fc21844 100644
@@ -42,7 +42,7 @@ typedef struct
 
 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
-#define local_add_unless(l, a, u) atomic_long_add_unless((&(l)->a), (a), (u))
+#define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
 
 /* Non-atomic variants, ie. preemption disabled and won't be touched
Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
Acked-by on v1 1/1
#2 lore raw
In reply to Roel Kluin
Quoted 3 lines · * Roel Kluin ([email protected]) wrote:

When this macro isn't called with 'a' this will
result in a build failure.

Maybe we can add to the changelog, for prople like me who fail to see the obvious :

"because local_add_unless(x, y, z) will be expanded to (&(x)->y, (y), (x)), where (x)->y should be (x)->a.

Thanks,

Quoted 15 lines

---

include/asm-generic/local.h +1 -1
index dbd6150..fc21844 100644
@@ -42,7 +42,7 @@ typedef struct
 
 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
-#define local_add_unless(l, a, u) atomic_long_add_unless((&(l)->a), (a), (u))
+#define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
 
 /* Non-atomic variants, ie. preemption disabled and won't be touched
Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
author
#3 lore raw

PATCH 1/1 asm-generic: fix local_add_unless macro

------------------------------>8-------------8<--------------------------------- local_add_unless(x, y, z)' will be expanded to (&(x)->y, (y), (x))', but &(x)->y' should be &(x)->a'

---
Was this patch lost? it's still not in current git.

include/asm-generic/local.h +1 -1
index dbd6150..fc21844 100644
@@ -42,7 +42,7 @@ typedef struct
 
 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
-#define local_add_unless(l, a, u) atomic_long_add_unless((&(l)->a), (a), (u))
+#define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
 
 /* Non-atomic variants, ie. preemption disabled and won't be touched
Acked-by on v1 1/1
#4 lore raw
Quoted 5 lines · * Roel Kluin ([email protected]) wrote:

------------------------------>8-------------8<--------------------------------- local_add_unless(x, y, z)' will be expanded to (&(x)->y, (y), (x))', but &(x)->y' should be &(x)->a'

It looks good to me.

Quoted 16 lines

---
Was this patch lost? it's still not in current git.

include/asm-generic/local.h +1 -1
index dbd6150..fc21844 100644
@@ -42,7 +42,7 @@ typedef struct
 
 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
-#define local_add_unless(l, a, u) atomic_long_add_unless((&(l)->a), (a), (u))
+#define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
 
 /* Non-atomic variants, ie. preemption disabled and won't be touched
Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68