From 7b41991a2509819cb047d701440bb403bf1c2b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berkay=20Din=C3=A7?= Date: Sat, 9 Mar 2024 15:23:45 +0300 Subject: [PATCH 1/5] Implement `replace()` method for `AtomicBox` This implements a method on `AtomicBox` that will allow you to replace the inner value with the given one, and without a closure. --- src/sync/atomics.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sync/atomics.rs b/src/sync/atomics.rs index c389308..d9b6ccb 100644 --- a/src/sync/atomics.rs +++ b/src/sync/atomics.rs @@ -107,6 +107,13 @@ impl AtomicBox { let ptr = Arc::into_raw(Arc::new(new_val)) as *mut T; self.release(ptr); } + + /// + /// Atomically replace the inner value with the given one. + pub fn replace(&self, new_val: T) { + let ptr = Arc::into_raw(Arc::new(new_val)) as *mut T; + self.release(ptr); + } } impl PartialEq for AtomicBox { From 5324d65a9093a9352dc7c22da52d71548f4c9a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berkay=20Din=C3=A7?= Date: Sat, 9 Mar 2024 17:18:08 +0300 Subject: [PATCH 2/5] Use feature flag `portable_simd` instead of `stdsimd` --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f2c1a14..297fe86 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ // Behind the feature gates -#![cfg_attr(feature = "hw", feature(stdsimd))] +#![cfg_attr(feature = "hw", feature(portable_simd))] #![cfg_attr(feature = "hw", feature(llvm_asm))] // FIXME: Baking still #![allow(dead_code)] From d41db294560493b9b9c284a3ec17c8c0897b054d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berkay=20Din=C3=A7?= Date: Sat, 9 Mar 2024 17:32:56 +0300 Subject: [PATCH 3/5] Enable feature flag `stdarch_x86_rtm` --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 297fe86..35411e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ // Behind the feature gates #![cfg_attr(feature = "hw", feature(portable_simd))] #![cfg_attr(feature = "hw", feature(llvm_asm))] +#![cfg_attr(feature = "hw", feature(stdarch_x86_rtm))] // FIXME: Baking still #![allow(dead_code)] #![allow(unused_imports)] From 8410730c960b6843082439232b3e4f9adb558e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berkay=20Din=C3=A7?= Date: Sat, 9 Mar 2024 17:58:29 +0300 Subject: [PATCH 4/5] Remove feature flag `llvm_asm` --- src/htm/ops.rs | 2 +- src/lib.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/htm/ops.rs b/src/htm/ops.rs index 108daf3..cace39f 100644 --- a/src/htm/ops.rs +++ b/src/htm/ops.rs @@ -93,7 +93,7 @@ mod lever_hwtxn_test { pub fn swallow(d: T) -> T { unsafe { - llvm_asm!("" : : "r"(&d)); + core::arch::asm!("" : : "r"(&d)); d } } diff --git a/src/lib.rs b/src/lib.rs index 35411e3..f444e50 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ // Behind the feature gates #![cfg_attr(feature = "hw", feature(portable_simd))] -#![cfg_attr(feature = "hw", feature(llvm_asm))] #![cfg_attr(feature = "hw", feature(stdarch_x86_rtm))] // FIXME: Baking still #![allow(dead_code)] From 73b70886c8a2c91eb5d65189ff87c0dc8431a113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berkay=20Din=C3=A7?= Date: Sat, 9 Mar 2024 18:03:53 +0300 Subject: [PATCH 5/5] Revert "Remove feature flag `llvm_asm`" This reverts commit 8410730c960b6843082439232b3e4f9adb558e32. --- src/htm/ops.rs | 2 +- src/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/htm/ops.rs b/src/htm/ops.rs index cace39f..108daf3 100644 --- a/src/htm/ops.rs +++ b/src/htm/ops.rs @@ -93,7 +93,7 @@ mod lever_hwtxn_test { pub fn swallow(d: T) -> T { unsafe { - core::arch::asm!("" : : "r"(&d)); + llvm_asm!("" : : "r"(&d)); d } } diff --git a/src/lib.rs b/src/lib.rs index f444e50..35411e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ // Behind the feature gates #![cfg_attr(feature = "hw", feature(portable_simd))] +#![cfg_attr(feature = "hw", feature(llvm_asm))] #![cfg_attr(feature = "hw", feature(stdarch_x86_rtm))] // FIXME: Baking still #![allow(dead_code)]