Skip to content

Commit

Permalink
Use :e registers on x32
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 committed Nov 16, 2021
1 parent 4c561d8 commit f35f0b4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/elision.rs
Expand Up @@ -56,6 +56,16 @@ impl AtomicElisionExt for AtomicUsize {
fn elision_compare_exchange_acquire(&self, current: usize, new: usize) -> Result<usize, usize> {
unsafe {
let prev: usize;
#[cfg(target_pointer_width = "32")]
asm!(
"xacquire",
"lock",
"cmpxchg [{:e}], {:e}",
in(reg) self,
in(reg) new,
inout("eax") current => prev,
);
#[cfg(target_pointer_width = "64")]
asm!(
"xacquire",
"lock",
Expand All @@ -76,6 +86,15 @@ impl AtomicElisionExt for AtomicUsize {
fn elision_fetch_sub_release(&self, val: usize) -> usize {
unsafe {
let prev: usize;
#[cfg(target_pointer_width = "32")]
asm!(
"xrelease",
"lock",
"xadd [{:e}], {:e}",
in(reg) self,
inout(reg) val.wrapping_neg() => prev,
);
#[cfg(target_pointer_width = "64")]
asm!(
"xrelease",
"lock",
Expand Down

0 comments on commit f35f0b4

Please sign in to comment.