[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT/LIBWAMR PATCH 1/1] libs/wamr: Adding clock_gettime for WAMR running on a Raspberry Pi3 B+
Adding clock_gettime for WAMR running on a Raspberry Pi3 B+. Signed-off-by: Santiago Pagani <santiagopagani@xxxxxxxxx> --- Makefile.uk | 13 ++-- patches/0005-adapt-main-c-to-unikraft.patch | 9 --- patches/0006-clock_gettime.patch | 70 +++++++++++++++++++++ 3 files changed, 77 insertions(+), 15 deletions(-) create mode 100644 patches/0006-clock_gettime.patch diff --git a/Makefile.uk b/Makefile.uk index 7bbf500..2fa59f9 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -97,16 +97,17 @@ LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/runtime/vmcore-wasm/wasm_application LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/runtime/vmcore-wasm/wasm_interp.c LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/runtime/vmcore-wasm/wasm_loader.c LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/runtime/vmcore-wasm/wasm_runtime.c -LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/shared-lib/mem-alloc/bh_memory.c LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/runtime/utils/wasm_log.c -LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/shared-lib/platform/linux/bh_thread.c LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/runtime/utils/wasm_hashmap.c -LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/lib/native/libc/libc_wrapper.c LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/runtime/utils/wasm_dlfcn.c -LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/shared-lib/mem-alloc/mem_alloc.c -LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/shared-lib/platform/linux/bh_platform.c LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/runtime/platform/zephyr/wasm_native.c LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/lib/native/base/base_lib_export.c -LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/products/linux/ext_lib_export.c +LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/lib/native/libc/libc_wrapper.c +LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/lib/app-libs/base/bh_platform.c +LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/shared-lib/mem-alloc/bh_memory.c +LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/shared-lib/mem-alloc/mem_alloc.c LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/shared-lib/mem-alloc/ems/ems_kfc.c LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/shared-lib/mem-alloc/ems/ems_alloc.c +LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/shared-lib/utils/bh_queue.c +LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/shared-lib/platform/linux/bh_thread.c +LIBWAMR_SRCS-y += $(LIBWAMR_SRC)/core/iwasm/products/linux/ext_lib_export.c diff --git a/patches/0005-adapt-main-c-to-unikraft.patch b/patches/0005-adapt-main-c-to-unikraft.patch index c8f73e5..086b7e8 100644 --- a/patches/0005-adapt-main-c-to-unikraft.patch +++ b/patches/0005-adapt-main-c-to-unikraft.patch @@ -9,15 +9,6 @@ static int app_argc; static char **app_argv; -@@ -158,7 +160,7 @@ - return NULL; - } - --#define USE_GLOBAL_HEAP_BUF 0 -+#define USE_GLOBAL_HEAP_BUF 1 - - #if USE_GLOBAL_HEAP_BUF != 0 - static char global_heap_buf[10 * 1024 * 1024] = { 0 }; @@ -177,15 +179,11 @@ int log_verbose_level = 1; #endif diff --git a/patches/0006-clock_gettime.patch b/patches/0006-clock_gettime.patch new file mode 100644 index 0000000..087e81c --- /dev/null +++ b/patches/0006-clock_gettime.patch @@ -0,0 +1,70 @@ +--- a/core/iwasm/lib/app-libs/libc/lib_base.h 2019-09-09 14:51:40.000000000 +0200 ++++ b/core/iwasm/lib/app-libs/libc/lib_base.h 2019-11-07 13:35:38.697247453 +0100 +@@ -37,6 +37,7 @@ + size_t strlen(const char *s); + int strncmp(const char * str1, const char * str2, size_t n); + char *strncpy(char *dest, const char *src, unsigned long n); ++int clock_gettime(clockid_t clk_id, struct timespec *tp); + + #ifdef __cplusplus + } +--- a/core/iwasm/lib/3rdparty/lv_conf.h 2019-12-16 11:31:38.000000000 +0100 ++++ b/core/iwasm/lib/3rdparty/lv_conf.h 2019-12-16 11:31:47.000000000 +0100 +@@ -488,7 +488,7 @@ + /*--END OF LV_CONF_H--*/ + + /*Be sure every define has a default value*/ +-#include "lvgl/src/lv_conf_checker.h" ++//#include "lvgl/src/lv_conf_checker.h" + + #endif /*LV_CONF_H*/ + +--- a/core/iwasm/lib/native/libc/libc_wrapper.c 2019-09-09 14:51:40.000000000 +0200 ++++ b/core/iwasm/lib/native/libc/libc_wrapper.c 2019-11-07 13:35:38.697247453 +0100 +@@ -18,6 +18,10 @@ + #include "wasm_export.h" + #include "wasm_log.h" + #include "wasm_platform_log.h" ++#include <time.h> ++#if CONFIG_PLAT_RASPI ++#include <raspi/time.h> ++#endif + + void + wasm_runtime_set_exception(wasm_module_inst_t module, const char *exception); +@@ -908,6 +912,25 @@ + wasm_runtime_set_exception(module_inst, buf); + } + ++static int ++_clock_gettime_wrapper(clockid_t clk_id, int32 tp_offset) ++{ ++ wasm_module_inst_t module_inst = get_module_inst(); ++ struct timespec *tp_native; ++ ++ if (!validate_app_addr(tp_offset, sizeof(struct timespec *))) ++ return -1; ++ ++ tp_native = addr_app_to_native(tp_offset); ++ #if CONFIG_PLAT_RASPI ++ // When running WAMR on the Raspberry Pi, we add support to WAMR for clock_gettime ++ // using the Raspberry Pi's system timer. Therefore, WAMR will need to include the ++ // raspi/time.h header to use the get_system_timer() function. ++ tp_native->tv_sec = get_system_timer(); ++ #endif ++ return 0; ++} ++ + /*#define ENABLE_SPEC_TEST 1*/ + + #ifdef ENABLE_SPEC_TEST +@@ -969,7 +992,8 @@ + REG_NATIVE_FUNC(env, _emscripten_memcpy_big), + REG_NATIVE_FUNC(env, abort), + REG_NATIVE_FUNC(env, abortStackOverflow), +- REG_NATIVE_FUNC(env, nullFunc_X) ++ REG_NATIVE_FUNC(env, nullFunc_X), ++ REG_NATIVE_FUNC(env, _clock_gettime) + }; + + void* -- 2.17.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |