diff options
author | gregames <gregames@13f79535-47bb-0310-9956-ffa450edef68> | 2003-12-09 22:20:22 +0000 |
---|---|---|
committer | gregames <gregames@13f79535-47bb-0310-9956-ffa450edef68> | 2003-12-09 22:20:22 +0000 |
commit | 2f647796bcc0af0867bbf24b2cfad20825b20957 (patch) | |
tree | 54a7df1b2e3bbd0bda71d4a482be8e971871a926 /atomic | |
parent | 0bedbb3f6e1baa2f766477920a63510befe1843c (diff) | |
download | libapr-2f647796bcc0af0867bbf24b2cfad20825b20957.tar.gz |
ppc + gcc updates
apr_atomic_cas32:
* make sure gcc uses a valid base register (not r0) for mem,
* tell gcc that the condition code is clobbered, and
* use asm local labels to avoid future namespace collisions
apr_atomic_add32: add a native implementation
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64832 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'atomic')
-rw-r--r-- | atomic/unix/apr_atomic.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/atomic/unix/apr_atomic.c b/atomic/unix/apr_atomic.c index 015d2f9e8..65258b22f 100644 --- a/atomic/unix/apr_atomic.c +++ b/atomic/unix/apr_atomic.c @@ -182,22 +182,45 @@ APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, { apr_uint32_t prev; - asm volatile ("retry:\n\t" + asm volatile ("0:\n\t" /* retry local label */ "lwarx %0,0,%1\n\t" /* load prev and reserve */ "cmpw %0,%3\n\t" /* does it match cmp? */ - "bne- exit\n\t" /* ...no, bail out */ + "bne- 1f\n\t" /* ...no, bail out */ "stwcx. %2,0,%1\n\t" /* ...yes, conditionally store swap */ - "bne- retry\n\t" /* start over if we lost + "bne- 0b\n\t" /* start over if we lost the reservation */ - "exit:" + "1:" /* exit local label */ + : "=&r"(prev) /* output */ - : "r" (mem), "r" (swap), "r"(cmp) /* inputs */ - : "memory"); /* clobbered */ + : "b" (mem), "r" (swap), "r"(cmp) /* inputs */ + : "memory", "cc"); /* clobbered */ return prev; } #define APR_OVERRIDE_ATOMIC_CAS32 +APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, + apr_uint32_t delta) +{ + apr_uint32_t prev, temp; + + asm volatile ("0:\n\t" /* retry local label */ + "lwarx %0,0,%2\n\t" /* load prev and reserve */ + "add %1,%0,%3\n\t" /* temp = prev + delta */ + "stwcx. %1,0,%2\n\t" /* conditionally store */ + "bne- 0b" /* start over if we lost + the reservation */ + + /*XXX find a cleaner way to define the temp + * it's not an output + */ + : "=&r" (prev), "=&r" (temp) /* output, temp */ + : "b" (mem), "r" (delta) /* inputs */ + : "memory", "cc"); /* clobbered */ + return prev; +} +#define APR_OVERRIDE_ATOMIC_ADD32 + #endif /* __PPC__ && __GNUC__ */ #if !defined(APR_OVERRIDE_ATOMIC_INIT) |