Skip to content

Commit abde052

Browse files
do not use atomicell, as it falls back to atomic u64s
1 parent f41a36c commit abde052

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/sync/atomic.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,31 @@ mod imp {
1212
#[cfg(any(target_arch = "arm", target_arch = "mips", target_arch = "powerpc"))]
1313
mod imp {
1414
use std::sync::atomic::Ordering;
15+
use std::sync::Mutex;
1516

16-
use crossbeam_utils::atomic::AtomicCell;
17-
18-
pub(crate) struct AtomicU64(AtomicCell<u64>);
17+
pub(crate) struct AtomicU64(Mutex<u64>);
1918

2019
impl AtomicU64 {
2120
pub(crate) const fn new(val: u64) -> Self {
22-
Self(AtomicCell::new(val))
21+
Self(Mutex::new(val))
2322
}
2423

2524
pub(crate) fn load(&self, _: Ordering) -> u64 {
26-
self.0.load()
25+
*self.0.lock().unwrap()
2726
}
2827

2928
pub(crate) fn fetch_add(&self, val: u64, _: Ordering) -> u64 {
30-
self.0.fetch_add(val)
29+
let lock = self.0.lock().unwrap();
30+
let prev = *lock;
31+
*lock += val;
32+
prev
3133
}
3234

3335
pub(crate) fn fetch_sub(&self, val: u64, _: Ordering) -> u64 {
34-
self.0.fetch_sub(val)
36+
let lock = self.0.lock().unwrap();
37+
let prev = *lock;
38+
*lock -= val;
39+
prev
3540
}
3641
}
3742
}

0 commit comments

Comments
 (0)