Skip to content

Commit 3864d2d

Browse files
committed
fix: std lib compile
1 parent be4363f commit 3864d2d

File tree

2 files changed

+19
-26
lines changed

2 files changed

+19
-26
lines changed

library/std/src/sys/pal/zkvm/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,3 @@ pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {
6060
pub fn abort_internal() -> ! {
6161
core::intrinsics::abort();
6262
}
63-
64-
pub fn hashmap_random_keys() -> (u64, u64) {
65-
let mut buf = [0u8; 16];
66-
unsafe {
67-
abi::sys_rand(buf.as_mut_ptr(), buf.len());
68-
};
69-
let a = u64::from_le_bytes(buf[0..8].try_into().unwrap());
70-
let b = u64::from_le_bytes(buf[8..16].try_into().unwrap());
71-
(a, b)
72-
}

library/std/src/sys/random/zkvm.rs

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
use crate::sys::pal::abi;
22

33
pub fn fill_bytes(bytes: &mut [u8]) {
4-
let (pre, words, post) = unsafe { bytes.align_to_mut::<u32>() };
5-
if !words.is_empty() {
6-
unsafe {
7-
abi::sys_rand(words.as_mut_ptr(), words.len());
8-
}
9-
}
4+
unsafe { abi::sys_rand(bytes.as_mut_ptr(), bytes.len()) };
5+
}
106

11-
let mut buf = [0u32; 2];
12-
let len = (pre.len() + post.len() + size_of::<u32>() - 1) / size_of::<u32>();
13-
if len != 0 {
14-
unsafe { abi::sys_rand(buf.as_mut_ptr(), len) };
15-
}
7+
// pub fn fill_bytes(bytes: &mut [u8]) {
8+
// let (pre, words, post) = unsafe { bytes.align_to_mut::<u32>() };
9+
// if !words.is_empty() {
10+
// unsafe { abi::sys_rand(words.as_mut_ptr(), words.len()) };
11+
// }
12+
// }
1613

17-
let buf = buf.map(u32::to_ne_bytes);
18-
let buf = buf.as_flattened();
19-
pre.copy_from_slice(&buf[..pre.len()]);
20-
post.copy_from_slice(&buf[pre.len()..pre.len() + post.len()]);
21-
}
14+
// let mut buf = [0u32; 2];
15+
// let len = (pre.len() + post.len() + size_of::<u32>() - 1) / size_of::<u32>();
16+
// if len != 0 {
17+
// unsafe { abi::sys_rand(buf.as_mut_ptr(), len) };
18+
// }
19+
20+
// let buf = buf.map(u32::to_ne_bytes);
21+
// let buf = buf.as_flattened();
22+
// pre.copy_from_slice(&buf[..pre.len()]);
23+
// post.copy_from_slice(&buf[pre.len()..pre.len() + post.len()]);
24+
// }

0 commit comments

Comments
 (0)