diff --git a/core/app-mgr/app-manager/app_manager.h b/core/app-mgr/app-manager/app_manager.h index 8021e30d1..b9fed73f5 100644 --- a/core/app-mgr/app-manager/app_manager.h +++ b/core/app-mgr/app-manager/app_manager.h @@ -20,7 +20,7 @@ #include "bh_platform.h" #include "bh_common.h" #include "bh_queue.h" -#include "korp_types.h" +#include "bh_types.h" #include "app_manager_export.h" #include "native_interface.h" #include "shared_utils.h" diff --git a/core/app-mgr/app-manager/app_manager_host.c b/core/app-mgr/app-manager/app_manager_host.c index ac8caddae..509a34324 100644 --- a/core/app-mgr/app-manager/app_manager_host.c +++ b/core/app-mgr/app-manager/app_manager_host.c @@ -15,7 +15,7 @@ */ #include "bh_common.h" -#include "korp_types.h" +#include "bh_types.h" #include "app_manager_host.h" #include "app_manager.h" #include "app_manager_export.h" diff --git a/core/app-mgr/app-manager/watchdog.c b/core/app-mgr/app-manager/watchdog.c index c3d9b0e99..c62f3d19a 100644 --- a/core/app-mgr/app-manager/watchdog.c +++ b/core/app-mgr/app-manager/watchdog.c @@ -52,8 +52,8 @@ bool watchdog_timer_init(module_data *m_data) #ifdef WATCHDOG_ENABLED /* TODO */ watchdog_timer *wd_timer = &m_data->wd_timer; - if (BH_SUCCESS != vm_mutex_init(&wd_timer->lock)) - return false; + if (0 != vm_mutex_init(&wd_timer->lock)) + return false; if (!(wd_timer->timer_handle = app_manager_timer_create(watchdog_timer_callback, wd_timer))) { diff --git a/core/iwasm/lib/native/extension/connection/linux/connection_mgr.c b/core/iwasm/lib/native/extension/connection/linux/connection_mgr.c index ad1f68c42..f6b871655 100644 --- a/core/iwasm/lib/native/extension/connection/linux/connection_mgr.c +++ b/core/iwasm/lib/native/extension/connection/linux/connection_mgr.c @@ -28,7 +28,6 @@ #include "conn_tcp.h" #include "conn_udp.h" #include "conn_uart.h" -#include "bh_definition.h" #include #include @@ -545,7 +544,7 @@ bool init_connection_framework() if (epollfd == -1) return false; - if (vm_mutex_init(&g_lock) != BH_SUCCESS) { + if (vm_mutex_init(&g_lock) != 0) { close(epollfd); return false; } @@ -562,7 +561,7 @@ bool init_connection_framework() if (vm_thread_create(&tid, polling_thread_routine, NULL, - BH_APPLET_PRESERVED_STACK_SIZE) != BH_SUCCESS) { + BH_APPLET_PRESERVED_STACK_SIZE) != 0) { goto fail; } diff --git a/core/iwasm/products/vxworks/CMakeLists.txt b/core/iwasm/products/vxworks/CMakeLists.txt index 80737f307..53aa42788 100644 --- a/core/iwasm/products/vxworks/CMakeLists.txt +++ b/core/iwasm/products/vxworks/CMakeLists.txt @@ -32,13 +32,17 @@ if (NOT ("$ENV{VALGRIND}" STREQUAL "YES")) endif () # Set BUILD_TARGET, currently values supported: -# "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32" +# "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32", "GENERAL" +#set (BUILD_TARGET "X86_64") + if (NOT BUILD_TARGET) if (CMAKE_SIZEOF_VOID_P EQUAL 8) # Build as X86_64 by default in 64-bit platform + # if BUILD_TARGET isn't set set (BUILD_TARGET "X86_64") else () # Build as X86_32 by default in 32-bit platform + # if BUILD_TARGET isn't set set (BUILD_TARGET "X86_32") endif () endif () @@ -58,6 +62,14 @@ elseif (BUILD_TARGET STREQUAL "MIPS_32") add_definitions(-DBUILD_TARGET_MIPS_32) elseif (BUILD_TARGET STREQUAL "XTENSA_32") add_definitions(-DBUILD_TARGET_XTENSA_32) +elseif (BUILD_TARGET STREQUAL "GENERAL") + # Will use invokeNative_general.c instead of assembly code, + # but the maximum number of native arguments is limited to 20, + # and there are possible issues when passing arguments to + # native function for some cpus, e.g. int64 and double arguments + # in arm and mips need to be 8-bytes aligned, and some arguments + # of x86_64 are passed by registers but not stack + add_definitions(-DBUILD_TARGET_GENERAL) else () message (FATAL_ERROR "-- Build target isn't set") endif () @@ -91,6 +103,8 @@ include_directories (. ../../runtime/platform/include ${SHARED_LIB_DIR}/include) +enable_language (ASM) + include (../../runtime/platform/${PLATFORM}/platform.cmake) include (../../runtime/utils/utils.cmake) include (../../runtime/vmcore-wasm/vmcore.cmake) diff --git a/core/iwasm/products/vxworks/main.c b/core/iwasm/products/vxworks/main.c index a1a503f31..22caee8ac 100644 --- a/core/iwasm/products/vxworks/main.c +++ b/core/iwasm/products/vxworks/main.c @@ -19,9 +19,9 @@ #endif #include #include +#include "bh_platform.h" #include "wasm_assert.h" #include "wasm_log.h" -#include "wasm_platform.h" #include "wasm_platform_log.h" #include "wasm_thread.h" #include "wasm_export.h" diff --git a/core/iwasm/runtime/vmcore-wasm/vmcore.cmake b/core/iwasm/runtime/vmcore-wasm/vmcore.cmake index cf3d4e0b5..ff69c003d 100644 --- a/core/iwasm/runtime/vmcore-wasm/vmcore.cmake +++ b/core/iwasm/runtime/vmcore-wasm/vmcore.cmake @@ -30,6 +30,8 @@ elseif (${BUILD_TARGET} STREQUAL "MIPS_32") set (source_all ${c_source_all} ${VMCORE_LIB_DIR}/invokeNative_mips.s) elseif (${BUILD_TARGET} STREQUAL "XTENSA_32") set (source_all ${c_source_all} ${VMCORE_LIB_DIR}/invokeNative_xtensa.s) +elseif (${BUILD_TARGET} STREQUAL "GENERAL") + set (source_all ${c_source_all} ${VMCORE_LIB_DIR}/invokeNative_general.c) else () message (FATAL_ERROR "Build target isn't set") endif () diff --git a/core/shared-lib/include/bh_common.h b/core/shared-lib/include/bh_common.h old mode 100755 new mode 100644 index a8176dc7f..c8e73cc60 --- a/core/shared-lib/include/bh_common.h +++ b/core/shared-lib/include/bh_common.h @@ -18,7 +18,6 @@ #define _BH_COMMON_H #include "bh_assert.h" -#include "bh_definition.h" #include "bh_platform.h" #include "bh_log.h" #include "bh_list.h" diff --git a/core/shared-lib/include/bh_list.h b/core/shared-lib/include/bh_list.h index 01644dc04..160cc505d 100644 --- a/core/shared-lib/include/bh_list.h +++ b/core/shared-lib/include/bh_list.h @@ -21,7 +21,7 @@ extern "C" { #endif -#include "korp_types.h" /*For bool type*/ +#include "bh_types.h" /*For bool type*/ #include "bh_platform.h" /* List user should embedded bh_list_link into list elem data structure diff --git a/core/shared-lib/include/bh_log.h b/core/shared-lib/include/bh_log.h index c2e45fe06..fd2a88ce1 100644 --- a/core/shared-lib/include/bh_log.h +++ b/core/shared-lib/include/bh_log.h @@ -34,7 +34,7 @@ #include -#include "korp_types.h" +#include "bh_types.h" #ifdef __cplusplus extern "C" { diff --git a/core/shared-lib/include/bh_queue.h b/core/shared-lib/include/bh_queue.h index f45b90149..d6f322e04 100644 --- a/core/shared-lib/include/bh_queue.h +++ b/core/shared-lib/include/bh_queue.h @@ -21,7 +21,7 @@ extern "C" { #endif -#include "korp_types.h" /*For bool type*/ +#include "bh_types.h" /*For bool type*/ #include "bh_platform.h" struct _bh_queue_node; diff --git a/core/shared-lib/include/jeff_export.h b/core/shared-lib/include/jeff_export.h old mode 100755 new mode 100644 index 360bba7db..3e45adb8d --- a/core/shared-lib/include/jeff_export.h +++ b/core/shared-lib/include/jeff_export.h @@ -26,7 +26,7 @@ #define JEFF_EXPORT_H #include "bni.h" -#include "korp_types.h" +#include "bh_types.h" /******************************************************************** * Exported internal types diff --git a/core/shared-lib/platform/alios/bh_definition.c b/core/shared-lib/platform/alios/bh_definition.c index 635e8fe53..756283225 100644 --- a/core/shared-lib/platform/alios/bh_definition.c +++ b/core/shared-lib/platform/alios/bh_definition.c @@ -14,14 +14,8 @@ * limitations under the License. */ -#include "bh_definition.h" #include "bh_platform.h" -int bh_return(int ret) -{ - return ret; -} - #define RSIZE_MAX 0x7FFFFFFF int b_memcpy_s(void * s1, unsigned int s1max, diff --git a/core/shared-lib/platform/darwin/bh_definition.c b/core/shared-lib/platform/darwin/bh_definition.c index 47ee11ed2..ebd609ace 100644 --- a/core/shared-lib/platform/darwin/bh_definition.c +++ b/core/shared-lib/platform/darwin/bh_definition.c @@ -14,15 +14,10 @@ * limitations under the License. */ -#include "bh_definition.h" #include "bh_platform.h" -int bh_return(int ret) -{ - return ret; -} - #define RSIZE_MAX 0x7FFFFFFF + int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) { char *dest = (char*) s1; @@ -44,8 +39,9 @@ int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) int b_strcat_s(char * s1, size_t s1max, const char * s2) { - if (NULL - == s1|| NULL == s2 || s1max < (strlen(s1) + strlen(s2) + 1) || s1max > RSIZE_MAX) { + if (NULL == s1 || NULL == s2 + || s1max < (strlen(s1) + strlen(s2) + 1) + || s1max > RSIZE_MAX) { return -1; } @@ -56,8 +52,9 @@ int b_strcat_s(char * s1, size_t s1max, const char * s2) int b_strcpy_s(char * s1, size_t s1max, const char * s2) { - if (NULL - == s1|| NULL == s2 || s1max < (strlen(s2) + 1) || s1max > RSIZE_MAX) { + if (NULL == s1 || NULL == s2 + || s1max < (strlen(s2) + 1) + || s1max > RSIZE_MAX) { return -1; } diff --git a/core/shared-lib/platform/include/bh_assert.h b/core/shared-lib/platform/include/bh_assert.h index 08cea79c7..585b77631 100644 --- a/core/shared-lib/platform/include/bh_assert.h +++ b/core/shared-lib/platform/include/bh_assert.h @@ -39,37 +39,31 @@ extern "C" { #ifdef BH_DEBUG -extern void bh_assert_internal(int v, const char *file_name, int line_number, const char *expr_string); -#define bh_assert(expr) bh_assert_internal((int)(expr), __FILE__, __LINE__, # expr) -extern void bh_debug_internal(const char *file_name, int line_number, const char *fmt, ...); +void bh_assert_internal(int v, const char *file_name, int line_number, + const char *expr_string); +#define bh_assert(expr) bh_assert_internal((int)(expr), __FILE__, __LINE__, #expr) -#if defined(WIN32) || defined(EMU) -# define bh_debug(fmt, ...) bh_debug_internal(__FILE__, __LINE__, fmt, __VA_ARGS__) +void bh_debug_internal(const char *file_name, int line_number, + const char *fmt, ...); +#if defined(WIN32) + #define bh_debug(fmt, ...) bh_debug_internal(__FILE__, __LINE__, fmt, __VA_ARGS__) #elif defined(__linux__) -/*# define bh_debug(...) bh_debug_internal(__FILE__, __LINE__, ## __VA_ARGS__)*/ -# define bh_debug bh_debug_internal(__FILE__, __LINE__, "");printf -#elif defined(PLATFORM_SEC) -# define bh_debug(fmt, ...) bh_debug_internal(__FILE__, __LINE__, fmt, __VA_ARGS__) + #define bh_debug bh_debug_internal(__FILE__, __LINE__, "");printf #else -# error "Unsupported platform" + #error "Unsupported platform" #endif -#else +#else /* else of BH_DEBUG */ #define bh_debug if(0)printf -#endif - -#define bh_assert_abort(x) do { \ - if (!x) \ - abort(); \ - } while (0) +#endif /* end of BH_DEBUG */ #ifdef BH_TEST -# define BH_STATIC + #define BH_STATIC #else -# define BH_STATIC static -#endif + #define BH_STATIC static +#endif /* end of BH_TEST */ #ifdef __cplusplus } @@ -77,8 +71,3 @@ extern void bh_debug_internal(const char *file_name, int line_number, const char #endif -/* Local Variables: */ -/* mode:c */ -/* c-basic-offset: 4 */ -/* indent-tabs-mode: nil */ -/* End: */ diff --git a/core/shared-lib/platform/include/bh_thread.h b/core/shared-lib/platform/include/bh_thread.h index a573f3f1d..5768c8f80 100644 --- a/core/shared-lib/platform/include/bh_thread.h +++ b/core/shared-lib/platform/include/bh_thread.h @@ -38,7 +38,7 @@ extern "C" { * vm_thread_sys_init * initiation function for beihai thread system. Invoked at the beginning of beihai intiation. * - * @return BH_SUCCESS if succuess. + * @return 0 if succuess. */ int _vm_thread_sys_init(void); #ifdef _INSTRUMENT_TEST_ENABLED @@ -58,7 +58,7 @@ void vm_thread_sys_destroy(void); * @param arg argument passed to main routine * @param stack_size bytes of stack size * - * @return BH_SUCCESS if success. + * @return 0 if success. */ int _vm_thread_create(korp_tid *p_tid, thread_start_routine_t start, void *arg, unsigned int stack_size); @@ -78,7 +78,7 @@ int vm_thread_create_instr(korp_tid *p_tid, thread_start_routine_t start, void * * @param stack_size bytes of stack size * @param prio the priority * - * @return BH_SUCCESS if success. + * @return 0 if success. */ int _vm_thread_create_with_prio(korp_tid *p_tid, thread_start_routine_t start, void *arg, unsigned int stack_size, int prio); @@ -115,7 +115,7 @@ korp_tid vm_self_thread_instr(const char*func_name); * @param idx tls array index * @param ptr pointer need save as TLS * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_tls_put(unsigned idx, void *ptr); #ifdef _INSTRUMENT_TEST_ENABLED @@ -147,7 +147,7 @@ void *vm_tls_get_instr(unsigned idx, const char*func_name); * * @param mutex [OUTPUT] pointer to mutex initialized. * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_mutex_init(korp_mutex *mutex); #ifdef INSTRUMENT_TEST_ENABLED @@ -162,7 +162,7 @@ int vm_mutex_init_instr(korp_mutex *mutex, const char*func_name); * * @param mutex [OUTPUT] pointer to mutex initialized. * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_recursive_mutex_init(korp_mutex *mutex); #ifdef INSTRUMENT_TEST_ENABLED @@ -177,7 +177,7 @@ int vm_recursive_mutex_init_instr(korp_mutex *mutex, const char*func_name); * * @param mutex pointer to mutex need destroy * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_mutex_destroy(korp_mutex *mutex); #ifdef _INSTRUMENT_TEST_ENABLED @@ -201,7 +201,7 @@ void vm_mutex_lock(korp_mutex *mutex); * * @param mutex pointer to mutex need lock * - * @return BH_SUCCESS if success + * @return 0 if success */ int vm_mutex_trylock(korp_mutex *mutex); @@ -220,7 +220,7 @@ void vm_mutex_unlock(korp_mutex *mutex); * @param sem [OUTPUT] pointer to semaphone * @param c counter of semaphone * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_sem_init(korp_sem *sem, unsigned int c); #ifdef _INSTRUMENT_TEST_ENABLED @@ -235,7 +235,7 @@ int vm_sem_init_instr(korp_sem *sem, unsigned int c, const char*func_name); * * @param sem pointer to semaphone need destroy * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_sem_destroy(korp_sem *sem); #ifdef _INSTRUMENT_TEST_ENABLED @@ -250,7 +250,7 @@ int vm_sem_destroy_instr(korp_sem *sem, const char*func_name); * * @param sem pointer to semaphone need perform wait operation * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_sem_wait(korp_sem *sem); #ifdef _INSTRUMENT_TEST_ENABLED @@ -266,7 +266,7 @@ int vm_sem_wait_instr(korp_sem *sem, const char*func_name); * @param sem pointer to semaphone need perform wait operation * @param mills wait milliseconds to return * - * @return BH_SUCCESS if success + * @return 0 if success * @return BH_TIMEOUT if time out */ int _vm_sem_reltimedwait(korp_sem *sem, int mills); @@ -282,7 +282,7 @@ int vm_sem_reltimedwait_instr(korp_sem *sem, int mills, const char*func_name); * * @param sem pointer to semaphone need perform post operation * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_sem_post(korp_sem *sem); #ifdef _INSTRUMENT_TEST_ENABLED @@ -297,7 +297,7 @@ int vm_sem_post_instr(korp_sem *sem, const char*func_name); * * @param cond [OUTPUT] pointer to condition variable * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_cond_init(korp_cond *cond); #ifdef INSTRUMENT_TEST_ENABLED @@ -312,7 +312,7 @@ int vm_cond_init_instr(korp_cond *cond, const char*func_name); * * @param cond pointer to condition variable * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_cond_destroy(korp_cond *cond); #ifdef _INSTRUMENT_TEST_ENABLED @@ -328,7 +328,7 @@ int vm_cond_destroy_instr(korp_cond *cond, const char*func_name); * @param cond pointer to condition variable * @param mutex pointer to mutex to protect the condition variable * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_cond_wait(korp_cond *cond, korp_mutex *mutex); #ifdef _INSTRUMENT_TEST_ENABLED @@ -345,7 +345,7 @@ int vm_cond_wait_instr(korp_cond *cond, korp_mutex *mutex, const char*func_name) * @param mutex pointer to mutex to protect the condition variable * @param mills milliseconds to wait * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, int mills); #ifdef _INSTRUMENT_TEST_ENABLED @@ -360,7 +360,7 @@ int vm_cond_reltimedwait_instr(korp_cond *cond, korp_mutex *mutex, int mills, co * * @param cond condition variable * - * @return BH_SUCCESS if success + * @return 0 if success */ int _vm_cond_signal(korp_cond *cond); #ifdef _INSTRUMENT_TEST_ENABLED diff --git a/core/shared-lib/platform/include/bh_time.h b/core/shared-lib/platform/include/bh_time.h index 31e1454a8..13b0286f9 100644 --- a/core/shared-lib/platform/include/bh_time.h +++ b/core/shared-lib/platform/include/bh_time.h @@ -22,7 +22,6 @@ extern "C" { #endif #include "bh_config.h" -#include "bh_definition.h" #include "bh_types.h" #include "bh_platform.h" diff --git a/core/shared-lib/platform/include/bh_types.h b/core/shared-lib/platform/include/bh_types.h index da26c7dc5..74e0dd683 100644 --- a/core/shared-lib/platform/include/bh_types.h +++ b/core/shared-lib/platform/include/bh_types.h @@ -28,25 +28,16 @@ typedef int int32; typedef float float32; typedef double float64; -#define BYTES_OF_UINT8 1 -#define BYTES_OF_UINT16 2 -#define BYTES_OF_UINT32 4 -#define BYTES_OF_UINT64 8 - -#define BYTES_OF_BOOLEAN 1 -#define BYTES_OF_BYTE 1 -#define BYTES_OF_CHAR 2 -#define BYTES_OF_SHORT 2 -#define BYTES_OF_INT 4 -#define BYTES_OF_FLOAT 4 -#define BYTES_OF_LONG 8 -#define BYTES_OF_DOUBLE 8 - #include "bh_platform.h" +#ifndef NULL +#define NULL (void*)0 +#endif + #ifndef __cplusplus #define true 1 #define false 0 +#define inline __inline #endif #endif diff --git a/core/shared-lib/platform/linux-sgx/bh_definition.c b/core/shared-lib/platform/linux-sgx/bh_definition.c index 5105d0ff8..42dd639a8 100644 --- a/core/shared-lib/platform/linux-sgx/bh_definition.c +++ b/core/shared-lib/platform/linux-sgx/bh_definition.c @@ -14,15 +14,10 @@ * limitations under the License. */ -#include "bh_definition.h" #include "bh_platform.h" -int bh_return(int ret) -{ - return ret; -} - #define RSIZE_MAX 0x7FFFFFFF + int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) { char *dest = (char*) s1; @@ -44,8 +39,9 @@ int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) int b_strcat_s(char * s1, size_t s1max, const char * s2) { - if (NULL - == s1|| NULL == s2 || s1max < (strlen(s1) + strlen(s2) + 1) || s1max > RSIZE_MAX) { + if (NULL == s1 || NULL == s2 + || s1max < (strlen(s1) + strlen(s2) + 1) + || s1max > RSIZE_MAX) { return -1; } @@ -56,8 +52,9 @@ int b_strcat_s(char * s1, size_t s1max, const char * s2) int b_strcpy_s(char * s1, size_t s1max, const char * s2) { - if (NULL - == s1|| NULL == s2 || s1max < (strlen(s2) + 1) || s1max > RSIZE_MAX) { + if (NULL == s1 || NULL == s2 + || s1max < (strlen(s2) + 1) + || s1max > RSIZE_MAX) { return -1; } diff --git a/core/shared-lib/platform/linux/bh_definition.c b/core/shared-lib/platform/linux/bh_definition.c index 47ee11ed2..ebd609ace 100644 --- a/core/shared-lib/platform/linux/bh_definition.c +++ b/core/shared-lib/platform/linux/bh_definition.c @@ -14,15 +14,10 @@ * limitations under the License. */ -#include "bh_definition.h" #include "bh_platform.h" -int bh_return(int ret) -{ - return ret; -} - #define RSIZE_MAX 0x7FFFFFFF + int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) { char *dest = (char*) s1; @@ -44,8 +39,9 @@ int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) int b_strcat_s(char * s1, size_t s1max, const char * s2) { - if (NULL - == s1|| NULL == s2 || s1max < (strlen(s1) + strlen(s2) + 1) || s1max > RSIZE_MAX) { + if (NULL == s1 || NULL == s2 + || s1max < (strlen(s1) + strlen(s2) + 1) + || s1max > RSIZE_MAX) { return -1; } @@ -56,8 +52,9 @@ int b_strcat_s(char * s1, size_t s1max, const char * s2) int b_strcpy_s(char * s1, size_t s1max, const char * s2) { - if (NULL - == s1|| NULL == s2 || s1max < (strlen(s2) + 1) || s1max > RSIZE_MAX) { + if (NULL == s1 || NULL == s2 + || s1max < (strlen(s2) + 1) + || s1max > RSIZE_MAX) { return -1; } diff --git a/core/shared-lib/platform/vxworks/bh_definition.c b/core/shared-lib/platform/vxworks/bh_definition.c index 19e10d55e..acdacf7f8 100644 --- a/core/shared-lib/platform/vxworks/bh_definition.c +++ b/core/shared-lib/platform/vxworks/bh_definition.c @@ -14,13 +14,9 @@ * limitations under the License. */ -#include "bh_definition.h" #include "bh_platform.h" -int bh_return(int ret) -{ - return ret; -} +#define RSIZE_MAX 0x7FFFFFFF int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) { @@ -43,8 +39,9 @@ int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) int b_strcat_s(char * s1, size_t s1max, const char * s2) { - if (NULL - == s1|| NULL == s2 || s1max < (strlen(s1) + strlen(s2) + 1) || s1max > RSIZE_MAX) { + if (NULL == s1 || NULL == s2 + || s1max < (strlen(s1) + strlen(s2) + 1) + || s1max > RSIZE_MAX) { return -1; } @@ -55,8 +52,8 @@ int b_strcat_s(char * s1, size_t s1max, const char * s2) int b_strcpy_s(char * s1, size_t s1max, const char * s2) { - if (NULL - == s1|| NULL == s2 || s1max < (strlen(s2) + 1) || s1max > RSIZE_MAX) { + if (NULL == s1|| NULL == s2 + || s1max < (strlen(s2) + 1) || s1max > RSIZE_MAX) { return -1; } diff --git a/core/shared-lib/platform/vxworks/bh_platform.c b/core/shared-lib/platform/vxworks/bh_platform.c index 981124228..5509a7e02 100644 --- a/core/shared-lib/platform/vxworks/bh_platform.c +++ b/core/shared-lib/platform/vxworks/bh_platform.c @@ -65,7 +65,7 @@ bh_read_file_to_buffer(const char *filename, int *ret_size) file_size = stat_buf.st_size; - if (!(buffer = wasm_malloc(file_size))) { + if (!(buffer = bh_malloc(file_size))) { printf("Read file to buffer failed: alloc memory failed.\n"); close(file); return NULL; @@ -76,7 +76,7 @@ bh_read_file_to_buffer(const char *filename, int *ret_size) if (read_size < file_size) { printf("Read file to buffer failed: read file content failed.\n"); - wasm_free(buffer); + bh_free(buffer); return NULL; } diff --git a/core/shared-lib/platform/vxworks/bh_platform.h b/core/shared-lib/platform/vxworks/bh_platform.h index 142583e5b..4fae1e679 100644 --- a/core/shared-lib/platform/vxworks/bh_platform.h +++ b/core/shared-lib/platform/vxworks/bh_platform.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/core/shared-lib/platform/zephyr/bh_definition.c b/core/shared-lib/platform/zephyr/bh_definition.c index 0c9d3fc6c..5602c594e 100644 --- a/core/shared-lib/platform/zephyr/bh_definition.c +++ b/core/shared-lib/platform/zephyr/bh_definition.c @@ -14,15 +14,10 @@ * limitations under the License. */ -#include "bh_definition.h" #include "bh_platform.h" -int bh_return(int ret) -{ - return ret; -} - #define RSIZE_MAX 0x7FFFFFFF + int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) { char *dest = (char*) s1; @@ -44,8 +39,9 @@ int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) int b_strcat_s(char * s1, size_t s1max, const char * s2) { - if (NULL - == s1|| NULL == s2 || s1max < (strlen(s1) + strlen(s2) + 1) || s1max > RSIZE_MAX) { + if (NULL == s1 || NULL == s2 + || s1max < (strlen(s1) + strlen(s2) + 1) + || s1max > RSIZE_MAX) { return -1; } @@ -56,8 +52,8 @@ int b_strcat_s(char * s1, size_t s1max, const char * s2) int b_strcpy_s(char * s1, size_t s1max, const char * s2) { - if (NULL - == s1|| NULL == s2 || s1max < (strlen(s2) + 1) || s1max > RSIZE_MAX) { + if (NULL == s1|| NULL == s2 + || s1max < (strlen(s2) + 1) || s1max > RSIZE_MAX) { return -1; }