Эх сурвалжийг харах

Re-org shared lib header files, remove unused info (#136)

And fix compile issues of vxworks
wenyongh 6 жил өмнө
parent
commit
49127efa99

+ 1 - 1
core/app-mgr/app-manager/app_manager.h

@@ -20,7 +20,7 @@
 #include "bh_platform.h"
 #include "bh_platform.h"
 #include "bh_common.h"
 #include "bh_common.h"
 #include "bh_queue.h"
 #include "bh_queue.h"
-#include "korp_types.h"
+#include "bh_types.h"
 #include "app_manager_export.h"
 #include "app_manager_export.h"
 #include "native_interface.h"
 #include "native_interface.h"
 #include "shared_utils.h"
 #include "shared_utils.h"

+ 1 - 1
core/app-mgr/app-manager/app_manager_host.c

@@ -15,7 +15,7 @@
  */
  */
 
 
 #include "bh_common.h"
 #include "bh_common.h"
-#include "korp_types.h"
+#include "bh_types.h"
 #include "app_manager_host.h"
 #include "app_manager_host.h"
 #include "app_manager.h"
 #include "app_manager.h"
 #include "app_manager_export.h"
 #include "app_manager_export.h"

+ 2 - 2
core/app-mgr/app-manager/watchdog.c

@@ -52,8 +52,8 @@ bool watchdog_timer_init(module_data *m_data)
 #ifdef WATCHDOG_ENABLED /* TODO */
 #ifdef WATCHDOG_ENABLED /* TODO */
     watchdog_timer *wd_timer = &m_data->wd_timer;
     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 =
     if (!(wd_timer->timer_handle =
                     app_manager_timer_create(watchdog_timer_callback, wd_timer))) {
                     app_manager_timer_create(watchdog_timer_callback, wd_timer))) {

+ 2 - 3
core/iwasm/lib/native/extension/connection/linux/connection_mgr.c

@@ -28,7 +28,6 @@
 #include "conn_tcp.h"
 #include "conn_tcp.h"
 #include "conn_udp.h"
 #include "conn_udp.h"
 #include "conn_uart.h"
 #include "conn_uart.h"
-#include "bh_definition.h"
 
 
 #include <unistd.h>
 #include <unistd.h>
 #include <sys/epoll.h>
 #include <sys/epoll.h>
@@ -545,7 +544,7 @@ bool init_connection_framework()
     if (epollfd == -1)
     if (epollfd == -1)
         return false;
         return false;
 
 
-    if (vm_mutex_init(&g_lock) != BH_SUCCESS) {
+    if (vm_mutex_init(&g_lock) != 0) {
         close(epollfd);
         close(epollfd);
         return false;
         return false;
     }
     }
@@ -562,7 +561,7 @@ bool init_connection_framework()
     if (vm_thread_create(&tid,
     if (vm_thread_create(&tid,
                          polling_thread_routine,
                          polling_thread_routine,
                          NULL,
                          NULL,
-                         BH_APPLET_PRESERVED_STACK_SIZE) != BH_SUCCESS) {
+                         BH_APPLET_PRESERVED_STACK_SIZE) != 0) {
         goto fail;
         goto fail;
     }
     }
 
 

+ 15 - 1
core/iwasm/products/vxworks/CMakeLists.txt

@@ -32,13 +32,17 @@ if (NOT ("$ENV{VALGRIND}" STREQUAL "YES"))
 endif ()
 endif ()
 
 
 # Set BUILD_TARGET, currently values supported:
 # 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 (NOT BUILD_TARGET)
   if (CMAKE_SIZEOF_VOID_P EQUAL 8)
   if (CMAKE_SIZEOF_VOID_P EQUAL 8)
     # Build as X86_64 by default in 64-bit platform
     # Build as X86_64 by default in 64-bit platform
+    # if BUILD_TARGET isn't set
     set (BUILD_TARGET "X86_64")
     set (BUILD_TARGET "X86_64")
   else ()
   else ()
     # Build as X86_32 by default in 32-bit platform
     # Build as X86_32 by default in 32-bit platform
+    # if BUILD_TARGET isn't set
     set (BUILD_TARGET "X86_32")
     set (BUILD_TARGET "X86_32")
   endif ()
   endif ()
 endif ()
 endif ()
@@ -58,6 +62,14 @@ elseif (BUILD_TARGET STREQUAL "MIPS_32")
   add_definitions(-DBUILD_TARGET_MIPS_32)
   add_definitions(-DBUILD_TARGET_MIPS_32)
 elseif (BUILD_TARGET STREQUAL "XTENSA_32")
 elseif (BUILD_TARGET STREQUAL "XTENSA_32")
   add_definitions(-DBUILD_TARGET_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 ()
 else ()
   message (FATAL_ERROR "-- Build target isn't set")
   message (FATAL_ERROR "-- Build target isn't set")
 endif ()
 endif ()
@@ -91,6 +103,8 @@ include_directories (.
                      ../../runtime/platform/include
                      ../../runtime/platform/include
                      ${SHARED_LIB_DIR}/include)
                      ${SHARED_LIB_DIR}/include)
 
 
+enable_language (ASM)
+
 include (../../runtime/platform/${PLATFORM}/platform.cmake)
 include (../../runtime/platform/${PLATFORM}/platform.cmake)
 include (../../runtime/utils/utils.cmake)
 include (../../runtime/utils/utils.cmake)
 include (../../runtime/vmcore-wasm/vmcore.cmake)
 include (../../runtime/vmcore-wasm/vmcore.cmake)

+ 1 - 1
core/iwasm/products/vxworks/main.c

@@ -19,9 +19,9 @@
 #endif
 #endif
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
+#include "bh_platform.h"
 #include "wasm_assert.h"
 #include "wasm_assert.h"
 #include "wasm_log.h"
 #include "wasm_log.h"
-#include "wasm_platform.h"
 #include "wasm_platform_log.h"
 #include "wasm_platform_log.h"
 #include "wasm_thread.h"
 #include "wasm_thread.h"
 #include "wasm_export.h"
 #include "wasm_export.h"

+ 2 - 0
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)
   set (source_all ${c_source_all} ${VMCORE_LIB_DIR}/invokeNative_mips.s)
 elseif (${BUILD_TARGET} STREQUAL "XTENSA_32")
 elseif (${BUILD_TARGET} STREQUAL "XTENSA_32")
   set (source_all ${c_source_all} ${VMCORE_LIB_DIR}/invokeNative_xtensa.s)
   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 ()
 else ()
   message (FATAL_ERROR "Build target isn't set")
   message (FATAL_ERROR "Build target isn't set")
 endif ()
 endif ()

+ 0 - 1
core/shared-lib/include/bh_common.h

@@ -18,7 +18,6 @@
 #define _BH_COMMON_H
 #define _BH_COMMON_H
 
 
 #include "bh_assert.h"
 #include "bh_assert.h"
-#include "bh_definition.h"
 #include "bh_platform.h"
 #include "bh_platform.h"
 #include "bh_log.h"
 #include "bh_log.h"
 #include "bh_list.h"
 #include "bh_list.h"

+ 1 - 1
core/shared-lib/include/bh_list.h

@@ -21,7 +21,7 @@
 extern "C" {
 extern "C" {
 #endif
 #endif
 
 
-#include "korp_types.h" /*For bool type*/
+#include "bh_types.h" /*For bool type*/
 #include "bh_platform.h"
 #include "bh_platform.h"
 
 
 /* List user should embedded bh_list_link into list elem data structure
 /* List user should embedded bh_list_link into list elem data structure

+ 1 - 1
core/shared-lib/include/bh_log.h

@@ -34,7 +34,7 @@
 
 
 #include <stdarg.h>
 #include <stdarg.h>
 
 
-#include "korp_types.h"
+#include "bh_types.h"
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 extern "C" {
 extern "C" {

+ 1 - 1
core/shared-lib/include/bh_queue.h

@@ -21,7 +21,7 @@
 extern "C" {
 extern "C" {
 #endif
 #endif
 
 
-#include "korp_types.h" /*For bool type*/
+#include "bh_types.h" /*For bool type*/
 #include "bh_platform.h"
 #include "bh_platform.h"
 
 
 struct _bh_queue_node;
 struct _bh_queue_node;

+ 1 - 1
core/shared-lib/include/jeff_export.h

@@ -26,7 +26,7 @@
 #define JEFF_EXPORT_H
 #define JEFF_EXPORT_H
 
 
 #include "bni.h"
 #include "bni.h"
-#include "korp_types.h"
+#include "bh_types.h"
 
 
 /********************************************************************
 /********************************************************************
  *                  Exported internal types
  *                  Exported internal types

+ 0 - 6
core/shared-lib/platform/alios/bh_definition.c

@@ -14,14 +14,8 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-#include "bh_definition.h"
 #include "bh_platform.h"
 #include "bh_platform.h"
 
 
-int bh_return(int ret)
-{
-  return ret;
-}
-
 #define RSIZE_MAX 0x7FFFFFFF
 #define RSIZE_MAX 0x7FFFFFFF
 
 
 int b_memcpy_s(void * s1, unsigned int s1max,
 int b_memcpy_s(void * s1, unsigned int s1max,

+ 7 - 10
core/shared-lib/platform/darwin/bh_definition.c

@@ -14,15 +14,10 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-#include "bh_definition.h"
 #include "bh_platform.h"
 #include "bh_platform.h"
 
 
-int bh_return(int ret)
-{
-    return ret;
-}
-
 #define RSIZE_MAX 0x7FFFFFFF
 #define RSIZE_MAX 0x7FFFFFFF
+
 int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
 int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
 {
 {
     char *dest = (char*) s1;
     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)
 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;
         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)
 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;
         return -1;
     }
     }
 
 

+ 15 - 26
core/shared-lib/platform/include/bh_assert.h

@@ -39,37 +39,31 @@ extern "C" {
 
 
 #ifdef BH_DEBUG
 #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, ...);
-
-#if defined(WIN32) || defined(EMU)
-#    define bh_debug(fmt, ...) bh_debug_internal(__FILE__, __LINE__, fmt, __VA_ARGS__)
+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)
+
+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__)
 #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
 #else
-#    error "Unsupported platform"
+  #error "Unsupported platform"
 #endif
 #endif
 
 
-#else
+#else /* else of BH_DEBUG */
 
 
 #define bh_debug if(0)printf
 #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
 #ifdef BH_TEST
-#    define BH_STATIC
+  #define BH_STATIC
 #else
 #else
-#    define BH_STATIC static
-#endif
+  #define BH_STATIC static
+#endif /* end of BH_TEST */
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }
@@ -77,8 +71,3 @@ extern void bh_debug_internal(const char *file_name, int line_number, const char
 
 
 #endif
 #endif
 
 
-/* Local Variables: */
-/* mode:c           */
-/* c-basic-offset: 4 */
-/* indent-tabs-mode: nil */
-/* End:             */

+ 18 - 18
core/shared-lib/platform/include/bh_thread.h

@@ -38,7 +38,7 @@ extern "C" {
  * vm_thread_sys_init
  * vm_thread_sys_init
  *    initiation function for beihai thread system. Invoked at the beginning of beihai intiation.
  *    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);
 int _vm_thread_sys_init(void);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #ifdef _INSTRUMENT_TEST_ENABLED
@@ -58,7 +58,7 @@ void vm_thread_sys_destroy(void);
  * @param arg  argument passed to main routine
  * @param arg  argument passed to main routine
  * @param stack_size  bytes of stack size
  * @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,
 int _vm_thread_create(korp_tid *p_tid, thread_start_routine_t start, void *arg,
         unsigned int stack_size);
         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 stack_size  bytes of stack size
  * @param prio the priority
  * @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,
 int _vm_thread_create_with_prio(korp_tid *p_tid, thread_start_routine_t start,
         void *arg, unsigned int stack_size, int prio);
         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 idx  tls array index
  * @param ptr  pointer need save as TLS
  * @param ptr  pointer need save as TLS
  *
  *
- * @return BH_SUCCESS if success
+ * @return 0 if success
  */
  */
 int _vm_tls_put(unsigned idx, void *ptr);
 int _vm_tls_put(unsigned idx, void *ptr);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #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.
  * @param mutex [OUTPUT] pointer to mutex initialized.
  *
  *
- * @return BH_SUCCESS if success
+ * @return 0 if success
  */
  */
 int _vm_mutex_init(korp_mutex *mutex);
 int _vm_mutex_init(korp_mutex *mutex);
 #ifdef INSTRUMENT_TEST_ENABLED
 #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.
  * @param mutex [OUTPUT] pointer to mutex initialized.
  *
  *
- * @return BH_SUCCESS if success
+ * @return 0 if success
  */
  */
 int _vm_recursive_mutex_init(korp_mutex *mutex);
 int _vm_recursive_mutex_init(korp_mutex *mutex);
 #ifdef INSTRUMENT_TEST_ENABLED
 #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
  * @param mutex  pointer to mutex need destroy
  *
  *
- * @return BH_SUCCESS if success
+ * @return 0 if success
  */
  */
 int _vm_mutex_destroy(korp_mutex *mutex);
 int _vm_mutex_destroy(korp_mutex *mutex);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #ifdef _INSTRUMENT_TEST_ENABLED
@@ -201,7 +201,7 @@ void vm_mutex_lock(korp_mutex *mutex);
  *
  *
  * @param mutex  pointer to mutex need lock
  * @param mutex  pointer to mutex need lock
  *
  *
- * @return BH_SUCCESS if success
+ * @return 0 if success
  */
  */
 int vm_mutex_trylock(korp_mutex *mutex);
 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 sem [OUTPUT] pointer to semaphone
  * @param c counter of 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);
 int _vm_sem_init(korp_sem *sem, unsigned int c);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #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
  * @param sem pointer to semaphone need destroy
  *
  *
- * @return BH_SUCCESS if success
+ * @return 0 if success
  */
  */
 int _vm_sem_destroy(korp_sem *sem);
 int _vm_sem_destroy(korp_sem *sem);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #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
  * @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);
 int _vm_sem_wait(korp_sem *sem);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #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 sem  pointer to semaphone need perform wait operation
  * @param mills  wait milliseconds to return
  * @param mills  wait milliseconds to return
  *
  *
- * @return BH_SUCCESS if success
+ * @return 0 if success
  * @return BH_TIMEOUT if time out
  * @return BH_TIMEOUT if time out
  */
  */
 int _vm_sem_reltimedwait(korp_sem *sem, int mills);
 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
  * @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);
 int _vm_sem_post(korp_sem *sem);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #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
  * @param cond  [OUTPUT] pointer to condition variable
  *
  *
- * @return BH_SUCCESS if success
+ * @return 0 if success
  */
  */
 int _vm_cond_init(korp_cond *cond);
 int _vm_cond_init(korp_cond *cond);
 #ifdef INSTRUMENT_TEST_ENABLED
 #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
  * @param cond  pointer to condition variable
  *
  *
- * @return BH_SUCCESS if success
+ * @return 0 if success
  */
  */
 int _vm_cond_destroy(korp_cond *cond);
 int _vm_cond_destroy(korp_cond *cond);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #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 cond  pointer to condition variable
  * @param mutex  pointer to mutex to protect the 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);
 int _vm_cond_wait(korp_cond *cond, korp_mutex *mutex);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #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 mutex  pointer to mutex to protect the condition variable
  * @param mills  milliseconds to wait
  * @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);
 int _vm_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, int mills);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #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
  * @param cond  condition variable
  *
  *
- * @return BH_SUCCESS if success
+ * @return 0 if success
  */
  */
 int _vm_cond_signal(korp_cond *cond);
 int _vm_cond_signal(korp_cond *cond);
 #ifdef _INSTRUMENT_TEST_ENABLED
 #ifdef _INSTRUMENT_TEST_ENABLED

+ 0 - 1
core/shared-lib/platform/include/bh_time.h

@@ -22,7 +22,6 @@ extern "C" {
 #endif
 #endif
 
 
 #include "bh_config.h"
 #include "bh_config.h"
-#include "bh_definition.h"
 #include "bh_types.h"
 #include "bh_types.h"
 #include "bh_platform.h"
 #include "bh_platform.h"
 
 

+ 5 - 14
core/shared-lib/platform/include/bh_types.h

@@ -28,25 +28,16 @@ typedef int int32;
 typedef float float32;
 typedef float float32;
 typedef double float64;
 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"
 #include "bh_platform.h"
 
 
+#ifndef NULL
+#define NULL (void*)0
+#endif
+
 #ifndef __cplusplus
 #ifndef __cplusplus
 #define true 1
 #define true 1
 #define false 0
 #define false 0
+#define inline __inline
 #endif
 #endif
 
 
 #endif
 #endif

+ 7 - 10
core/shared-lib/platform/linux-sgx/bh_definition.c

@@ -14,15 +14,10 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-#include "bh_definition.h"
 #include "bh_platform.h"
 #include "bh_platform.h"
 
 
-int bh_return(int ret)
-{
-    return ret;
-}
-
 #define RSIZE_MAX 0x7FFFFFFF
 #define RSIZE_MAX 0x7FFFFFFF
+
 int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
 int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
 {
 {
     char *dest = (char*) s1;
     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)
 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;
         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)
 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;
         return -1;
     }
     }
 
 

+ 7 - 10
core/shared-lib/platform/linux/bh_definition.c

@@ -14,15 +14,10 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-#include "bh_definition.h"
 #include "bh_platform.h"
 #include "bh_platform.h"
 
 
-int bh_return(int ret)
-{
-    return ret;
-}
-
 #define RSIZE_MAX 0x7FFFFFFF
 #define RSIZE_MAX 0x7FFFFFFF
+
 int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
 int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
 {
 {
     char *dest = (char*) s1;
     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)
 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;
         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)
 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;
         return -1;
     }
     }
 
 

+ 6 - 9
core/shared-lib/platform/vxworks/bh_definition.c

@@ -14,13 +14,9 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-#include "bh_definition.h"
 #include "bh_platform.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)
 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)
 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;
         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)
 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;
         return -1;
     }
     }
 
 

+ 2 - 2
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;
     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");
         printf("Read file to buffer failed: alloc memory failed.\n");
         close(file);
         close(file);
         return NULL;
         return NULL;
@@ -76,7 +76,7 @@ bh_read_file_to_buffer(const char *filename, int *ret_size)
 
 
     if (read_size < file_size) {
     if (read_size < file_size) {
         printf("Read file to buffer failed: read file content failed.\n");
         printf("Read file to buffer failed: read file content failed.\n");
-        wasm_free(buffer);
+        bh_free(buffer);
         return NULL;
         return NULL;
     }
     }
 
 

+ 2 - 0
core/shared-lib/platform/vxworks/bh_platform.h

@@ -26,6 +26,8 @@
 #include <time.h>
 #include <time.h>
 #include <string.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
 #include <assert.h>
 #include <assert.h>
 #include <stdarg.h>
 #include <stdarg.h>
 #include <ctype.h>
 #include <ctype.h>

+ 6 - 10
core/shared-lib/platform/zephyr/bh_definition.c

@@ -14,15 +14,10 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-#include "bh_definition.h"
 #include "bh_platform.h"
 #include "bh_platform.h"
 
 
-int bh_return(int ret)
-{
-    return ret;
-}
-
 #define RSIZE_MAX 0x7FFFFFFF
 #define RSIZE_MAX 0x7FFFFFFF
+
 int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
 int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
 {
 {
     char *dest = (char*) s1;
     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)
 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;
         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)
 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;
         return -1;
     }
     }