|
1 | 1 | use crate::sys::pal::abi;
|
2 | 2 |
|
3 | 3 | 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 | +} |
10 | 6 |
|
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 | +// } |
16 | 13 |
|
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