Compare commits
6 Commits
ef3b3eee85
...
WAMR-2.4.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
fd69a4e76e
|
|||
|
3318609c59
|
|||
|
8fd8bc7b0f
|
|||
|
4c1c1875fc
|
|||
|
ca3a01d7fc
|
|||
|
0002e68b1c
|
@ -183,6 +183,14 @@ set_target_properties (vmlib PROPERTIES PUBLIC_HEADER "${WAMR_PUBLIC_HEADERS}")
|
|||||||
|
|
||||||
set_version_info (vmlib)
|
set_version_info (vmlib)
|
||||||
|
|
||||||
|
message("CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
||||||
|
message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
|
||||||
|
message("CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}")
|
||||||
|
message("CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}")
|
||||||
|
message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
||||||
|
message("CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||||
|
message("CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||||
|
|
||||||
install (TARGETS vmlib
|
install (TARGETS vmlib
|
||||||
EXPORT iwasmTargets
|
EXPORT iwasmTargets
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
|
|||||||
@ -1,5 +1,15 @@
|
|||||||
#include "platform_api_vmcore.h"
|
#include "platform_api_vmcore.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
os_dcache_flush(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
os_icache_flush(void *start, size_t len)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_cond_init(korp_cond *cond)
|
os_cond_init(korp_cond *cond)
|
||||||
{
|
{
|
||||||
@ -18,80 +28,71 @@ os_dumps_proc_mem_info(char *out, unsigned int size)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((weak)) void
|
|
||||||
bh_print_proc_mem(const char *prompt)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((weak)) void
|
|
||||||
bh_log_proc_mem(const char *function, uint32 line)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************
|
|
||||||
* string
|
|
||||||
****************************************************/
|
|
||||||
|
|
||||||
// void *
|
|
||||||
// memcpy(void *restrict dest, const void *restrict src, size_t n)
|
|
||||||
// {
|
|
||||||
// unsigned char *d = (unsigned char *)dest;
|
|
||||||
// const unsigned char *s = (const unsigned char *)src;
|
|
||||||
//
|
|
||||||
// while (n--)
|
|
||||||
// *d++ = *s++;
|
|
||||||
//
|
|
||||||
// return dest;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void *
|
|
||||||
// memmove(void *dest, const void *src, size_t n)
|
|
||||||
// {
|
|
||||||
// unsigned char *d = (unsigned char *)dest;
|
|
||||||
// const unsigned char *s = (const unsigned char *)src;
|
|
||||||
//
|
|
||||||
// if (d == s || n == 0)
|
|
||||||
// return dest;
|
|
||||||
//
|
|
||||||
// if (d < s) {
|
|
||||||
// /* forward copy */
|
|
||||||
// while (n--)
|
|
||||||
// *d++ = *s++;
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// /* backward copy */
|
|
||||||
// d += n;
|
|
||||||
// s += n;
|
|
||||||
// while (n--)
|
|
||||||
// *--d = *--s;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return dest;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void *
|
|
||||||
// memset(void *dest, int c, size_t n)
|
|
||||||
// {
|
|
||||||
// unsigned char *p = dest;
|
|
||||||
// while (n--)
|
|
||||||
// *p++ = (unsigned char)c;
|
|
||||||
// return dest;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
* mman
|
* mman
|
||||||
****************************************************/
|
****************************************************/
|
||||||
|
|
||||||
|
// Need os_mmap for aot_load_from_aot_file
|
||||||
|
//
|
||||||
|
// Stacktrace:
|
||||||
|
// #5 0x0805e5c1 in os_mmap
|
||||||
|
// #6 0x080524d3 in loader_mmap
|
||||||
|
// #7 0x08059294 in create_sections
|
||||||
|
// #8 0x08059553 in load
|
||||||
|
// #9 0x0805966b in aot_load_from_aot_file
|
||||||
|
// #10 0x08048c34 in wasm_runtime_load_ex
|
||||||
|
// #11 0x08048cff in wasm_runtime_load
|
||||||
|
// #12 0x08048112 in main
|
||||||
|
|
||||||
|
// I hope this isn't too simple
|
||||||
|
static uint8_t mmap_space[MMAP_SPACE_SIZE];
|
||||||
|
static size_t mmap_offset = 0; // Free space begins here
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
align_up(size_t x, size_t a)
|
||||||
|
{
|
||||||
|
// a is a power of two, e.g., 8:
|
||||||
|
// x+a-1: Shift value upwards to the next alignment "bucket"
|
||||||
|
// a-1: 00000111, ~(a-1): 11111000 - Clears the lower bits/alignment
|
||||||
|
// remainder
|
||||||
|
return (x + a - 1) & ~(a - 1);
|
||||||
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
|
os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
|
||||||
{
|
{
|
||||||
return NULL;
|
// Free space begins here (aligned)
|
||||||
|
size_t start = align_up(mmap_offset, PAGE_SIZE);
|
||||||
|
|
||||||
|
// How much we're mapping
|
||||||
|
size_t end = start + align_up(size, PAGE_SIZE);
|
||||||
|
|
||||||
|
if (end > MMAP_SPACE_SIZE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *ptr = &mmap_space[start];
|
||||||
|
mmap_offset = end;
|
||||||
|
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
os_mremap(void *old_addr, size_t old_size, size_t new_size)
|
os_mremap(void *old_addr, size_t old_size, size_t new_size)
|
||||||
{
|
{
|
||||||
return NULL;
|
// Map the new size
|
||||||
|
void *new_addr = os_mmap(NULL, new_size, 0, 0, -1);
|
||||||
|
if (!new_addr) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy the old memory to the new mapped address
|
||||||
|
if (old_addr) {
|
||||||
|
size_t copy_size = old_size < new_size ? old_size : new_size;
|
||||||
|
memcpy(new_addr, old_addr, copy_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -105,22 +106,6 @@ os_mprotect(void *addr, size_t size, int prot)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************
|
|
||||||
* math
|
|
||||||
****************************************************/
|
|
||||||
|
|
||||||
double
|
|
||||||
sqrt(double x)
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
sqrtf(float x)
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
* Section 1 *
|
* Section 1 *
|
||||||
* Interfaces required by the runtime *
|
* Interfaces required by the runtime *
|
||||||
|
|||||||
@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
// #include <assert.h>
|
// #include <assert.h>
|
||||||
// #include <time.h>
|
// #include <time.h>
|
||||||
// #include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
// #include <stdlib.h>
|
|
||||||
// #include <math.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
// #include <ctype.h>
|
// #include <ctype.h>
|
||||||
// #include <pthread.h>
|
// #include <pthread.h>
|
||||||
// #include <signal.h>
|
// #include <signal.h>
|
||||||
@ -42,6 +43,9 @@ extern "C" {
|
|||||||
#define BH_APPLET_PRESERVED_STACK_SIZE (8 * 1024)
|
#define BH_APPLET_PRESERVED_STACK_SIZE (8 * 1024)
|
||||||
#define BH_THREAD_DEFAULT_PRIORITY 0
|
#define BH_THREAD_DEFAULT_PRIORITY 0
|
||||||
|
|
||||||
|
#define PAGE_SIZE 4096
|
||||||
|
#define MMAP_SPACE_SIZE (2 * 1024 * 1024)
|
||||||
|
|
||||||
typedef int korp_tid;
|
typedef int korp_tid;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int dummy;
|
int dummy;
|
||||||
@ -77,17 +81,9 @@ os_get_invalid_handle(void)
|
|||||||
static inline int
|
static inline int
|
||||||
os_getpagesize()
|
os_getpagesize()
|
||||||
{
|
{
|
||||||
// TODO: What pagesize? 65536?
|
return PAGE_SIZE;
|
||||||
return 4096;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// void *
|
|
||||||
// memcpy(void *restrict dest, const void *restrict src, size_t n);
|
|
||||||
// void *
|
|
||||||
// memmove(void *dest, const void *src, size_t n);
|
|
||||||
// void *
|
|
||||||
// memset(void *dest, int c, size_t n);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -5,8 +5,6 @@ add_definitions(-DBH_PLATFORM_BAREMETAL)
|
|||||||
include_directories(${PLATFORM_SHARED_DIR})
|
include_directories(${PLATFORM_SHARED_DIR})
|
||||||
|
|
||||||
include_directories(${PLATFORM_SHARED_DIR}/../include)
|
include_directories(${PLATFORM_SHARED_DIR}/../include)
|
||||||
# file (GLOB header ${PLATFORM_SHARED_DIR}/../include/baremetal/*.h)
|
|
||||||
# list (APPEND RUNTIME_LIB_HEADER_LIST ${header})
|
|
||||||
|
|
||||||
file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c)
|
file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c)
|
||||||
set (PLATFORM_SHARED_SOURCE ${source_all})
|
set (PLATFORM_SHARED_SOURCE ${source_all})
|
||||||
|
|||||||
Reference in New Issue
Block a user