From 5e2011ca1d03d2499b00e423f2eeccf221a2370c Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Thu, 14 Mar 2024 21:31:44 +0800 Subject: [PATCH] Fix compilation errors on esp-idf platform (#3224) The issue was reported in #3208. --- core/iwasm/interpreter/wasm_loader.c | 2 +- core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c | 2 +- core/shared/platform/esp-idf/espidf_memmap.c | 6 ++++++ core/shared/platform/esp-idf/espidf_platform.c | 6 +++--- core/shared/platform/esp-idf/platform_internal.h | 6 ++++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 0f23e48b6..3edd7ff5c 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -11421,7 +11421,7 @@ re_scan: case WASM_OP_BR_TABLE: { - uint32 depth, default_arity, arity = 0; + uint32 depth = 0, default_arity, arity = 0; BranchBlock *target_block; BlockType *target_block_type; #if WASM_ENABLE_FAST_INTERP == 0 diff --git a/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c b/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c index fe99cabe7..7aa3444f9 100644 --- a/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c +++ b/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c @@ -426,7 +426,7 @@ sprintf_wrapper(wasm_exec_env_t exec_env, char *str, const char *format, if (!wasm_runtime_get_native_addr_range(module_inst, (uint8 *)str, NULL, &native_end_offset)) { wasm_runtime_set_exception(module_inst, "out of bounds memory access"); - return false; + return 0; } ctx.str = str; diff --git a/core/shared/platform/esp-idf/espidf_memmap.c b/core/shared/platform/esp-idf/espidf_memmap.c index 9f3ec47a6..6b1b6f045 100644 --- a/core/shared/platform/esp-idf/espidf_memmap.c +++ b/core/shared/platform/esp-idf/espidf_memmap.c @@ -59,6 +59,12 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) } } +void * +os_mremap(void *old_addr, size_t old_size, size_t new_size) +{ + return os_mremap_slow(old_addr, old_size, new_size); +} + void os_munmap(void *addr, size_t size) { diff --git a/core/shared/platform/esp-idf/espidf_platform.c b/core/shared/platform/esp-idf/espidf_platform.c index 8d3a9b87c..9c0d02e62 100644 --- a/core/shared/platform/esp-idf/espidf_platform.c +++ b/core/shared/platform/esp-idf/espidf_platform.c @@ -234,7 +234,7 @@ unlinkat(int fd, const char *path, int flag) } int -utimensat(int fd, const char *path, const struct timespec *ts, int flag) +utimensat(int fd, const char *path, const struct timespec ts[2], int flag) { errno = ENOSYS; return -1; @@ -257,7 +257,7 @@ ftruncate(int fd, off_t length) #endif int -futimens(int fd, const struct timespec *times) +futimens(int fd, const struct timespec times[2]) { errno = ENOSYS; return -1; @@ -268,4 +268,4 @@ nanosleep(const struct timespec *req, struct timespec *rem) { errno = ENOSYS; return -1; -} \ No newline at end of file +} diff --git a/core/shared/platform/esp-idf/platform_internal.h b/core/shared/platform/esp-idf/platform_internal.h index 70c4fe7b1..0f873810e 100644 --- a/core/shared/platform/esp-idf/platform_internal.h +++ b/core/shared/platform/esp-idf/platform_internal.h @@ -109,6 +109,12 @@ typedef unsigned int korp_sem; #define DT_LNK DTYPE_LINK #define DT_SOCK DTYPE_SOCK +static inline int +os_getpagesize() +{ + return 4096; +} + typedef int os_file_handle; typedef DIR *os_dir_stream; typedef int os_raw_file_handle;