aboutsummaryrefslogtreecommitdiffstats
path: root/include/sys/atomic.h
diff options
context:
space:
mode:
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>2008-08-11 22:42:04 +0000
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>2008-08-11 22:42:04 +0000
commitb61a6e8bdc5ca52a09ff02a6ce2e92742725f8cc (patch)
tree5848193e57d72b0287a019e3b2f1734aa4fa7c3c /include/sys/atomic.h
parent3d061e9d1092364be132fc3f6c478add94b4e482 (diff)
Pull in initial 32-bit support patches.
git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@156 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
Diffstat (limited to 'include/sys/atomic.h')
-rw-r--r--include/sys/atomic.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/include/sys/atomic.h b/include/sys/atomic.h
index 7bb915611..cd0eb3b0a 100644
--- a/include/sys/atomic.h
+++ b/include/sys/atomic.h
@@ -33,6 +33,7 @@ extern "C" {
#include <linux/module.h>
#include <linux/spinlock.h>
+#include <sys/isa_defs.h>
/* XXX: Serialize everything through global locks. This is
* going to be bad for performance, but for now it's the easiest
@@ -133,7 +134,23 @@ atomic_cas_64(volatile uint64_t *target, uint64_t cmp,
return rc;
}
-#if defined(__x86_64__)
+static __inline__ uint32_t
+atomic_cas_32(volatile uint32_t *target, uint32_t cmp,
+ uint32_t newval)
+{
+ uint32_t rc;
+
+ spin_lock(&atomic32_lock);
+ rc = *target;
+ if (*target == cmp)
+ *target = newval;
+
+ spin_unlock(&atomic32_lock);
+
+ return rc;
+}
+
+#ifdef _LP64
/* XXX: Implement atomic_cas_ptr() in terms of uint64'ts. This
* is of course only safe and correct for 64 bit arches... but
* for now I'm OK with that.
@@ -144,6 +161,13 @@ atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
return (void *)atomic_cas_64((volatile uint64_t *)target,
(uint64_t)cmp, (uint64_t)newval);
}
+#else
+static __inline__ void *
+atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
+{
+ return (void *)atomic_cas_32((volatile uint32_t *)target,
+ (uint32_t)cmp, (uint32_t)newval);
+}
#endif
#ifdef __cplusplus