1
Fork 0

Convert pipes to new atomic intrinsics

This commit is contained in:
Ben Blum 2012-08-21 15:18:50 -04:00
parent dc107898b2
commit c47342e7c2

View file

@ -243,39 +243,37 @@ fn entangle_buffer<T: send, Tstart: send>(
#[abi = "rust-intrinsic"] #[abi = "rust-intrinsic"]
#[doc(hidden)] #[doc(hidden)]
extern mod rusti { extern mod rusti {
fn atomic_xchng(&dst: int, src: int) -> int; fn atomic_xchg(dst: &mut int, src: int) -> int;
fn atomic_xchng_acq(&dst: int, src: int) -> int; fn atomic_xchg_acq(dst: &mut int, src: int) -> int;
fn atomic_xchng_rel(&dst: int, src: int) -> int; fn atomic_xchg_rel(dst: &mut int, src: int) -> int;
fn atomic_add_acq(&dst: int, src: int) -> int; fn atomic_xadd_acq(dst: &mut int, src: int) -> int;
fn atomic_sub_rel(&dst: int, src: int) -> int; fn atomic_xsub_rel(dst: &mut int, src: int) -> int;
} }
// If I call the rusti versions directly from a polymorphic function, // If I call the rusti versions directly from a polymorphic function,
// I get link errors. This is a bug that needs investigated more. // I get link errors. This is a bug that needs investigated more.
#[doc(hidden)] #[doc(hidden)]
fn atomic_xchng_rel(dst: &mut int, src: int) -> int { fn atomic_xchng_rel(dst: &mut int, src: int) -> int {
rusti::atomic_xchng_rel(*dst, src) rusti::atomic_xchg_rel(dst, src)
} }
#[doc(hidden)] #[doc(hidden)]
fn atomic_add_acq(dst: &mut int, src: int) -> int { fn atomic_add_acq(dst: &mut int, src: int) -> int {
rusti::atomic_add_acq(*dst, src) rusti::atomic_xadd_acq(dst, src)
} }
#[doc(hidden)] #[doc(hidden)]
fn atomic_sub_rel(dst: &mut int, src: int) -> int { fn atomic_sub_rel(dst: &mut int, src: int) -> int {
rusti::atomic_sub_rel(*dst, src) rusti::atomic_xsub_rel(dst, src)
} }
#[doc(hidden)] #[doc(hidden)]
fn swap_task(dst: &mut *rust_task, src: *rust_task) -> *rust_task { fn swap_task(+dst: &mut *rust_task, src: *rust_task) -> *rust_task {
// It might be worth making both acquire and release versions of // It might be worth making both acquire and release versions of
// this. // this.
unsafe { unsafe {
reinterpret_cast(rusti::atomic_xchng( transmute(rusti::atomic_xchg(transmute(dst), src as int))
*(ptr::mut_addr_of(*dst) as *mut int),
src as int))
} }
} }
@ -309,20 +307,16 @@ fn wait_event(this: *rust_task) -> *libc::c_void {
} }
#[doc(hidden)] #[doc(hidden)]
fn swap_state_acq(dst: &mut state, src: state) -> state { fn swap_state_acq(+dst: &mut state, src: state) -> state {
unsafe { unsafe {
reinterpret_cast(rusti::atomic_xchng_acq( transmute(rusti::atomic_xchg_acq(transmute(dst), src as int))
*(ptr::mut_addr_of(*dst) as *mut int),
src as int))
} }
} }
#[doc(hidden)] #[doc(hidden)]
fn swap_state_rel(dst: &mut state, src: state) -> state { fn swap_state_rel(+dst: &mut state, src: state) -> state {
unsafe { unsafe {
reinterpret_cast(rusti::atomic_xchng_rel( transmute(rusti::atomic_xchg_rel(transmute(dst), src as int))
*(ptr::mut_addr_of(*dst) as *mut int),
src as int))
} }
} }