Support building solana-program on 32-bit architectures that do not (#21577)

have 64-bit atomics by using a Mutex<u64> on 32-bit architectures.

Currently the usage of atomics are only in functions that support
tests and benchmarks.
This commit is contained in:
Jarred Nicholls
2021-12-02 20:18:21 -05:00
committed by GitHub
parent 1ae9cdcb43
commit 18a16ad956
9 changed files with 53 additions and 9 deletions

View File

@@ -104,11 +104,11 @@ impl Hash {
/// unique Hash for tests and benchmarks.
pub fn new_unique() -> Self {
use std::sync::atomic::{AtomicU64, Ordering};
use crate::atomic_u64::AtomicU64;
static I: AtomicU64 = AtomicU64::new(1);
let mut b = [0u8; HASH_BYTES];
let i = I.fetch_add(1, Ordering::Relaxed);
let i = I.fetch_add(1);
b[0..8].copy_from_slice(&i.to_le_bytes());
Self::new(&b)
}