diff options
author | gregames <gregames@13f79535-47bb-0310-9956-ffa450edef68> | 2003-12-05 18:57:21 +0000 |
---|---|---|
committer | gregames <gregames@13f79535-47bb-0310-9956-ffa450edef68> | 2003-12-05 18:57:21 +0000 |
commit | 9a9d8b744dfeb517b3f9c9d6bcba5f3d008267c1 (patch) | |
tree | f0d6a661ac5080349332fbd3cff02a044a17b1f6 /atomic | |
parent | acc04390c38cbee098dbd7fbeb57ce392c427ff8 (diff) | |
download | libapr-9a9d8b744dfeb517b3f9c9d6bcba5f3d008267c1.tar.gz |
use an inlined function to eliminate one copy of the xadd assembler code.
You need to specify at least -O1 to enable inlining. That seems fair.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64814 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'atomic')
-rw-r--r-- | atomic/unix/apr_atomic.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/atomic/unix/apr_atomic.c b/atomic/unix/apr_atomic.c index 13c65703d..d596ab7e6 100644 --- a/atomic/unix/apr_atomic.c +++ b/atomic/unix/apr_atomic.c @@ -105,7 +105,8 @@ APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, } #define APR_OVERRIDE_ATOMIC_CAS32 -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val) +static apr_uint32_t inline intel_atomic_add32(volatile apr_uint32_t *mem, + apr_uint32_t val) { asm volatile ("lock; xaddl %1, (%2)" : "=r"(val) /* output, same as 1st input */ @@ -113,6 +114,12 @@ APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint3 : "%1","memory"); /* tell gcc they are clobbered */ return val; } + +APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, + apr_uint32_t val) +{ + return intel_atomic_add32(mem, val); +} #define APR_OVERRIDE_ATOMIC_ADD32 APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val) @@ -141,13 +148,7 @@ APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem) APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem) { - apr_uint32_t val = 1; - - asm volatile ("lock; xaddl %1, (%2)" - : "=r"(val) /* output, same as 1st input */ - : "0"(val), "r"(mem) /* inputs */ - : "%1","memory"); /* tell gcc they are clobbered */ - return val; + return intel_atomic_add32(mem, 1); } #define APR_OVERRIDE_ATOMIC_INC32 |