about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcore/unstable/sync.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libcore/unstable/sync.rs b/src/libcore/unstable/sync.rs
index 734368c70c4..7c228ff5647 100644
--- a/src/libcore/unstable/sync.rs
+++ b/src/libcore/unstable/sync.rs
@@ -205,6 +205,26 @@ extern {
     fn rust_unlock_little_lock(lock: rust_little_lock);
 }
 
+/* *********************************************************************/
+
+//FIXME: #5042 This should be replaced by proper atomic type
+pub struct AtomicUint(uint);
+pub impl AtomicUint {
+    fn load(&self) -> uint {
+        unsafe { intrinsics::atomic_load(cast::transmute(self)) as uint }
+    }
+    fn store(&mut self, val:uint) {
+        unsafe { intrinsics::atomic_store(cast::transmute(self), val as int); }
+    }
+    fn add(&mut self, val:int) -> uint {
+        unsafe { intrinsics::atomic_xadd(cast::transmute(self), val as int) as uint }
+    }
+    fn cas(&self, old:uint, new:uint) -> uint {
+        unsafe { intrinsics::atomic_cxchg(cast::transmute(self), old as int, new as int) as uint }
+    }
+}
+
+
 #[cfg(test)]
 mod tests {
     use comm;