Skip to content

Commit e7fffad

Browse files
authored
Merge pull request #442 from cr1901/no-atomic
2 parents b81db2f + ba870b2 commit e7fffad

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/float/pow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use int::Int;
55
fn pow<F: Float>(a: F, b: i32) -> F {
66
let mut a = a;
77
let recip = b < 0;
8-
let mut pow = i32::abs_diff(b, 0);
8+
let mut pow = Int::abs_diff(b, 0);
99
let mut mul = F::ONE;
1010
loop {
1111
if (pow & 1) != 0 {

src/mem/impls.rs

+10
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ pub unsafe fn copy_forward(mut dest: *mut u8, mut src: *const u8, mut n: usize)
6262
// Realign src
6363
let mut src_aligned = (src as usize & !WORD_MASK) as *mut usize;
6464
// This will read (but won't use) bytes out of bound.
65+
// cfg needed because not all targets will have atomic loads that can be lowered
66+
// (e.g. BPF, MSP430), or provided by an external library (e.g. RV32I)
67+
#[cfg(target_has_atomic_load_store = "ptr")]
6568
let mut prev_word = core::intrinsics::atomic_load_unordered(src_aligned);
69+
#[cfg(not(target_has_atomic_load_store = "ptr"))]
70+
let mut prev_word = core::ptr::read_volatile(src_aligned);
6671

6772
while dest_usize < dest_end {
6873
src_aligned = src_aligned.add(1);
@@ -155,7 +160,12 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, mut n: usize) {
155160
// Realign src_aligned
156161
let mut src_aligned = (src as usize & !WORD_MASK) as *mut usize;
157162
// This will read (but won't use) bytes out of bound.
163+
// cfg needed because not all targets will have atomic loads that can be lowered
164+
// (e.g. BPF, MSP430), or provided by an external library (e.g. RV32I)
165+
#[cfg(target_has_atomic_load_store = "ptr")]
158166
let mut prev_word = core::intrinsics::atomic_load_unordered(src_aligned);
167+
#[cfg(not(target_has_atomic_load_store = "ptr"))]
168+
let mut prev_word = core::ptr::read_volatile(src_aligned);
159169

160170
while dest_start < dest_usize {
161171
src_aligned = src_aligned.sub(1);

0 commit comments

Comments
 (0)