Add emscripten_sleep() wrapper to libc-emcc (#3669)
This commit is contained in:
@ -495,6 +495,24 @@ emscripten_notify_memory_growth_wrapper(wasm_exec_env_t exec_env, int i)
|
||||
(void)i;
|
||||
}
|
||||
|
||||
static void
|
||||
emscripten_sleep_wrapper(wasm_exec_env_t exec_env, int timeout_ms)
|
||||
{
|
||||
unsigned int sec;
|
||||
useconds_t us;
|
||||
|
||||
if (timeout_ms <= 0)
|
||||
return;
|
||||
|
||||
sec = timeout_ms / 1000;
|
||||
us = (timeout_ms % 1000) * 1000;
|
||||
|
||||
if (sec > 0)
|
||||
sleep(sec);
|
||||
if (us > 0)
|
||||
usleep(us);
|
||||
}
|
||||
|
||||
static void
|
||||
emscripten_thread_sleep_wrapper(wasm_exec_env_t exec_env, double timeout_ms)
|
||||
{
|
||||
@ -544,6 +562,7 @@ static NativeSymbol native_symbols_libc_emcc[] = {
|
||||
REG_NATIVE_FUNC(__sys_getcwd, "(*~)i"),
|
||||
REG_NATIVE_FUNC(__sys_uname, "(*)i"),
|
||||
REG_NATIVE_FUNC(emscripten_notify_memory_growth, "(i)"),
|
||||
REG_NATIVE_FUNC(emscripten_sleep, "(i)"),
|
||||
REG_NATIVE_FUNC(emscripten_thread_sleep, "(F)"),
|
||||
#endif /* end of BH_PLATFORM_LINUX_SGX */
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user