summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread
diff options
context:
space:
mode:
Diffstat (limited to 'fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread')
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/SConscript34
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/platform_internal.h48
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/rtt_platform.c209
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/shared_platform.cmake19
4 files changed, 310 insertions, 0 deletions
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/SConscript b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/SConscript
new file mode 100644
index 000000000..1e93f4755
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/SConscript
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 2021, RT-Thread Development Team
+#
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+
+from building import *
+import os
+
+cwd = GetCurrentDir()
+
+src = Split('''
+''')
+
+
+def addSrcFiles(arr, path):
+ for f in os.listdir(path):
+ fpath = os.path.join(path, f);
+ if os.path.isfile(fpath):
+ ext = os.path.splitext(fpath)[-1]
+ if ext == '.c' or ext == '.cpp':
+ arr += [fpath]
+ elif os.path.isdir(fpath):
+ addSrcFiles(arr, fpath)
+
+
+
+addSrcFiles(src, cwd);
+CPPPATH = [cwd, cwd+'/../include']
+
+group = DefineGroup('iwasm_platform_core', src, depend = [''], CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/platform_internal.h b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/platform_internal.h
new file mode 100644
index 000000000..5f9cc8bc8
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/platform_internal.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#ifndef RTTHREAD_PLATFORM_INTERNAL_H
+#define RTTHREAD_PLATFORM_INTERNAL_H
+
+#include <rtthread.h>
+#include <stdbool.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <stdint.h>
+#include <ctype.h>
+
+#if defined(WASM_ENABLE_AOT)
+#if defined(RTT_WAMR_BUILD_TARGET_THUMB)
+#define BUILD_TARGET "thumbv4t"
+#elif defined(RTT_WAMR_BUILD_TARGET_ARMV7)
+#define BUILD_TARGET "armv7"
+#elif defined(RTT_WAMR_BUILD_TARGET_ARMV6)
+#define BUILD_TARGET "armv6"
+#elif defined(RTT_WAMR_BUILD_TARGET_ARMV4)
+#define BUILD_TARGET "armv4"
+#elif defined(RTT_WAMR_BUILD_TARGET_X86_32)
+#define BUILD_TARGET "X86_32"
+#else
+#error "unsupported aot platform."
+#endif
+#endif /* WASM_ENABLE_AOT */
+
+typedef rt_thread_t korp_tid;
+typedef struct rt_mutex korp_mutex;
+typedef struct rt_thread korp_cond;
+typedef struct rt_thread korp_thread;
+typedef unsigned int korp_sem;
+
+typedef rt_uint8_t uint8_t;
+typedef rt_int8_t int8_t;
+typedef rt_uint16_t uint16_t;
+typedef rt_int16_t int16_t;
+typedef rt_uint64_t uint64_t;
+typedef rt_int64_t int64_t;
+
+#endif /* RTTHREAD_PLATFORM_INTERNAL_H */
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/rtt_platform.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/rtt_platform.c
new file mode 100644
index 000000000..4685e1ea3
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/rtt_platform.c
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include <platform_api_vmcore.h>
+#include <platform_api_extension.h>
+
+typedef struct os_malloc_list {
+ void *real;
+ void *used;
+ rt_list_t node;
+} os_malloc_list_t;
+
+int
+bh_platform_init(void)
+{
+ return 0;
+}
+
+void
+bh_platform_destroy(void)
+{}
+
+void *
+os_malloc(unsigned size)
+{
+ void *buf_origin;
+ void *buf_fixed;
+ rt_ubase_t *addr_field;
+
+ buf_origin = rt_malloc(size + 8 + sizeof(rt_ubase_t));
+ buf_fixed = buf_origin + sizeof(void *);
+ if ((rt_ubase_t)buf_fixed & 0x7) {
+ buf_fixed = (void *)((rt_ubase_t)(buf_fixed + 8) & (~7));
+ }
+
+ addr_field = buf_fixed - sizeof(rt_ubase_t);
+ *addr_field = (rt_ubase_t)buf_origin;
+
+ return buf_fixed;
+}
+
+void *
+os_realloc(void *ptr, unsigned size)
+{
+
+ void *mem_origin;
+ void *mem_new;
+ void *mem_new_fixed;
+ rt_ubase_t *addr_field;
+
+ if (!ptr) {
+ return RT_NULL;
+ }
+
+ addr_field = ptr - sizeof(rt_ubase_t);
+ mem_origin = (void *)(*addr_field);
+ mem_new = rt_realloc(mem_origin, size + 8 + sizeof(rt_ubase_t));
+
+ if (mem_origin != mem_new) {
+ mem_new_fixed = mem_new + sizeof(rt_ubase_t);
+ if ((rt_ubase_t)mem_new_fixed & 0x7) {
+ mem_new_fixed = (void *)((rt_ubase_t)(mem_new_fixed + 8) & (~7));
+ }
+
+ addr_field = mem_new_fixed - sizeof(rt_ubase_t);
+ *addr_field = (rt_ubase_t)mem_new;
+
+ return mem_new_fixed;
+ }
+
+ return ptr;
+}
+
+void
+os_free(void *ptr)
+{
+ void *mem_origin;
+ rt_ubase_t *addr_field;
+
+ if (ptr) {
+ addr_field = ptr - sizeof(rt_ubase_t);
+ mem_origin = (void *)(*addr_field);
+
+ rt_free(mem_origin);
+ }
+}
+
+int
+os_dumps_proc_mem_info(char *out, unsigned int size)
+{
+ return -1;
+}
+
+static char wamr_vprint_buf[RT_CONSOLEBUF_SIZE * 2];
+
+int
+os_printf(const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ rt_size_t len =
+ vsnprintf(wamr_vprint_buf, sizeof(wamr_vprint_buf) - 1, format, ap);
+ wamr_vprint_buf[len] = 0x00;
+ rt_kputs(wamr_vprint_buf);
+ va_end(ap);
+ return 0;
+}
+
+int
+os_vprintf(const char *format, va_list ap)
+{
+ rt_size_t len =
+ vsnprintf(wamr_vprint_buf, sizeof(wamr_vprint_buf) - 1, format, ap);
+ wamr_vprint_buf[len] = 0;
+ rt_kputs(wamr_vprint_buf);
+ return 0;
+}
+
+uint64
+os_time_get_boot_microsecond(void)
+{
+ uint64 ret = rt_tick_get() * 1000;
+ ret /= RT_TICK_PER_SECOND;
+ return ret;
+}
+
+korp_tid
+os_self_thread(void)
+{
+ return rt_thread_self();
+}
+
+uint8 *
+os_thread_get_stack_boundary(void)
+{
+ rt_thread_t tid = rt_thread_self();
+ return tid->stack_addr;
+}
+
+int
+os_mutex_init(korp_mutex *mutex)
+{
+ return rt_mutex_init(mutex, "wamr0", RT_IPC_FLAG_FIFO);
+}
+
+int
+os_mutex_destroy(korp_mutex *mutex)
+{
+ return rt_mutex_detach(mutex);
+}
+
+int
+os_mutex_lock(korp_mutex *mutex)
+{
+ return rt_mutex_take(mutex, RT_WAITING_FOREVER);
+}
+
+int
+os_mutex_unlock(korp_mutex *mutex)
+{
+ return rt_mutex_release(mutex);
+}
+
+/*
+ * functions below was not implement
+ */
+
+int
+os_cond_init(korp_cond *cond)
+{
+ return 0;
+}
+
+int
+os_cond_destroy(korp_cond *cond)
+{
+ return 0;
+}
+
+int
+os_cond_wait(korp_cond *cond, korp_mutex *mutex)
+{
+ return 0;
+}
+
+void *
+os_mmap(void *hint, size_t size, int prot, int flags)
+{
+ return rt_malloc(size);
+}
+
+void
+os_munmap(void *addr, size_t size)
+{
+ rt_free(addr);
+}
+
+int
+os_mprotect(void *addr, size_t size, int prot)
+{
+ return 0;
+}
+
+void
+os_dcache_flush(void)
+{}
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/shared_platform.cmake b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/shared_platform.cmake
new file mode 100644
index 000000000..fce9bff33
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/rt-thread/shared_platform.cmake
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2021, RT-Thread Development Team
+#
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+set (PLATFORM_SHARED_DIR ${CMAKE_CURRENT_LIST_DIR})
+
+add_definitions(-DBH_PLATFORM_RTT)
+
+include_directories(${PLATFORM_SHARED_DIR})
+include_directories(${PLATFORM_SHARED_DIR}/../include)
+
+# include (${CMAKE_CURRENT_LIST_DIR}/../common/math/platform_api_math.cmake)
+
+file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c)
+
+set (PLATFORM_SHARED_SOURCE ${source_all} ${PLATFORM_COMMON_MATH_SOURCE})
+