Implement clock() wrapper for built-in libc (#691)

This commit is contained in:
Huang Qi 2021-08-07 21:21:25 +08:00 committed by GitHub
parent 0db04e0b8f
commit 8fd89bd415
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1090,6 +1090,14 @@ clock_gettime_wrapper(wasm_exec_env_t exec_env,
return (uint32)0;
}
static uint64
clock_wrapper(wasm_exec_env_t exec_env)
{
/* Convert to nano seconds as CLOCKS_PER_SEC in wasi-sdk */
return os_time_get_boot_microsecond() * 1000;
}
#if WASM_ENABLE_SPEC_TEST != 0
static void
print_wrapper(wasm_exec_env_t exec_env)
@ -1190,6 +1198,7 @@ static NativeSymbol native_symbols_libc_builtin[] = {
REG_NATIVE_FUNC(__cxa_begin_catch, "(*)"),
REG_NATIVE_FUNC(__cxa_throw, "(**i)"),
REG_NATIVE_FUNC(clock_gettime, "(i*)i"),
REG_NATIVE_FUNC(clock, "()I"),
};
#if WASM_ENABLE_SPEC_TEST != 0