Skip to content

Commit e2fc6dc

Browse files
committed
implement (shimmed) std::random
1 parent 22a2217 commit e2fc6dc

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pub mod alloc;
21
#[path = "../unsupported/args.rs"]
32
pub mod args;
43
pub mod env;
@@ -19,7 +18,6 @@ pub mod thread;
1918
pub mod time;
2019

2120
use crate::arch::global_asm;
22-
use crate::hash::{DefaultHasher, Hasher};
2321
use crate::ptr::{self, addr_of_mut};
2422
use crate::time::{Duration, Instant};
2523

@@ -55,11 +53,6 @@ pub unsafe extern "C" fn _start() -> ! {
5553

5654
main();
5755

58-
unsafe {
59-
crate::sys::thread_local::destructors::run();
60-
}
61-
crate::rt::thread_cleanup();
62-
6356
abort_internal()
6457
}
6558

@@ -127,17 +120,3 @@ pub fn abort_internal() -> ! {
127120
crate::hint::spin_loop()
128121
}
129122
}
130-
131-
fn hash_time() -> u64 {
132-
let mut hasher = DefaultHasher::new();
133-
// The closest we can get to a random number is the time since program start
134-
let time = unsafe { vex_sdk::vexSystemHighResTimeGet() };
135-
hasher.write_u64(time);
136-
hasher.finish()
137-
}
138-
139-
pub fn hashmap_random_keys() -> (u64, u64) {
140-
let key1 = hash_time();
141-
let key2 = hash_time();
142-
(key1, key2)
143-
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ cfg_if::cfg_if! {
7373
} else if #[cfg(any(
7474
all(target_family = "wasm", target_os = "unknown"),
7575
target_os = "xous",
76+
target_os = "vexos",
7677
))] {
7778
// FIXME: finally remove std support for wasm32-unknown-unknown
7879
// FIXME: add random data generation to xous
@@ -86,6 +87,7 @@ cfg_if::cfg_if! {
8687
target_os = "android",
8788
all(target_family = "wasm", target_os = "unknown"),
8889
target_os = "xous",
90+
target_os = "vexos",
8991
)))]
9092
pub fn hashmap_random_keys() -> (u64, u64) {
9193
let mut buf = [0; 16];

0 commit comments

Comments
 (0)