re-org bh_definition.c && introduce wamr fast interpreter (#189)
Co-authored-by: Xu Jun
This commit is contained in:
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
#define RSIZE_MAX 0x7FFFFFFF
|
||||
|
||||
int b_memcpy_s(void * s1, unsigned int s1max,
|
||||
const void * s2, unsigned int n)
|
||||
{
|
||||
char *dest = (char*)s1;
|
||||
char *src = (char*)s2;
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (s1 == NULL || s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
if (s2 == NULL || n > s1max) {
|
||||
memset(dest, 0, s1max);
|
||||
return -1;
|
||||
}
|
||||
memcpy(dest, src, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcat(s1, s2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b_strcpy_s(char * s1, size_t s1max, const char * s2)
|
||||
{
|
||||
if (NULL == s1 || NULL == s2
|
||||
|| s1max < (strlen(s2) + 1)
|
||||
|| s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy(s1, s2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -9,20 +9,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *bh_strdup(const char *s)
|
||||
{
|
||||
uint32 size;
|
||||
char *s1 = NULL;
|
||||
|
||||
if (s) {
|
||||
size = (uint32)(strlen(s) + 1);
|
||||
if ((s1 = bh_malloc(size)))
|
||||
bh_memcpy_s(s1, size, s, size);
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
int bh_platform_init()
|
||||
int
|
||||
bh_platform_init()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
#define RSIZE_MAX 0x7FFFFFFF
|
||||
|
||||
int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
|
||||
{
|
||||
char *dest = (char*) s1;
|
||||
char *src = (char*) s2;
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (s1 == NULL || s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
if (s2 == NULL || n > s1max) {
|
||||
memset(dest, 0, s1max);
|
||||
return -1;
|
||||
}
|
||||
memcpy(dest, src, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcat(s1, s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b_strcpy_s(char * s1, size_t s1max, const char * s2)
|
||||
{
|
||||
if (NULL == s1 || NULL == s2
|
||||
|| s1max < (strlen(s2) + 1)
|
||||
|| s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy(s1, s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fopen_s(FILE ** pFile, const char *filename, const char *mode)
|
||||
{
|
||||
if (NULL == pFile || NULL == filename || NULL == mode) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pFile = fopen(filename, mode);
|
||||
|
||||
if (NULL == *pFile)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -12,20 +12,8 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
char *bh_strdup(const char *s)
|
||||
{
|
||||
uint32 size;
|
||||
char *s1 = NULL;
|
||||
|
||||
if (s) {
|
||||
size = (uint32)(strlen(s) + 1);
|
||||
if ((s1 = bh_malloc(size)))
|
||||
bh_memcpy_s(s1, size, s, size);
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
int bh_platform_init()
|
||||
int
|
||||
bh_platform_init()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -104,8 +104,6 @@ int b_memcpy_s(void * s1, unsigned int s1max, const void * s2,
|
||||
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 fopen_s(FILE ** pFile, const char *filename, const char *mode);
|
||||
|
||||
char *bh_read_file_to_buffer(const char *filename, uint32 *ret_size);
|
||||
|
||||
char *bh_strdup(const char *s);
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
#ifdef RSIZE_MAX
|
||||
#undef RSIZE_MAX
|
||||
#endif
|
||||
|
||||
#define RSIZE_MAX 0x7FFFFFFF
|
||||
|
||||
int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
|
||||
{
|
||||
char *dest = (char*) s1;
|
||||
char *src = (char*) s2;
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (s1 == NULL || s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
if (s2 == NULL || n > s1max) {
|
||||
memset(dest, 0, s1max);
|
||||
return -1;
|
||||
}
|
||||
memcpy(dest, src, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcat(s1, s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b_strcpy_s(char * s1, size_t s1max, const char * s2)
|
||||
{
|
||||
if (NULL == s1 || NULL == s2
|
||||
|| s1max < (strlen(s2) + 1)
|
||||
|| s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy(s1, s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fopen_s(FILE ** pFile, const char *filename, const char *mode)
|
||||
{
|
||||
if (NULL == pFile || NULL == filename || NULL == mode) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pFile = fopen(filename, mode);
|
||||
|
||||
if (NULL == *pFile)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -12,20 +12,8 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
char *bh_strdup(const char *s)
|
||||
{
|
||||
uint32 size;
|
||||
char *s1 = NULL;
|
||||
|
||||
if (s) {
|
||||
size = (uint32)(strlen(s) + 1);
|
||||
if ((s1 = bh_malloc(size)))
|
||||
bh_memcpy_s(s1, size, s, size);
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
int bh_platform_init()
|
||||
int
|
||||
bh_platform_init()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -101,8 +101,6 @@ int b_memcpy_s(void * s1, unsigned int s1max, const void * s2,
|
||||
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 fopen_s(FILE ** pFile, const char *filename, const char *mode);
|
||||
|
||||
char *bh_read_file_to_buffer(const char *filename, uint32 *ret_size);
|
||||
|
||||
char *bh_strdup(const char *s);
|
||||
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
#define RSIZE_MAX 0x7FFFFFFF
|
||||
|
||||
int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
|
||||
{
|
||||
char *dest = (char*) s1;
|
||||
char *src = (char*) s2;
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (s1 == NULL || s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
if (s2 == NULL || n > s1max) {
|
||||
memset(dest, 0, s1max);
|
||||
return -1;
|
||||
}
|
||||
memcpy(dest, src, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncat(s1, s2, strlen(s2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b_strcpy_s(char * s1, size_t s1max, const char * s2)
|
||||
{
|
||||
if (NULL == s1 || NULL == s2
|
||||
|| s1max < (strlen(s2) + 1)
|
||||
|| s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(s1, s2, s1max);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -14,19 +14,6 @@
|
||||
#define FIXED_BUFFER_SIZE (1<<9)
|
||||
static bh_print_function_t print_function = NULL;
|
||||
|
||||
char *bh_strdup(const char *s)
|
||||
{
|
||||
uint32 size;
|
||||
char *s1 = NULL;
|
||||
|
||||
if (s) {
|
||||
size = (uint32)(strlen(s) + 1);
|
||||
if ((s1 = bh_malloc(size)))
|
||||
bh_memcpy_s(s1, size, s, size);
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
int bh_platform_init()
|
||||
{
|
||||
return 0;
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
#define RSIZE_MAX 0x7FFFFFFF
|
||||
|
||||
int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
|
||||
{
|
||||
char *dest = (char*) s1;
|
||||
char *src = (char*) s2;
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (s1 == NULL || s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
if (s2 == NULL || n > s1max) {
|
||||
memset(dest, 0, s1max);
|
||||
return -1;
|
||||
}
|
||||
memcpy(dest, src, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcat(s1, s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b_strcpy_s(char * s1, size_t s1max, const char * s2)
|
||||
{
|
||||
if (NULL == s1 || NULL == s2
|
||||
|| s1max < (strlen(s2) + 1)
|
||||
|| s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy(s1, s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fopen_s(FILE ** pFile, const char *filename, const char *mode)
|
||||
{
|
||||
if (NULL == pFile || NULL == filename || NULL == mode) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pFile = fopen(filename, mode);
|
||||
|
||||
if (NULL == *pFile)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -12,20 +12,8 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
char *bh_strdup(const char *s)
|
||||
{
|
||||
uint32 size;
|
||||
char *s1 = NULL;
|
||||
|
||||
if (s) {
|
||||
size = (uint32)(strlen(s) + 1);
|
||||
if ((s1 = bh_malloc(size)))
|
||||
bh_memcpy_s(s1, size, s, size);
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
int bh_platform_init()
|
||||
int
|
||||
bh_platform_init()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -102,8 +102,6 @@ int b_memcpy_s(void * s1, unsigned int s1max, const void * s2,
|
||||
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 fopen_s(FILE ** pFile, const char *filename, const char *mode);
|
||||
|
||||
char *bh_read_file_to_buffer(const char *filename, uint32 *ret_size);
|
||||
|
||||
char *bh_strdup(const char *s);
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
#define RSIZE_MAX 0x7FFFFFFF
|
||||
|
||||
int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
|
||||
{
|
||||
char *dest = (char*) s1;
|
||||
char *src = (char*) s2;
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (s1 == NULL || s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
if (s2 == NULL || n > s1max) {
|
||||
memset(dest, 0, s1max);
|
||||
return -1;
|
||||
}
|
||||
memcpy(dest, src, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcat(s1, s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b_strcpy_s(char * s1, size_t s1max, const char * s2)
|
||||
{
|
||||
if (NULL == s1 || NULL == s2
|
||||
|| s1max < (strlen(s2) + 1)
|
||||
|| s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy(s1, s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -16,21 +16,8 @@
|
||||
#include <dlfcn.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
|
||||
char *bh_strdup(const char *s)
|
||||
{
|
||||
uint32 size;
|
||||
char *s1 = NULL;
|
||||
|
||||
if (s) {
|
||||
size = (uint32)(strlen(s) + 1);
|
||||
if ((s1 = bh_malloc(size)))
|
||||
bh_memcpy_s(s1, size, s, size);
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
int bh_platform_init()
|
||||
int
|
||||
bh_platform_init()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
#define RSIZE_MAX 0x7FFFFFFF
|
||||
|
||||
int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
|
||||
{
|
||||
char *dest = (char*) s1;
|
||||
char *src = (char*) s2;
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (s1 == NULL || s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
if (s2 == NULL || n > s1max) {
|
||||
memset(dest, 0, s1max);
|
||||
return -1;
|
||||
}
|
||||
memcpy(dest, src, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcat(s1, s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b_strcpy_s(char * s1, size_t s1max, const char * s2)
|
||||
{
|
||||
if (NULL == s1|| NULL == s2
|
||||
|| s1max < (strlen(s2) + 1) || s1max > RSIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy(s1, s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -12,19 +12,6 @@
|
||||
#include <arch/arm/aarch32/cortex_m/cmsis.h>
|
||||
#endif
|
||||
|
||||
char *bh_strdup(const char *s)
|
||||
{
|
||||
uint32 size;
|
||||
char *s1 = NULL;
|
||||
|
||||
if (s) {
|
||||
size = (uint32)(strlen(s) + 1);
|
||||
if ((s1 = bh_malloc(size)))
|
||||
bh_memcpy_s(s1, size, s, size);
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
/**
|
||||
* This function will allow execute from sram region.
|
||||
@ -54,7 +41,8 @@ _stdout_hook_iwasm(int c)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bh_platform_init()
|
||||
int
|
||||
bh_platform_init()
|
||||
{
|
||||
extern void __stdout_hook_install(int (*hook)(int));
|
||||
/* Enable printf() in Zephyr */
|
||||
|
||||
Reference in New Issue
Block a user