File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
library/std/src/sys/hermit Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -76,9 +76,24 @@ pub fn abort_internal() -> ! {
7676 }
7777}
7878
79- // FIXME: just a workaround to test the system
8079pub fn hashmap_random_keys ( ) -> ( u64 , u64 ) {
81- ( 1 , 2 )
80+ let mut buf = [ 0 ; 16 ] ;
81+ let mut slice = & mut buf[ ..] ;
82+ while !slice. is_empty ( ) {
83+ let res = unsafe { abi:: read_entropy ( slice. as_mut_ptr ( ) , slice. len ( ) , 0 ) } ;
84+ if res < 0 {
85+ panic ! (
86+ "random key generation failed: {}" ,
87+ crate :: io:: Error :: from_raw_os_error( -res as i32 )
88+ ) ;
89+ } else {
90+ slice = & mut slice[ res as usize ..] ;
91+ }
92+ }
93+
94+ let key1 = buf[ ..8 ] . try_into ( ) . unwrap ( ) ;
95+ let key2 = buf[ 8 ..] . try_into ( ) . unwrap ( ) ;
96+ ( u64:: from_ne_bytes ( key1) , u64:: from_ne_bytes ( key2) )
8297}
8398
8499// This function is needed by the panic runtime. The symbol is named in
You can’t perform that action at this time.
0 commit comments