diff options
author | Brian Pane <brianp@apache.org> | 2002-09-22 04:17:02 +0000 |
---|---|---|
committer | Brian Pane <brianp@apache.org> | 2002-09-22 04:17:02 +0000 |
commit | a220c69fe7725fb7c4e671b9bcdf69b8f36629bf (patch) | |
tree | 50218e3cfdb9f8a8f764547922974359e7ab9f38 /include/apr_atomic.h | |
parent | 9c28608c168e91802976b5f0c6befbc0b603da16 (diff) | |
download | apr-a220c69fe7725fb7c4e671b9bcdf69b8f36629bf.tar.gz |
Inline, mutex-free implementations of the rest of the atomic
functions for Linux/x86.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63881 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include/apr_atomic.h')
-rw-r--r-- | include/apr_atomic.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/apr_atomic.h b/include/apr_atomic.h index bddbd2579..9a3eb43c3 100644 --- a/include/apr_atomic.h +++ b/include/apr_atomic.h @@ -191,6 +191,31 @@ APR_DECLARE(int) apr_atomic_dec(apr_atomic_t *mem); : "memory"); \ prev;}) +#define apr_atomic_add(mem, val) \ +({ register apr_atomic_t last; \ + do { \ + last = *(mem); \ + } while (apr_atomic_cas((mem), last + (val), last) != last); \ + }) + +#define apr_atomic_dec(mem) \ +({ register apr_atomic_t last; \ + do { \ + last = *(mem); \ + } while (apr_atomic_cas((mem), last - 1, last) != last); \ + (--last != 0); }) + +#define apr_atomic_inc(mem) \ +({ register apr_atomic_t last; \ + do { \ + last = *(mem); \ + } while (apr_atomic_cas((mem), last + 1, last) != last); \ + }) + +#define apr_atomic_set(mem, val) (*(mem) = val) +#define apr_atomic_read(mem) (*(mem)) +#define apr_atomic_init(pool) APR_SUCCESS + #elif (defined(__sparc__) || defined(sparc)) && !APR_FORCE_ATOMIC_GENERIC #define apr_atomic_t apr_uint32_t |