re-org platform APIs, simplify porting process (#201)

Co-authored-by: Xu Jun <jun1.xu@intel.com>
This commit is contained in:
Xu Jun
2020-03-16 16:43:57 +08:00
committed by GitHub
parent ef5ceffe71
commit f1a0e75ab7
177 changed files with 2954 additions and 7904 deletions

View File

@ -388,7 +388,7 @@ sprintf_out(int c, struct str_context *ctx)
static int
printf_out(int c, struct str_context *ctx)
{
bh_printf("%c", c);
os_printf("%c", c);
ctx->count++;
return c;
}
@ -470,13 +470,13 @@ snprintf_wrapper(wasm_exec_env_t exec_env, char *str, uint32 size,
static int
puts_wrapper(wasm_exec_env_t exec_env, const char *str)
{
return bh_printf("%s\n", str);
return os_printf("%s\n", str);
}
static int
putchar_wrapper(wasm_exec_env_t exec_env, int c)
{
bh_printf("%c", c);
os_printf("%c", c);
return 1;
}
@ -908,7 +908,7 @@ static void
llvm_stackrestore_wrapper(wasm_exec_env_t exec_env, uint32 llvm_stack)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
bh_printf("_llvm_stackrestore called!\n");
os_printf("_llvm_stackrestore called!\n");
wasm_runtime_set_llvm_stack(module_inst, llvm_stack);
}
@ -916,7 +916,7 @@ static uint32
llvm_stacksave_wrapper(wasm_exec_env_t exec_env)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
bh_printf("_llvm_stacksave called!\n");
os_printf("_llvm_stacksave called!\n");
return wasm_runtime_get_llvm_stack(module_inst);
}
@ -996,7 +996,7 @@ __cxa_throw_wrapper(wasm_exec_env_t exec_env,
static void
print_i32_wrapper(wasm_exec_env_t exec_env, int32 i32)
{
bh_printf("%d\n", i32);
os_printf("%d\n", i32);
}
#define REG_NATIVE_FUNC(func_name, signature) \
@ -1028,7 +1028,7 @@ static NativeSymbol native_symbols_libc_builtin[] = {
REG_NATIVE_FUNC(exit, "(i)"),
REG_NATIVE_FUNC(strtol, "($*i)i"),
REG_NATIVE_FUNC(strtoul, "($*i)i"),
REG_NATIVE_FUNC(memchr, "(*ii)"),
REG_NATIVE_FUNC(memchr, "(*ii)i"),
REG_NATIVE_FUNC(strncasecmp, "($$i)"),
REG_NATIVE_FUNC(strspn, "($$)i"),
REG_NATIVE_FUNC(strcspn, "($$)i"),

View File

@ -47,6 +47,7 @@
#include "str.h"
#include "bh_common.h"
#include "bh_assert.h"
#if 0 /* TODO: -std=gnu99 causes compile error, comment them first */
// struct iovec must have the same layout as __wasi_iovec_t.