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