aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren Hart <dvhltc@us.ibm.com>2009-11-23 13:36:26 -0800
committerDarren Hart <dvhltc@us.ibm.com>2009-11-23 13:36:26 -0800
commit22f0bb5d78af71c74ba6af90345805a2b4782dd6 (patch)
tree09d7ae511f66a90d228213147981243f0db164e3
parente6f351a97480f4e6ed17d379006e654a7c25af23 (diff)
downloadfutextest-22f0bb5d78af71c74ba6af90345805a2b4782dd6.tar.gz
Return futex value from futex atomic operations
Update the futex atomic operations to return the value of the futex after the operation (with the exception of cmpxchg which returns the old value). Update futex_cmpxchg() to return u_int32_t instead of futex_t to avoid compiler warnings regarding the volatile keyword with gcc 4.2 (but not 4.1 or 4.4 oddly enough). Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
-rw-r--r--include/futextest.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/include/futextest.h b/include/futextest.h
index 7fce3db..048500a 100644
--- a/include/futextest.h
+++ b/include/futextest.h
@@ -228,8 +228,10 @@ futex_cmp_requeue_pi(futex_t *uaddr, futex_t val, futex_t *uaddr2, int nr_wake,
*
* Implement cmpxchg using gcc atomic builtins.
* http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
+ *
+ * Return the old futex value.
*/
-static inline futex_t
+static inline u_int32_t
futex_cmpxchg(futex_t *uaddr, u_int32_t oldval, u_int32_t newval)
{
return __sync_val_compare_and_swap(uaddr, oldval, newval);
@@ -238,32 +240,39 @@ futex_cmpxchg(futex_t *uaddr, u_int32_t oldval, u_int32_t newval)
/**
* futex_dec() - atomic decrement of the futex value
* @uaddr: The address of the futex to be modified
+ *
+ * Return the new futex value.
*/
-static inline void
+static inline u_int32_t
futex_dec(futex_t *uaddr)
{
- __sync_sub_and_fetch(uaddr, 1);
+ return __sync_sub_and_fetch(uaddr, 1);
}
/**
* futex_inc() - atomic increment of the futex value
* @uaddr: the address of the futex to be modified
+ *
+ * Return the new futex value.
*/
-static inline void
+static inline u_int32_t
futex_inc(futex_t *uaddr)
{
- __sync_add_and_fetch(uaddr, 1);
+ return __sync_add_and_fetch(uaddr, 1);
}
/**
* futex_set() - atomic decrement of the futex value
* @uaddr: the address of the futex to be modified
* @newval: New value for the atomic_t
+ *
+ * Return the new futex value.
*/
-static inline void
+static inline u_int32_t
futex_set(futex_t *uaddr, u_int32_t newval)
{
*uaddr = newval;
+ return newval;
}
#endif