update wasm support with emscripten compilation; now using sbrk instead of wasm_memory_grow

This commit is contained in:
Daan Leijen 2021-10-01 15:05:01 -07:00
parent 076f815cec
commit 679aad0659
4 changed files with 56 additions and 9 deletions

View file

@ -188,7 +188,7 @@ static bool os_random_buf(void* buf, size_t buf_len) {
#elif defined(ANDROID) || defined(XP_DARWIN) || defined(__APPLE__) || defined(__DragonFly__) || \
defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__sun) || defined(__wasi__)
defined(__sun) // todo: what to use with __wasi__?
#include <stdlib.h>
static bool os_random_buf(void* buf, size_t buf_len) {
arc4random_buf(buf, buf_len);
@ -280,7 +280,9 @@ void _mi_random_init(mi_random_ctx_t* ctx) {
if (!os_random_buf(key, sizeof(key))) {
// if we fail to get random data from the OS, we fall back to a
// weak random source based on the current time
#if !defined(__wasi__)
_mi_warning_message("unable to use secure randomness\n");
#endif
uintptr_t x = _os_random_weak(0);
for (size_t i = 0; i < 8; i++) { // key is eight 32-bit words.
x = _mi_random_shuffle(x);