summaryrefslogtreecommitdiffstats
path: root/library/std/src/sys/hermit/mod.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /library/std/src/sys/hermit/mod.rs
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/std/src/sys/hermit/mod.rs')
-rw-r--r--library/std/src/sys/hermit/mod.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/library/std/src/sys/hermit/mod.rs b/library/std/src/sys/hermit/mod.rs
index d34a4cfed..c7cb84667 100644
--- a/library/std/src/sys/hermit/mod.rs
+++ b/library/std/src/sys/hermit/mod.rs
@@ -15,7 +15,6 @@
#![allow(missing_docs, nonstandard_style, unsafe_op_in_unsafe_fn)]
-use crate::intrinsics;
use crate::os::raw::c_char;
pub mod alloc;
@@ -76,9 +75,18 @@ pub fn abort_internal() -> ! {
}
}
-// FIXME: just a workaround to test the system
pub fn hashmap_random_keys() -> (u64, u64) {
- (1, 2)
+ let mut buf = [0; 16];
+ let mut slice = &mut buf[..];
+ while !slice.is_empty() {
+ let res = cvt(unsafe { abi::read_entropy(slice.as_mut_ptr(), slice.len(), 0) })
+ .expect("failed to generate random hashmap keys");
+ slice = &mut slice[res as usize..];
+ }
+
+ let key1 = buf[..8].try_into().unwrap();
+ let key2 = buf[8..].try_into().unwrap();
+ (u64::from_ne_bytes(key1), u64::from_ne_bytes(key2))
}
// This function is needed by the panic runtime. The symbol is named in