From 9489d26b3b669b37376d9d51b305a37a01a32520 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Wed, 11 Mar 2026 18:08:48 +0100 Subject: [PATCH] baremetal: remove unnecessary functions --- .../shared/platform/baremetal/platform_init.c | 98 +++---------------- .../platform/baremetal/platform_internal.h | 17 ++-- .../platform/baremetal/shared_platform.cmake | 2 - 3 files changed, 17 insertions(+), 100 deletions(-) diff --git a/core/shared/platform/baremetal/platform_init.c b/core/shared/platform/baremetal/platform_init.c index ffdccc59..fa1db213 100644 --- a/core/shared/platform/baremetal/platform_init.c +++ b/core/shared/platform/baremetal/platform_init.c @@ -10,89 +10,29 @@ os_icache_flush(void *start, size_t len) { } -int -os_cond_init(korp_cond *cond) -{ - return 0; -} - -int -os_cond_destroy(korp_cond *cond) -{ - return 0; -} - -int -os_dumps_proc_mem_info(char *out, unsigned int size) -{ - return -1; -} - -__attribute__((weak)) void -bh_print_proc_mem(const char *prompt) -{ -} - -__attribute__((weak)) void -bh_log_proc_mem(const char *function, uint32 line) -{ -} - -/**************************************************** - * string - ****************************************************/ - -// void * -// memcpy(void *restrict dest, const void *restrict src, size_t n) +// int +// os_cond_init(korp_cond *cond) // { -// unsigned char *d = (unsigned char *)dest; -// const unsigned char *s = (const unsigned char *)src; -// -// while (n--) -// *d++ = *s++; -// -// return dest; +// return 0; // } // -// void * -// memmove(void *dest, const void *src, size_t n) +// int +// os_cond_destroy(korp_cond *cond) // { -// unsigned char *d = (unsigned char *)dest; -// const unsigned char *s = (const unsigned char *)src; -// -// if (d == s || n == 0) -// return dest; -// -// if (d < s) { -// /* forward copy */ -// while (n--) -// *d++ = *s++; -// } -// else { -// /* backward copy */ -// d += n; -// s += n; -// while (n--) -// *--d = *--s; -// } -// -// return dest; +// return 0; // } // -// void * -// memset(void *dest, int c, size_t n) +// int +// os_dumps_proc_mem_info(char *out, unsigned int size) // { -// unsigned char *p = dest; -// while (n--) -// *p++ = (unsigned char)c; -// return dest; +// return -1; // } /**************************************************** * mman ****************************************************/ -// NOTE: We need os_mmap for aot_load_from_aot_file +// Need os_mmap for aot_load_from_aot_file // // Stacktrace: // #5 0x0805e5c1 in os_mmap @@ -104,7 +44,7 @@ bh_log_proc_mem(const char *function, uint32 line) // #11 0x08048cff in wasm_runtime_load // #12 0x08048112 in main -#define MMAP_SPACE_SIZE (2 * 1024 * 1024) +// I hope this isn't too simple static uint8_t mmap_space[MMAP_SPACE_SIZE]; static size_t mmap_offset = 0; // Free space begins here @@ -166,22 +106,6 @@ os_mprotect(void *addr, size_t size, int prot) return 0; } -/**************************************************** - * math - ****************************************************/ - -double -sqrt(double x) -{ - return 0.0; -} - -float -sqrtf(float x) -{ - return 0.0; -} - /**************************************************** * Section 1 * * Interfaces required by the runtime * diff --git a/core/shared/platform/baremetal/platform_internal.h b/core/shared/platform/baremetal/platform_internal.h index 615d79f7..f8de71c8 100644 --- a/core/shared/platform/baremetal/platform_internal.h +++ b/core/shared/platform/baremetal/platform_internal.h @@ -3,13 +3,14 @@ #include #include -// #include -// #include #include #include #include #include #include + +// #include +// #include // #include // #include // #include @@ -42,6 +43,9 @@ extern "C" { #define BH_APPLET_PRESERVED_STACK_SIZE (8 * 1024) #define BH_THREAD_DEFAULT_PRIORITY 0 +#define PAGE_SIZE 4096 +#define MMAP_SPACE_SIZE (2 * 1024 * 1024) + typedef int korp_tid; typedef struct { int dummy; @@ -74,21 +78,12 @@ os_get_invalid_handle(void) return -1; } -#define PAGE_SIZE 4096 - static inline int os_getpagesize() { return PAGE_SIZE; } -// void * -// memcpy(void *restrict dest, const void *restrict src, size_t n); -// void * -// memmove(void *dest, const void *src, size_t n); -// void * -// memset(void *dest, int c, size_t n); - #ifdef __cplusplus } #endif diff --git a/core/shared/platform/baremetal/shared_platform.cmake b/core/shared/platform/baremetal/shared_platform.cmake index 6c0d3db3..e0203ef3 100644 --- a/core/shared/platform/baremetal/shared_platform.cmake +++ b/core/shared/platform/baremetal/shared_platform.cmake @@ -5,8 +5,6 @@ add_definitions(-DBH_PLATFORM_BAREMETAL) include_directories(${PLATFORM_SHARED_DIR}) include_directories(${PLATFORM_SHARED_DIR}/../include) -# file (GLOB header ${PLATFORM_SHARED_DIR}/../include/baremetal/*.h) -# list (APPEND RUNTIME_LIB_HEADER_LIST ${header}) file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c) set (PLATFORM_SHARED_SOURCE ${source_all})