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

And fix compile issues of vxworks
This commit is contained in:
wenyongh 2019-11-04 18:56:27 -06:00 committed by GitHub
parent 28993946ad
commit 49127efa99
24 changed files with 102 additions and 129 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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))) {

View File

@ -28,7 +28,6 @@
#include "conn_tcp.h"
#include "conn_udp.h"
#include "conn_uart.h"
#include "bh_definition.h"
#include <unistd.h>
#include <sys/epoll.h>
@ -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;
}

View File

@ -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)

View File

@ -19,9 +19,9 @@
#endif
#include <stdlib.h>
#include <string.h>
#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"

View File

@ -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 ()

1
core/shared-lib/include/bh_common.h Executable file → Normal file
View File

@ -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"

View File

@ -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

View File

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

View File

@ -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;

2
core/shared-lib/include/jeff_export.h Executable file → Normal file
View File

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

View File

@ -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,

View File

@ -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;
}

View File

@ -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: */

View File

@ -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

View File

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

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

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

View File

@ -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;
}