Change wasm app offset type from int32 to uint32 (#361)
And fix some sign/unsigned conversion compilation warnings.
This commit is contained in:
@ -321,10 +321,10 @@ handle_1_to_9:
|
||||
case 's': {
|
||||
char *s;
|
||||
char *start;
|
||||
int32 s_offset;
|
||||
uint32 s_offset;
|
||||
|
||||
CHECK_VA_ARG(ap, int32);
|
||||
s_offset = _va_arg(ap, int32);
|
||||
s_offset = _va_arg(ap, uint32);
|
||||
|
||||
if (!validate_app_str_addr(s_offset)) {
|
||||
return false;
|
||||
@ -494,13 +494,13 @@ putchar_wrapper(wasm_exec_env_t exec_env, int c)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
strdup_wrapper(wasm_exec_env_t exec_env, const char *str)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
char *str_ret;
|
||||
uint32 len;
|
||||
int32 str_ret_offset = 0;
|
||||
uint32 str_ret_offset = 0;
|
||||
|
||||
/* str has been checked by runtime */
|
||||
if (str) {
|
||||
@ -515,7 +515,7 @@ strdup_wrapper(wasm_exec_env_t exec_env, const char *str)
|
||||
return str_ret_offset;
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
_strdup_wrapper(wasm_exec_env_t exec_env, const char *str)
|
||||
{
|
||||
return strdup_wrapper(exec_env, str);
|
||||
@ -534,12 +534,12 @@ memcmp_wrapper(wasm_exec_env_t exec_env,
|
||||
return memcmp(s1, s2, size);
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
memcpy_wrapper(wasm_exec_env_t exec_env,
|
||||
void *dst, const void *src, uint32 size)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
int32 dst_offset = addr_native_to_app(dst);
|
||||
uint32 dst_offset = addr_native_to_app(dst);
|
||||
|
||||
if (size == 0)
|
||||
return dst_offset;
|
||||
@ -552,12 +552,12 @@ memcpy_wrapper(wasm_exec_env_t exec_env,
|
||||
return dst_offset;
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
memmove_wrapper(wasm_exec_env_t exec_env,
|
||||
void *dst, void *src, uint32 size)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
int32 dst_offset = addr_native_to_app(dst);
|
||||
uint32 dst_offset = addr_native_to_app(dst);
|
||||
|
||||
if (size == 0)
|
||||
return dst_offset;
|
||||
@ -570,12 +570,12 @@ memmove_wrapper(wasm_exec_env_t exec_env,
|
||||
return dst_offset;
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
memset_wrapper(wasm_exec_env_t exec_env,
|
||||
void *s, int32 c, uint32 size)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
int32 s_offset = addr_native_to_app(s);
|
||||
uint32 s_offset = addr_native_to_app(s);
|
||||
|
||||
if (!validate_native_addr(s, size))
|
||||
return s_offset;
|
||||
@ -584,7 +584,7 @@ memset_wrapper(wasm_exec_env_t exec_env,
|
||||
return s_offset;
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
strchr_wrapper(wasm_exec_env_t exec_env,
|
||||
const char *s, int32 c)
|
||||
{
|
||||
@ -617,7 +617,7 @@ strncmp_wrapper(wasm_exec_env_t exec_env,
|
||||
return strncmp(s1, s2, size);
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
strcpy_wrapper(wasm_exec_env_t exec_env, char *dst, const char *src)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
@ -631,7 +631,7 @@ strcpy_wrapper(wasm_exec_env_t exec_env, char *dst, const char *src)
|
||||
return addr_native_to_app(dst);
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
strncpy_wrapper(wasm_exec_env_t exec_env,
|
||||
char *dst, const char *src, uint32 size)
|
||||
{
|
||||
@ -652,19 +652,19 @@ strlen_wrapper(wasm_exec_env_t exec_env, const char *s)
|
||||
return (uint32)strlen(s);
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
malloc_wrapper(wasm_exec_env_t exec_env, uint32 size)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
return module_malloc(size, NULL);
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
calloc_wrapper(wasm_exec_env_t exec_env, uint32 nmemb, uint32 size)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
uint64 total_size = (uint64) nmemb * (uint64) size;
|
||||
int32 ret_offset = 0;
|
||||
uint32 ret_offset = 0;
|
||||
uint8 *ret_ptr;
|
||||
|
||||
if (total_size >= UINT32_MAX)
|
||||
@ -672,7 +672,7 @@ calloc_wrapper(wasm_exec_env_t exec_env, uint32 nmemb, uint32 size)
|
||||
|
||||
ret_offset = module_malloc((uint32)total_size, (void**)&ret_ptr);
|
||||
if (ret_offset) {
|
||||
memset(ret_ptr, 0, (uint32) total_size);
|
||||
memset(ret_ptr, 0, (uint32)total_size);
|
||||
}
|
||||
|
||||
return ret_offset;
|
||||
@ -717,7 +717,7 @@ strtol_wrapper(wasm_exec_env_t exec_env,
|
||||
return 0;
|
||||
|
||||
num = (int32)strtol(nptr, endptr, base);
|
||||
*(int32*)endptr = addr_native_to_app(*endptr);
|
||||
*(uint32*)endptr = addr_native_to_app(*endptr);
|
||||
|
||||
return num;
|
||||
}
|
||||
@ -734,12 +734,12 @@ strtoul_wrapper(wasm_exec_env_t exec_env,
|
||||
return 0;
|
||||
|
||||
num = (uint32)strtoul(nptr, endptr, base);
|
||||
*(int32 *)endptr = addr_native_to_app(*endptr);
|
||||
*(uint32 *)endptr = addr_native_to_app(*endptr);
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
memchr_wrapper(wasm_exec_env_t exec_env,
|
||||
const void *s, int32 c, uint32 n)
|
||||
{
|
||||
@ -755,7 +755,7 @@ memchr_wrapper(wasm_exec_env_t exec_env,
|
||||
|
||||
static int32
|
||||
strncasecmp_wrapper(wasm_exec_env_t exec_env,
|
||||
const char *s1, const char *s2, int32 n)
|
||||
const char *s1, const char *s2, uint32 n)
|
||||
{
|
||||
/* s1 and s2 have been checked by runtime */
|
||||
return strncasecmp(s1, s2, n);
|
||||
@ -777,7 +777,7 @@ strcspn_wrapper(wasm_exec_env_t exec_env,
|
||||
return (uint32)strcspn(s, reject);
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
strstr_wrapper(wasm_exec_env_t exec_env,
|
||||
const char *s, const char *find)
|
||||
{
|
||||
@ -934,12 +934,12 @@ llvm_stacksave_wrapper(wasm_exec_env_t exec_env)
|
||||
return wasm_runtime_get_llvm_stack(module_inst);
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
emscripten_memcpy_big_wrapper(wasm_exec_env_t exec_env,
|
||||
void *dst, const void *src, uint32 size)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
int32 dst_offset = addr_native_to_app(dst);
|
||||
uint32 dst_offset = addr_native_to_app(dst);
|
||||
|
||||
/* src has been checked by runtime */
|
||||
if (!validate_native_addr(dst, size))
|
||||
@ -976,12 +976,12 @@ nullFunc_X_wrapper(wasm_exec_env_t exec_env, int32 code)
|
||||
wasm_runtime_set_exception(module_inst, buf);
|
||||
}
|
||||
|
||||
static int32
|
||||
static uint32
|
||||
__cxa_allocate_exception_wrapper(wasm_exec_env_t exec_env,
|
||||
uint32 thrown_size)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
int32 exception = module_malloc(thrown_size, NULL);
|
||||
uint32 exception = module_malloc(thrown_size, NULL);
|
||||
if (!exception)
|
||||
return 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user