rt: Make the old rand builtins work with newsched
This commit is contained in:
parent
07e52eb7fc
commit
2c1315719d
@ -86,15 +86,10 @@ rand_gen_seed(uint8_t* dest, size_t size) {
|
|||||||
|
|
||||||
extern "C" CDECL void *
|
extern "C" CDECL void *
|
||||||
rand_new_seeded(uint8_t* seed, size_t seed_size) {
|
rand_new_seeded(uint8_t* seed, size_t seed_size) {
|
||||||
rust_task *task = rust_get_current_task();
|
assert(seed != NULL);
|
||||||
rust_rng *rng = (rust_rng *) task->malloc(sizeof(rust_rng),
|
rust_rng *rng = (rust_rng *) malloc(sizeof(rust_rng));
|
||||||
"rand_new_seeded");
|
assert(rng != NULL && "rng alloc failed");
|
||||||
if (!rng) {
|
rng_init(rng, NULL, seed, seed_size);
|
||||||
task->fail();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
char *env_seed = task->kernel->env->rust_seed;
|
|
||||||
rng_init(rng, env_seed, seed, seed_size);
|
|
||||||
return rng;
|
return rng;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,8 +100,7 @@ rand_next(rust_rng *rng) {
|
|||||||
|
|
||||||
extern "C" CDECL void
|
extern "C" CDECL void
|
||||||
rand_free(rust_rng *rng) {
|
rand_free(rust_rng *rng) {
|
||||||
rust_task *task = rust_get_current_task();
|
free(rng);
|
||||||
task->free(rng);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user