libc-emcc: Use alternate method to check getrandom support (#3848)
This commit is contained in:
@ -7,8 +7,13 @@
|
||||
#include "bh_log.h"
|
||||
#include "wasm_export.h"
|
||||
#include "../interpreter/wasm.h"
|
||||
#if !defined(_DEFAULT_SOURCE) && !defined(BH_PLATFORM_LINUX_SGX)
|
||||
#include "sys/syscall.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
|
||||
#define HAVE_SYSCALL_GETRANDOM
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
@ -270,11 +275,10 @@ getentropy_wrapper(wasm_exec_env_t exec_env, void *buffer, uint32 length)
|
||||
{
|
||||
if (buffer == NULL)
|
||||
return -1;
|
||||
#if defined(_DEFAULT_SOURCE) || defined(BH_PLATFORM_LINUX_SGX) \
|
||||
|| defined(__APPLE__)
|
||||
return getentropy(buffer, length);
|
||||
#else
|
||||
#if defined(HAVE_SYSCALL_GETRANDOM)
|
||||
return syscall(SYS_getrandom, buffer, length, 0);
|
||||
#else
|
||||
return getentropy(buffer, length);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user