[python/urandom] Use Ion::random to seed urandom

This commit is contained in:
Léa Saviot
2019-04-17 11:44:57 +02:00
committed by Émilie Feral
parent 447c2f63e1
commit 3a390111d8
3 changed files with 8 additions and 0 deletions

View File

@@ -42,3 +42,7 @@ bool micropython_port_interrupt_if_needed() {
}
return false;
}
int micropython_port_random() {
return Ion::random();
}

View File

@@ -12,6 +12,7 @@ extern "C" {
bool micropython_port_vm_hook_loop();
bool micropython_port_interruptible_msleep(uint32_t delay);
bool micropython_port_interrupt_if_needed();
int micropython_port_random();
#ifdef __cplusplus
}

View File

@@ -89,6 +89,9 @@
// Whether to include: randrange, randint, choice, random, uniform
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
// Function to seed URANDOM with on init
#define MICROPY_PY_URANDOM_SEED_INIT_FUNC micropython_port_random()
// Make a pointer to RAM callable (eg set lower bit for Thumb code)
// (This scheme won't work if we want to mix Thumb and normal ARM code.)
#define MICROPY_MAKE_POINTER_CALLABLE(p) (p)