summaryrefslogtreecommitdiff
path: root/atomic
diff options
context:
space:
mode:
authorGreg Ames <gregames@apache.org>2003-12-08 19:49:16 +0000
committerGreg Ames <gregames@apache.org>2003-12-08 19:49:16 +0000
commit410c6b42740adb3a7c7f725d22f148fcfdfd56c8 (patch)
tree57bf78576ff622ffd0c954b81afc10f88ff7d56e /atomic
parent5abe85045383933d8d9c02e28683849f0301f7b7 (diff)
downloadapr-410c6b42740adb3a7c7f725d22f148fcfdfd56c8.tar.gz
add apr_atomic_cas32 for ppc with gcc.
Could someone try this with testatomic on Mac OS X? It should just work, but I couldn't test it. moof no longer likes me. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@64816 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'atomic')
-rw-r--r--atomic/unix/apr_atomic.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/atomic/unix/apr_atomic.c b/atomic/unix/apr_atomic.c
index 19dc3e9e7..65d30bda5 100644
--- a/atomic/unix/apr_atomic.c
+++ b/atomic/unix/apr_atomic.c
@@ -175,6 +175,31 @@ APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint
#endif /* (__linux__ || __EMX__ || __FreeBSD__) && __i386__ */
+#if defined(__PPC__) && defined(__GNUC__) && !APR_FORCE_ATOMIC_GENERIC
+APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem,
+ apr_uint32_t swap,
+ apr_uint32_t cmp)
+{
+ apr_uint32_t prev;
+
+ asm volatile ("retry:\n\t"
+ "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 */
+ "stwcx. %2,0,%1\n\t" /* ...yes, conditionally
+ store swap */
+ "bne- retry\n\t" /* start over if we lost
+ the reservation */
+ "exit:"
+ : "=&r"(prev) /* output */
+ : "r" (mem), "r" (swap), "r"(cmp) /* inputs */
+ : "memory"); /* clobbered */
+ return prev;
+}
+#define APR_OVERRIDE_ATOMIC_CAS32
+
+#endif /* __PPC__ && __GNUC__ */
+
#if !defined(apr_atomic_init) && !defined(APR_OVERRIDE_ATOMIC_INIT)
#if APR_HAS_THREADS