summaryrefslogtreecommitdiff
path: root/atomic/os390
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2003-12-04 20:06:03 +0000
committerJeff Trawick <trawick@apache.org>2003-12-04 20:06:03 +0000
commit5242d89a2e02eef5ce58a83efa411d15126e6613 (patch)
treed37fbaf861b7975ed041d57b63bb7fe57246105d /atomic/os390
parentbcc7f9827c769f74131219696e4049e40c29a5fd (diff)
downloadapr-5242d89a2e02eef5ce58a83efa411d15126e6613.tar.gz
apr_atomic_add32() and apr_atomic_inc32() now return values (the old value)
Submitted by: gregames (all the hard bits) and trawick git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@64808 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'atomic/os390')
-rw-r--r--atomic/os390/atomic.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/atomic/os390/atomic.c b/atomic/os390/atomic.c
index 088759352..3adeb3576 100644
--- a/atomic/os390/atomic.c
+++ b/atomic/os390/atomic.c
@@ -63,24 +63,30 @@ apr_status_t apr_atomic_init(apr_pool_t *p)
return APR_SUCCESS;
}
-void apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
+apr_uint32_t apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
{
apr_uint32_t old, new_val;
old = *mem; /* old is automatically updated on cs failure */
do {
new_val = old + val;
- } while (__cs(&old, (cs_t *)mem, new_val));
+ } while (__cs(&old, (cs_t *)mem, new_val));
+ return old;
}
void apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
{
- apr_atomic_add32(mem, -val);
+ apr_uint32_t old, new_val;
+
+ old = *mem; /* old is automatically updated on cs failure */
+ do {
+ new_val = old - val;
+ } while (__cs(&old, (cs_t *)mem, new_val));
}
-void apr_atomic_inc32(volatile apr_uint32_t *mem)
+apr_uint32_t apr_atomic_inc32(volatile apr_uint32_t *mem)
{
- apr_atomic_add32(mem, 1);
+ return apr_atomic_add32(mem, 1);
}
int apr_atomic_dec32(volatile apr_uint32_t *mem)