Enable AoT and wamr-sdk, and change arguments of call wasm API (#157)
* Implement memory profiler, optimize memory usage, modify code indent * Implement memory.grow and limit heap space base offset to 1G; modify iwasm build type to Release and 64 bit by default * Add a new extension library: connection * Fix bug of reading magic number and version in big endian platform * Re-org platform APIs: move most platform APIs from iwasm to shared-lib * Enhance wasm loader to fix some security issues * Fix issue about illegal load of EXC_RETURN into PC on stm32 board * Updates that let a restricted version of the interpreter run in SGX * Enable native/app address validation and conversion for wasm app * Remove wasm_application_exectue_* APIs from wasm_export.h which makes confused * Refine binary size and fix several minor issues Optimize interpreter LOAD/STORE opcodes to decrease the binary size Fix issues when using iwasm library: _bh_log undefined, bh_memory.h not found Remove unused _stdin/_stdout/_stderr global variables resolve in libc wrapper Add macros of global heap size, stack size, heap size for Zephyr main.c Clear compile warning of wasm_application.c * Add more strict security checks for libc wrapper API's * Use one libc wrapper copy for sgx and other platforms; remove bh_printf macro for other platform header files * Enhance security of libc strcpy/sprintf wrapper function * Fix issue of call native for x86_64/arm/mips, add module inst parameter for native wrapper functions * Remove get_module_inst() and fix issue of call native * Refine wgl lib: remove module_inst parameter from widget functions; move function index check to runtime instantiate * Refine interpreter call native process, refine memory boudary check * Fix issues of invokeNative function of arm/mips/general version * Add a switch to build simple sample without gui support * Add BUILD_TARGET setting in makefile to replace cpu compiler flags in source code * Re-org shared lib header files, remove unused info; fix compile issues of vxworks * Add build target general * Remove unused files * Update license header * test push * Restore file * Sync up with internal/feature * Sync up with internal/feature * Rename build_wamr_app to build_wasm_app * Fix small issues of README * Enhance malformed wasm file checking Fix issue of print hex int and implement utf8 string check Fix wasi file read/write right issue Fix minor issue of build wasm app doc * Sync up with internal/feature * Sync up with internal/feature: fix interpreter arm issue, fix read leb issue * Sync up with internal/feature * Fix bug of config.h and rename wasi config.h to ssp_config.h * Sync up with internal/feature * Import wamr aot * update document * update document * Update document, disable WASI in 32bit * update document * remove files * update document * Update document * update document * update document * update samples * Sync up with internal repo
This commit is contained in:
34
core/shared/include/bh_common.h
Normal file
34
core/shared/include/bh_common.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _BH_COMMON_H
|
||||
#define _BH_COMMON_H
|
||||
|
||||
#include "bh_assert.h"
|
||||
#include "bh_platform.h"
|
||||
#include "bh_list.h"
|
||||
|
||||
typedef void (*bh_print_function_t)(const char* message);
|
||||
void bh_set_print_function(bh_print_function_t pf);
|
||||
|
||||
#define bh_memcpy_s(dest, dlen, src, slen) do { \
|
||||
int _ret = slen == 0 ? 0 : b_memcpy_s (dest, dlen, src, slen); \
|
||||
(void)_ret; \
|
||||
bh_assert (_ret == 0); \
|
||||
} while (0)
|
||||
|
||||
#define bh_strcat_s(dest, dlen, src) do { \
|
||||
int _ret = b_strcat_s (dest, dlen, src); \
|
||||
(void)_ret; \
|
||||
bh_assert (_ret == 0); \
|
||||
} while (0)
|
||||
|
||||
#define bh_strcpy_s(dest, dlen, src) do { \
|
||||
int _ret = b_strcpy_s (dest, dlen, src); \
|
||||
(void)_ret; \
|
||||
bh_assert (_ret == 0); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
133
core/shared/include/bh_hashmap.h
Normal file
133
core/shared/include/bh_hashmap.h
Normal file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef WASM_HASHMAP_H
|
||||
#define WASM_HASHMAP_H
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Maximum initial size of hash map */
|
||||
#define HASH_MAP_MAX_SIZE 65536
|
||||
|
||||
struct HashMap;
|
||||
typedef struct HashMap HashMap;
|
||||
|
||||
/* Hash function: to get the hash value of key. */
|
||||
typedef uint32 (*HashFunc)(const void *key);
|
||||
|
||||
/* Key equal function: to check whether two keys are equal. */
|
||||
typedef bool (*KeyEqualFunc)(void *key1, void *key2);
|
||||
|
||||
/* Key destroy function: to destroy the key, auto called
|
||||
when an hash element is removed. */
|
||||
typedef void (*KeyDestroyFunc)(void *key);
|
||||
|
||||
/* Value destroy function: to destroy the value, auto called
|
||||
when an hash element is removed. */
|
||||
typedef void (*ValueDestroyFunc)(void *key);
|
||||
|
||||
/**
|
||||
* Create a hash map.
|
||||
*
|
||||
* @param size: the initial size of the hash map
|
||||
* @param use_lock whether to lock the hash map when operating on it
|
||||
* @param hash_func hash function of the key, must be specified
|
||||
* @param key_equal_func key equal function, check whether two keys
|
||||
* are equal, must be specified
|
||||
* @param key_destroy_func key destroy function, called when an hash element
|
||||
* is removed if it is not NULL
|
||||
* @param value_destroy_func value destroy function, called when an hash
|
||||
* element is removed if it is not NULL
|
||||
*
|
||||
* @return the hash map created, NULL if failed
|
||||
*/
|
||||
HashMap*
|
||||
bh_hash_map_create(uint32 size, bool use_lock,
|
||||
HashFunc hash_func,
|
||||
KeyEqualFunc key_equal_func,
|
||||
KeyDestroyFunc key_destroy_func,
|
||||
ValueDestroyFunc value_destroy_func);
|
||||
|
||||
/**
|
||||
* Insert an element to the hash map
|
||||
*
|
||||
* @param map the hash map to insert element
|
||||
* @key the key of the element
|
||||
* @value the value of the element
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
* Note: fail if key is NULL or duplicated key exists in the hash map,
|
||||
*/
|
||||
bool
|
||||
bh_hash_map_insert(HashMap *map, void *key, void *value);
|
||||
|
||||
/**
|
||||
* Find an element in the hash map
|
||||
*
|
||||
* @param map the hash map to find element
|
||||
* @key the key of the element
|
||||
*
|
||||
* @return the value of the found element if success, NULL otherwise
|
||||
*/
|
||||
void*
|
||||
bh_hash_map_find(HashMap *map, void *key);
|
||||
|
||||
/**
|
||||
* Update an element in the hash map with new value
|
||||
*
|
||||
* @param map the hash map to update element
|
||||
* @key the key of the element
|
||||
* @value the new value of the element
|
||||
* @p_old_value if not NULL, copies the old value to it
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
* Note: the old value won't be destroyed by value destroy function,
|
||||
* it will be copied to p_old_value for user to process.
|
||||
*/
|
||||
bool
|
||||
bh_hash_map_update(HashMap *map, void *key, void *value,
|
||||
void **p_old_value);
|
||||
|
||||
/**
|
||||
* Remove an element from the hash map
|
||||
*
|
||||
* @param map the hash map to remove element
|
||||
* @key the key of the element
|
||||
* @p_old_key if not NULL, copies the old key to it
|
||||
* @p_old_value if not NULL, copies the old value to it
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
* Note: the old key and old value won't be destroyed by key destroy
|
||||
* function and value destroy function, they will be copied to
|
||||
* p_old_key and p_old_value for user to process.
|
||||
*/
|
||||
bool
|
||||
bh_hash_map_remove(HashMap *map, void *key,
|
||||
void **p_old_key, void **p_old_value);
|
||||
|
||||
/**
|
||||
* Destroy the hashmap
|
||||
*
|
||||
* @param map the hash map to destroy
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
* Note: the key destroy function and value destroy function will be
|
||||
* called to destroy each element's key and value if they are
|
||||
* not NULL.
|
||||
*/
|
||||
bool
|
||||
bh_hash_map_destroy(HashMap *map);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* endof WASM_HASHMAP_H */
|
||||
|
||||
109
core/shared/include/bh_list.h
Normal file
109
core/shared/include/bh_list.h
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _BH_LIST_H
|
||||
#define _BH_LIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "bh_types.h" /*For bool type*/
|
||||
#include "bh_platform.h"
|
||||
|
||||
/* List user should embedded bh_list_link into list elem data structure
|
||||
* definition. And bh_list_link data field should be the first field.
|
||||
* For example, if we would like to use bh_list for our own data type A,
|
||||
* A must be defined as a structure like below:
|
||||
* struct A {
|
||||
* bh_list_link l;
|
||||
* ...
|
||||
* };
|
||||
*
|
||||
* bh_list_link is defined as a structure (not typedef void*).
|
||||
* It will make extend list into bi-direction easy.
|
||||
*/
|
||||
typedef struct _bh_list_link {
|
||||
struct _bh_list_link *next;
|
||||
} bh_list_link;
|
||||
|
||||
typedef struct _bh_list {
|
||||
bh_list_link head;
|
||||
uint32 len;
|
||||
} bh_list;
|
||||
|
||||
/* Beihai list operation return value */
|
||||
typedef enum _bh_list_status {
|
||||
BH_LIST_SUCCESS = 0, BH_LIST_ERROR = -1
|
||||
} bh_list_status;
|
||||
|
||||
/**
|
||||
* Initialize a list.
|
||||
*
|
||||
* @param list pointer to list.
|
||||
* @return <code>BH_LIST_ERROR</code> if OK;
|
||||
* <code>BH_LIST_ERROR</code> if list pointer is NULL.
|
||||
*/
|
||||
bh_list_status bh_list_init(bh_list *list);
|
||||
|
||||
/**
|
||||
* Insert an elem pointer into list. The list node memory is maintained by list while
|
||||
* elem memory is the responsibility of list user.
|
||||
*
|
||||
* @param list pointer to list.
|
||||
* @param elem pointer to elem that will be inserted into list.
|
||||
* @return <code>BH_LIST_ERROR</code> if OK;
|
||||
* <code>BH_LIST_ERROR</code> if input is invalid or no memory available.
|
||||
*/
|
||||
extern bh_list_status _bh_list_insert(bh_list *list, void *elem);
|
||||
|
||||
#ifdef _INSTRUMENT_TEST_ENABLED
|
||||
extern bh_list_status bh_list_insert_instr(bh_list *list, void *elem, const char*func_name);
|
||||
#define bh_list_insert(list, elem) bh_list_insert_instr(list, elem, __FUNCTION__)
|
||||
#else
|
||||
#define bh_list_insert _bh_list_insert
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Remove an elem pointer from list. The list node memory is maintained by list while
|
||||
* elem memory is the responsibility of list user.
|
||||
*
|
||||
* @param list pointer to list.
|
||||
* @param elem pointer to elem that will be inserted into list.
|
||||
* @return <code>BH_LIST_ERROR</code> if OK;
|
||||
* <code>BH_LIST_ERROR</code> if element does not exist in given list.
|
||||
*/
|
||||
bh_list_status bh_list_remove(bh_list *list, void *elem);
|
||||
|
||||
/**
|
||||
* Get the list length.
|
||||
*
|
||||
* @param list pointer to list.
|
||||
* @return the length of the list.
|
||||
*/
|
||||
uint32 bh_list_length(bh_list *list);
|
||||
|
||||
/**
|
||||
* Get the first elem in the list.
|
||||
*
|
||||
* @param list pointer to list.
|
||||
* @return pointer to the first node.
|
||||
*/
|
||||
void* bh_list_first_elem(bh_list *list);
|
||||
|
||||
/**
|
||||
* Get the next elem of given list input elem.
|
||||
*
|
||||
* @param node pointer to list node.
|
||||
* @return pointer to next list node.
|
||||
*/
|
||||
void* bh_list_elem_next(void *node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _BH_LIST_H */
|
||||
|
||||
144
core/shared/include/bh_log.h
Normal file
144
core/shared/include/bh_log.h
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
/**
|
||||
* @file bh_log.h
|
||||
* @date Tue Nov 8 18:19:10 2011
|
||||
*
|
||||
* @brief This log system supports wrapping multiple outputs into one
|
||||
* log message. This is useful for outputting variable-length logs
|
||||
* without additional memory overhead (the buffer for concatenating
|
||||
* the message), e.g. exception stack trace, which cannot be printed
|
||||
* by a single log calling without the help of an additional buffer.
|
||||
* Avoiding additional memory buffer is useful for resource-constraint
|
||||
* systems. It can minimize the impact of log system on applications
|
||||
* and logs can be printed even when no enough memory is available.
|
||||
* Functions with prefix "_" are private functions. Only macros that
|
||||
* are not start with "_" are exposed and can be used.
|
||||
*/
|
||||
|
||||
#ifndef _BH_LOG_H
|
||||
#define _BH_LOG_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "bh_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The following functions are the primitive operations of this log
|
||||
* system. A normal usage of the log system is to call bh_log_printf
|
||||
* or bh_log_vprintf one or multiple times and then call bh_log_commit
|
||||
* to wrap (mark) the previous outputs into one log message. The
|
||||
* bh_log and macros LOG_ERROR etc. can be used to output log messages
|
||||
* that can be wrapped into one log calling.
|
||||
*/
|
||||
int _bh_log_init(void);
|
||||
void _bh_log_set_verbose_level(int level);
|
||||
void _bh_log_printf(const char *fmt, ...);
|
||||
void _bh_log_vprintf(const char *fmt, va_list ap);
|
||||
void _bh_log_commit(void);
|
||||
|
||||
#if WASM_ENABLE_LOG != 0
|
||||
# define bh_log_init() _bh_log_init ()
|
||||
# define bh_log_set_verbose_level(l) _bh_log_set_verbose_level (l)
|
||||
# define bh_log_printf(...) _bh_log_printf (__VA_ARGS__)
|
||||
# define bh_log_vprintf(...) _bh_log_vprintf (__VA_ARGS__)
|
||||
# define bh_log_commit() _bh_log_commit ()
|
||||
#else /* WASM_ENABLE_LOG != 0 */
|
||||
# define bh_log_init() 0
|
||||
# define bh_log_set_verbose_level(l) (void)0
|
||||
# define bh_log_printf(...) (void)0
|
||||
# define bh_log_vprintf(...) (void)0
|
||||
# define bh_log_commit() (void)0
|
||||
#endif /* WASM_ENABLE_LOG != 0 */
|
||||
|
||||
void _bh_log(const char *tag, const char *file, int line, const char *fmt, ...);
|
||||
|
||||
/* Always print fatal message */
|
||||
# define LOG_FATAL(...) _bh_log ("V0.", NULL, 0, __VA_ARGS__)
|
||||
|
||||
#if WASM_ENABLE_LOG != 0
|
||||
# define LOG_ERROR(...) _bh_log ("V1.", NULL, 0, __VA_ARGS__)
|
||||
# define LOG_WARNING(...) _bh_log ("V2.", NULL, 0, __VA_ARGS__)
|
||||
# define LOG_INFO_RELEASE(...) _bh_log ("V3.", NULL, 0, __VA_ARGS__)
|
||||
# define LOG_INFO_APP_DEV(...) _bh_log ("V4.", NULL, 0, __VA_ARGS__)
|
||||
# define LOG_VERBOSE(...) _bh_log ("V5.", NULL, 0, __VA_ARGS__)
|
||||
# if BEIHAI_ENABLE_MEMORY_PROFILING != 0
|
||||
# define LOG_PROFILE(...) _bh_log ("V3.", NULL, 0, __VA_ARGS__)
|
||||
# else
|
||||
# define LOG_PROFILE(...) (void)0
|
||||
#endif
|
||||
# if BEIHAI_ENABLE_QUEUE_PROFILING != 0
|
||||
# define LOG_QUEUE_PROFILE(...) _bh_log ("V3.", NULL, 0, __VA_ARGS__)
|
||||
# else
|
||||
# define LOG_QUEUE_PROFILE(...) (void)0
|
||||
#endif
|
||||
# if BEIHAI_ENABLE_GC_STAT_PROFILING != 0
|
||||
# define LOG_GC_STAT_PROFILE(...) _bh_log ("V3.", NULL, 0, __VA_ARGS__)
|
||||
# else
|
||||
# define LOG_GC_STAT_PROFILE(...) (void)0
|
||||
#endif
|
||||
#else /* WASM_ENABLE_LOG != 0 */
|
||||
# define LOG_ERROR(...) (void)0
|
||||
# define LOG_WARNING(...) (void)0
|
||||
# define LOG_INFO_APP_DEV(...) (void)0
|
||||
# define LOG_INFO_RELEASE(...) (void)0
|
||||
# define LOG_VERBOSE(...) (void)0
|
||||
# define LOG_PROFILE(...) (void)0
|
||||
# define LOG_QUEUE_PROFILE(...) (void)0
|
||||
# define LOG_GC_STAT_PROFILE(...) (void)0
|
||||
#endif /* WASM_ENABLE_LOG != 0 */
|
||||
|
||||
#define LOG_PROFILE_INSTANCE_HEAP_CREATED(heap) \
|
||||
LOG_PROFILE ("PROF.INSTANCE.HEAP_CREATED: HEAP=%08X", heap)
|
||||
#define LOG_PROFILE_INSTANCE_THREAD_STARTED(heap) \
|
||||
LOG_PROFILE ("PROF.INSTANCE.THREAD_STARTED: HEAP=%08X", heap)
|
||||
#define LOG_PROFILE_HEAP_ALLOC(heap, size) \
|
||||
LOG_PROFILE ("PROF.HEAP.ALLOC: HEAP=%08X SIZE=%d", heap, size)
|
||||
#define LOG_PROFILE_HEAP_FREE(heap, size) \
|
||||
LOG_PROFILE ("PROF.HEAP.FREE: HEAP=%08X SIZE=%d", heap, size)
|
||||
#define LOG_PROFILE_HEAP_NEW(heap, size) \
|
||||
LOG_PROFILE ("PROF.HEAP.NEW: HEAP=%08X SIZE=%d", heap, size)
|
||||
#define LOG_PROFILE_HEAP_GC(heap, size) \
|
||||
LOG_PROFILE ("PROF.HEAP.GC: HEAP=%08X SIZE=%d", heap, size)
|
||||
#define LOG_PROFILE_STACK_PUSH(used) \
|
||||
LOG_PROFILE ("PROF.STACK.PUSH: USED=%d", used)
|
||||
#define LOG_PROFILE_STACK_POP() \
|
||||
LOG_PROFILE ("PROF.STACK.POP")
|
||||
|
||||
/* Please add your component ahead of LOG_COM_MAX */
|
||||
enum {
|
||||
LOG_COM_APP_MANAGER = 0,
|
||||
LOG_COM_GC,
|
||||
LOG_COM_HMC,
|
||||
LOG_COM_UTILS,
|
||||
LOG_COM_VERIFIER_JEFF,
|
||||
LOG_COM_VMCORE_JEFF,
|
||||
LOG_COM_MAX
|
||||
};
|
||||
|
||||
#if defined(BH_DEBUG)
|
||||
void log_parse_coms(const char *coms);
|
||||
int bh_log_dcom_is_enabled(int component);
|
||||
|
||||
#define LOG_DEBUG(component, ...) do { \
|
||||
if (bh_log_dcom_is_enabled (component)) \
|
||||
_bh_log ("V6: ", __FILE__, __LINE__, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#else /* defined(BH_DEBUG) */
|
||||
|
||||
#define LOG_DEBUG(component, ...) (void)0
|
||||
|
||||
#endif /* defined(BH_DEBUG) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BH_LOG_H */
|
||||
99
core/shared/include/bh_memory.h
Normal file
99
core/shared/include/bh_memory.h
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _BH_MEMORY_H
|
||||
#define _BH_MEMORY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BH_KB (1024)
|
||||
#define BH_MB ((BH_KB)*1024)
|
||||
#define BH_GB ((BH_MB)*1024)
|
||||
|
||||
/**
|
||||
* Initialize memory allocator with a pool, the bh_malloc/bh_free function
|
||||
* will malloc/free memory from the pool
|
||||
*
|
||||
* @param mem the pool buffer
|
||||
* @param bytes the size bytes of the buffer
|
||||
*
|
||||
* @return 0 if success, -1 otherwise
|
||||
*/
|
||||
int bh_memory_init_with_pool(void *mem, unsigned int bytes);
|
||||
|
||||
/**
|
||||
* Initialize memory allocator with memory allocator, the bh_malloc/bh_free
|
||||
* function will malloc/free memory with the allocator passed
|
||||
*
|
||||
* @param malloc_func the malloc function
|
||||
* @param free_func the free function
|
||||
*
|
||||
* @return 0 if success, -1 otherwise
|
||||
*/
|
||||
int bh_memory_init_with_allocator(void *malloc_func, void *free_func);
|
||||
|
||||
/**
|
||||
* Destroy memory
|
||||
*/
|
||||
void bh_memory_destroy();
|
||||
|
||||
/**
|
||||
* Get the pool size of memory, if memory is initialized with allocator,
|
||||
* return 1GB by default.
|
||||
*/
|
||||
unsigned bh_memory_pool_size();
|
||||
|
||||
#if BEIHAI_ENABLE_MEMORY_PROFILING == 0
|
||||
|
||||
/**
|
||||
* This function allocates a memory chunk from system
|
||||
*
|
||||
* @param size bytes need allocate
|
||||
*
|
||||
* @return the pointer to memory allocated
|
||||
*/
|
||||
void* bh_malloc(unsigned int size);
|
||||
|
||||
/**
|
||||
* This function frees memory chunk
|
||||
*
|
||||
* @param ptr the pointer to memory need free
|
||||
*/
|
||||
void bh_free(void *ptr);
|
||||
|
||||
#else
|
||||
|
||||
void* bh_malloc_profile(const char *file, int line, const char *func, unsigned int size);
|
||||
void bh_free_profile(const char *file, int line, const char *func, void *ptr);
|
||||
|
||||
#define bh_malloc(size) bh_malloc_profile(__FILE__, __LINE__, __func__, size)
|
||||
#define bh_free(ptr) bh_free_profile(__FILE__, __LINE__, __func__, ptr)
|
||||
|
||||
/**
|
||||
* Print current memory profiling data
|
||||
*
|
||||
* @param file file name of the caller
|
||||
* @param line line of the file of the caller
|
||||
* @param func function name of the caller
|
||||
*/
|
||||
void memory_profile_print(const char *file, int line, const char *func, int alloc);
|
||||
|
||||
/**
|
||||
* Summarize memory usage and print it out
|
||||
* Can use awk to analyze the output like below:
|
||||
* awk -F: '{print $2,$4,$6,$8,$9}' OFS="\t" ./out.txt | sort -n -r -k 1
|
||||
*/
|
||||
void memory_usage_summarize();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _BH_MEMORY_H */
|
||||
|
||||
84
core/shared/include/bh_queue.h
Normal file
84
core/shared/include/bh_queue.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _BH_QUEUE_H
|
||||
#define _BH_QUEUE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "bh_types.h" /*For bool type*/
|
||||
#include "bh_platform.h"
|
||||
|
||||
struct _bh_queue_node;
|
||||
typedef struct _bh_queue_node * bh_message_t;
|
||||
struct bh_queue;
|
||||
typedef struct bh_queue bh_queue;
|
||||
|
||||
typedef void (*bh_queue_handle_msg_callback)(void *message, void *arg);
|
||||
|
||||
#define bh_queue_malloc bh_malloc
|
||||
#define bh_queue_free bh_free
|
||||
|
||||
#define bh_queue_mutex korp_mutex
|
||||
#define bh_queue_sem korp_sem
|
||||
#define bh_queue_cond korp_cond
|
||||
|
||||
#define bh_queue_mutex_init vm_mutex_init
|
||||
#define bh_queue_mutex_destroy vm_mutex_destroy
|
||||
#define bh_queue_mutex_lock vm_mutex_lock
|
||||
#define bh_queue_mutex_unlock vm_mutex_unlock
|
||||
|
||||
#define bh_queue_sem_init vm_sem_init
|
||||
#define bh_queue_sem_destroy vm_sem_destroy
|
||||
#define bh_queue_sem_wait vm_sem_wait
|
||||
#define bh_queue_sem_reltimedwait vm_sem_reltimedwait
|
||||
#define bh_queue_sem_post vm_sem_post
|
||||
|
||||
#define bh_queue_cond_init vm_cond_init
|
||||
#define bh_queue_cond_destroy vm_cond_destroy
|
||||
#define bh_queue_cond_wait vm_cond_wait
|
||||
#define bh_queue_cond_timedwait vm_cond_reltimedwait
|
||||
#define bh_queue_cond_signal vm_cond_signal
|
||||
#define bh_queue_cond_broadcast vm_cond_broadcast
|
||||
|
||||
typedef void (*bh_msg_cleaner)(void *msg);
|
||||
|
||||
bh_queue *
|
||||
bh_queue_create();
|
||||
|
||||
void
|
||||
bh_queue_destroy(bh_queue *queue);
|
||||
|
||||
char * bh_message_payload(bh_message_t message);
|
||||
uint32 bh_message_payload_len(bh_message_t message);
|
||||
int bh_message_type(bh_message_t message);
|
||||
|
||||
bh_message_t bh_new_msg(unsigned short tag, void *body, unsigned int len,
|
||||
void * handler);
|
||||
void bh_free_msg(bh_message_t msg);
|
||||
bool bh_post_msg(bh_queue *queue, unsigned short tag, void *body,
|
||||
unsigned int len);
|
||||
bool bh_post_msg2(bh_queue *queue, bh_message_t msg);
|
||||
|
||||
bh_message_t bh_get_msg(bh_queue *queue, int timeout);
|
||||
|
||||
unsigned
|
||||
bh_queue_get_message_count(bh_queue *queue);
|
||||
|
||||
void
|
||||
bh_queue_enter_loop_run(bh_queue *queue,
|
||||
bh_queue_handle_msg_callback handle_cb,
|
||||
void *arg);
|
||||
void
|
||||
bh_queue_exit_loop_run(bh_queue *queue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _BH_QUEUE_H */
|
||||
|
||||
126
core/shared/include/bh_vector.h
Normal file
126
core/shared/include/bh_vector.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _WASM_VECTOR_H
|
||||
#define _WASM_VECTOR_H
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DEFAULT_VECTOR_INIT_SIZE 8
|
||||
|
||||
typedef struct Vector {
|
||||
/* size of each element */
|
||||
uint32 size_elem;
|
||||
/* max element number */
|
||||
uint32 max_elements;
|
||||
/* current element num */
|
||||
uint32 num_elements;
|
||||
/* vector data allocated */
|
||||
uint8 *data;
|
||||
} Vector;
|
||||
|
||||
/**
|
||||
* Initialize vector
|
||||
*
|
||||
* @param vector the vector to init
|
||||
* @param init_length the initial length of the vector
|
||||
* @param size_elem size of each element
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
bh_vector_init(Vector *vector, uint32 init_length, uint32 size_elem);
|
||||
|
||||
/**
|
||||
* Set element of vector
|
||||
*
|
||||
* @param vector the vector to set
|
||||
* @param index the index of the element to set
|
||||
* @param elem_buf the element buffer which stores the element data
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
bh_vector_set(Vector *vector, uint32 index, const void *elem_buf);
|
||||
|
||||
/**
|
||||
* Get element of vector
|
||||
*
|
||||
* @param vector the vector to get
|
||||
* @param index the index of the element to get
|
||||
* @param elem_buf the element buffer to store the element data,
|
||||
* whose length must be no less than element size
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
bh_vector_get(const Vector *vector, uint32 index, void *elem_buf);
|
||||
|
||||
/**
|
||||
* Insert element of vector
|
||||
*
|
||||
* @param vector the vector to insert
|
||||
* @param index the index of the element to insert
|
||||
* @param elem_buf the element buffer which stores the element data
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
bh_vector_insert(Vector *vector, uint32 index, const void *elem_buf);
|
||||
|
||||
/**
|
||||
* Append element to the end of vector
|
||||
*
|
||||
* @param vector the vector to append
|
||||
* @param elem_buf the element buffer which stores the element data
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
bh_vector_append(Vector *vector, const void *elem_buf);
|
||||
|
||||
/**
|
||||
* Remove element from vector
|
||||
*
|
||||
* @param vector the vector to remove element
|
||||
* @param index the index of the element to remove
|
||||
* @param old_elem_buf if not NULL, copies the element data to the buffer
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
bh_vector_remove(Vector *vector, uint32 index, void *old_elem_buf);
|
||||
|
||||
/**
|
||||
* Return the size of the vector
|
||||
*
|
||||
* @param vector the vector to get size
|
||||
*
|
||||
* @return return the size of the vector
|
||||
*/
|
||||
uint32
|
||||
bh_vector_size(const Vector *vector);
|
||||
|
||||
/**
|
||||
* Destroy the vector
|
||||
*
|
||||
* @param vector the vector to destroy
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
bh_vector_destroy(Vector *vector);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* endof _WASM_VECTOR_H */
|
||||
|
||||
225
core/shared/include/bni.h
Normal file
225
core/shared/include/bni.h
Normal file
@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
/**
|
||||
* @file bni.h
|
||||
* @date Mon Jul 2 16:54:58 2012
|
||||
*
|
||||
* @brief Beihai native interface.
|
||||
*/
|
||||
|
||||
#ifndef BNI_H
|
||||
#define BNI_H
|
||||
|
||||
#include "bh_types.h"
|
||||
|
||||
/* Primitive types */
|
||||
typedef uint8 jboolean;
|
||||
typedef int8 jbyte;
|
||||
typedef uint16 jchar;
|
||||
typedef int16 jshort;
|
||||
typedef int32 jint;
|
||||
typedef int64 jlong;
|
||||
typedef float jfloat;
|
||||
typedef double jdouble;
|
||||
typedef jint jsize;
|
||||
|
||||
/* Predefined Java class types. */
|
||||
struct _jobject;
|
||||
typedef struct _jobject *jobject;
|
||||
struct _jclass;
|
||||
typedef struct _jclass *jclass;
|
||||
struct _jstring;
|
||||
typedef struct _jstring *jstring;
|
||||
|
||||
/* Values of jboolean: */
|
||||
#define BNI_FALSE 0
|
||||
#define BNI_TRUE 1
|
||||
|
||||
/**
|
||||
* Return the length of the array object.
|
||||
*
|
||||
* @param array Java array object
|
||||
*
|
||||
* @return the length of the Java array
|
||||
*/
|
||||
#define bni_array_length(array) ((jsize)((uint32)(array)->__length >> 2))
|
||||
|
||||
/**
|
||||
* Return the address of the first element of array object.
|
||||
*
|
||||
* @param array Java array object
|
||||
*
|
||||
* @return the address of the first element of array object
|
||||
*/
|
||||
#define bni_array_elem(array) ((array)->__elem)
|
||||
|
||||
/**
|
||||
* Find the Java class with given class name.
|
||||
*
|
||||
* @param name Java class name
|
||||
*
|
||||
* @return class object of the Java class if found, NULL otherwise
|
||||
*
|
||||
* @throws OutOfMemoryError if VM runs out of memory.
|
||||
*/
|
||||
jclass
|
||||
bni_find_class(const char *name);
|
||||
|
||||
/**
|
||||
* Throw an exception of given class with message.
|
||||
*
|
||||
* @param clazz class object of a subclass of java.lang.Throwable
|
||||
* @param msg message for the exception or NULL if no message
|
||||
*
|
||||
* @return 0 if succeeds, nonzero otherwise
|
||||
*/
|
||||
jint
|
||||
bni_throw_new(jclass clazz, const char *msg);
|
||||
|
||||
/**
|
||||
* Throw a NullPointerException.
|
||||
*
|
||||
* @throws NullPointerException
|
||||
*/
|
||||
void
|
||||
bni_throw_npe(void);
|
||||
|
||||
/**
|
||||
* Throw an ArrayIndexOutOfBoundsException
|
||||
*
|
||||
* @param index the index used to access the array
|
||||
*
|
||||
* @throws ArrayIndexOutOfBoundsException
|
||||
*/
|
||||
void
|
||||
bni_throw_aioobe(int index);
|
||||
|
||||
/**
|
||||
* Determine whether an exception is being thrown.
|
||||
*
|
||||
* @return exception object if exception is thrown, NULL otherwise
|
||||
*/
|
||||
jobject
|
||||
bni_exception_occurred(void);
|
||||
|
||||
/**
|
||||
* Print the current exception to error-reporting channel.
|
||||
*/
|
||||
void
|
||||
bni_exception_describe(void);
|
||||
|
||||
/**
|
||||
* Clear the currently thrown exception.
|
||||
*/
|
||||
void
|
||||
bni_exception_clear(void);
|
||||
|
||||
/**
|
||||
* Return the Unicode character number of a string.
|
||||
*
|
||||
* @param str Java string object
|
||||
*
|
||||
* @return the Unicode character number of the string
|
||||
*/
|
||||
jsize
|
||||
bni_string_length(jstring str);
|
||||
|
||||
/**
|
||||
* Return the length in bytes of the modified UTF-8 representation of
|
||||
* a string.
|
||||
*
|
||||
* @param str Java string object
|
||||
* @param start start offset in the string
|
||||
* @param len number of Unicode characters
|
||||
*
|
||||
* @return the UTF-8 length of the string
|
||||
*
|
||||
* @throws StringIndexOutOfBoundsException on index overflow.
|
||||
*/
|
||||
jsize
|
||||
bni_string_utf_length(jstring str, jsize start, jsize len);
|
||||
|
||||
/**
|
||||
* Copies len number of Unicode characters beginning at offset start
|
||||
* to the given buffer buf.
|
||||
*
|
||||
* @param str Java string object
|
||||
* @param start start offset in the string
|
||||
* @param len number of Unicode characters to copy
|
||||
* @param buf buffer for storing the result
|
||||
*/
|
||||
void
|
||||
bni_string_region(jstring str, jsize start, jsize len, jchar *buf);
|
||||
|
||||
/**
|
||||
* Translates len number of Unicode characters beginning at offset
|
||||
* start into modified UTF-8 encoding and place the result in the
|
||||
* given buffer buf.
|
||||
*
|
||||
* @param str Java string object
|
||||
* @param start start offset in the string
|
||||
* @param len number of Unicode characters to copy
|
||||
* @param buf buffer for storing the result
|
||||
*
|
||||
* @throws StringIndexOutOfBoundsException on index overflow.
|
||||
*/
|
||||
void
|
||||
bni_string_utf_region(jstring str, jsize start, jsize len, char *buf);
|
||||
|
||||
/**
|
||||
* Translate Unicode characters into modified UTF-8 encoding and return
|
||||
* the result.
|
||||
*
|
||||
* @param str Java string object
|
||||
*
|
||||
* @return the UTF-8 encoding string if succeeds, NULL otherwise
|
||||
*/
|
||||
char *
|
||||
bni_string_get_utf_chars(jstring str);
|
||||
|
||||
/**
|
||||
* Get the given Java object's class index.
|
||||
*
|
||||
* @param obj Java object
|
||||
*
|
||||
* @return -1 if obj is an array, class index of the object otherwise
|
||||
*/
|
||||
jint
|
||||
bni_object_class_index(jobject obj);
|
||||
|
||||
/**
|
||||
* Allocate memory from the current instance's private heap.
|
||||
*
|
||||
* @param size bytes to allocate
|
||||
*
|
||||
* @return pointer to the allocated memory
|
||||
*
|
||||
* @throws OutOfMemoryError if VM runs out of memory.
|
||||
*/
|
||||
void*
|
||||
bni_malloc(unsigned size);
|
||||
|
||||
/**
|
||||
* Allocate memory from the current instance's private heap and clear
|
||||
* to zero.
|
||||
*
|
||||
* @param size bytes to allocate
|
||||
*
|
||||
* @return pointer to the allocated memory
|
||||
*
|
||||
* @throws OutOfMemoryError if VM runs out of memory.
|
||||
*/
|
||||
void*
|
||||
bni_calloc(unsigned size);
|
||||
|
||||
/**
|
||||
* Free the memory allocated from the current instance's private heap.
|
||||
*
|
||||
* @param ptr pointer to the memory in current instance's private heap
|
||||
*/
|
||||
void
|
||||
bni_free(void *ptr);
|
||||
|
||||
#endif
|
||||
153
core/shared/include/config.h
Normal file
153
core/shared/include/config.h
Normal file
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
|
||||
#if !defined(BUILD_TARGET_X86_64) \
|
||||
&& !defined(BUILD_TARGET_AMD_64) \
|
||||
&& !defined(BUILD_TARGET_X86_32) \
|
||||
&& !defined(BUILD_TARGET_ARM) \
|
||||
&& !defined(BUILD_TARGET_ARM_VFP) \
|
||||
&& !defined(BUILD_TARGET_THUMB) \
|
||||
&& !defined(BUILD_TARGET_THUMB_VFP) \
|
||||
&& !defined(BUILD_TARGET_MIPS) \
|
||||
&& !defined(BUILD_TARGET_XTENSA)
|
||||
#if defined(__x86_64__) || defined(__x86_64)
|
||||
#define BUILD_TARGET_X86_64
|
||||
#elif defined(__amd64__) || defined(__amd64)
|
||||
#define BUILD_TARGET_AMD_64
|
||||
#elif defined(__i386__) || defined(__i386) || defined(i386)
|
||||
#define BUILD_TARGET_X86_32
|
||||
#elif defined(__thumb__)
|
||||
#define BUILD_TARGET_THUMB
|
||||
#define BUILD_TARGET "THUMBV4T"
|
||||
#elif defined(__arm__)
|
||||
#define BUILD_TARGET_ARM
|
||||
#define BUILD_TARGET "ARMV4T"
|
||||
#elif defined(__mips__) || defined(__mips) || defined(mips)
|
||||
#define BUILD_TARGET_MIPS
|
||||
#elif defined(__XTENSA__)
|
||||
#define BUILD_TARGET_XTENSA
|
||||
#else
|
||||
#error "Build target isn't set"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
enum {
|
||||
/* Memory allocator ems */
|
||||
MEM_ALLOCATOR_EMS = 0,
|
||||
/* Memory allocator tlsf */
|
||||
MEM_ALLOCATOR_TLSF
|
||||
};
|
||||
|
||||
/* Default memory allocator */
|
||||
#define DEFAULT_MEM_ALLOCATOR MEM_ALLOCATOR_EMS
|
||||
|
||||
#ifndef WASM_ENABLE_INTERP
|
||||
#define WASM_ENABLE_INTERP 0
|
||||
#endif
|
||||
|
||||
#ifndef WASM_ENABLE_AOT
|
||||
#define WASM_ENABLE_AOT 0
|
||||
#endif
|
||||
|
||||
#ifndef WASM_ENABLE_JIT
|
||||
#define WASM_ENABLE_JIT 0
|
||||
#endif
|
||||
|
||||
#if (WASM_ENABLE_AOT == 0) && (WASM_ENABLE_JIT != 0)
|
||||
/* JIT can only be enabled when AOT is enabled */
|
||||
#undef WASM_ENABLE_JIT
|
||||
#define WASM_ENABLE_JIT 0
|
||||
#endif
|
||||
|
||||
#ifndef WASM_ENABLE_LIBC_BUILTIN
|
||||
#define WASM_ENABLE_LIBC_BUILTIN 0
|
||||
#endif
|
||||
|
||||
#ifndef WASM_ENABLE_LIBC_WASI
|
||||
#define WASM_ENABLE_LIBC_WASI 0
|
||||
#endif
|
||||
|
||||
#ifndef WASM_ENABLE_BASE_LIB
|
||||
#define WASM_ENABLE_BASE_LIB 0
|
||||
#endif
|
||||
|
||||
/* WASM log system */
|
||||
#ifndef WASM_ENABLE_LOG
|
||||
#define WASM_ENABLE_LOG 1
|
||||
#endif
|
||||
|
||||
#if defined(BUILD_TARGET_X86_32) || defined(BUILD_TARGET_X86_64)
|
||||
#define WASM_CPU_SUPPORTS_UNALIGNED_64BIT_ACCESS 1
|
||||
#else
|
||||
#define WASM_CPU_SUPPORTS_UNALIGNED_64BIT_ACCESS 0
|
||||
#endif
|
||||
|
||||
/* WASM Interpreter labels-as-values feature */
|
||||
#define WASM_ENABLE_LABELS_AS_VALUES 1
|
||||
|
||||
/* Heap and stack profiling */
|
||||
#define BEIHAI_ENABLE_MEMORY_PROFILING 0
|
||||
|
||||
/* Max app number of all modules */
|
||||
#define MAX_APP_INSTALLATIONS 3
|
||||
|
||||
/* Default timer number in one app */
|
||||
#define DEFAULT_TIMERS_PER_APP 20
|
||||
|
||||
/* Max timer number in one app */
|
||||
#define MAX_TIMERS_PER_APP 30
|
||||
|
||||
/* Max connection number in one app */
|
||||
#define MAX_CONNECTION_PER_APP 20
|
||||
|
||||
/* Max resource registration number in one app */
|
||||
#define RESOURCE_REGISTRATION_NUM_MAX 16
|
||||
|
||||
/* Max length of resource/event url */
|
||||
#define RESOUCE_EVENT_URL_LEN_MAX 256
|
||||
|
||||
/* Default length of queue */
|
||||
#define DEFAULT_QUEUE_LENGTH 50
|
||||
|
||||
/* Default watchdog interval in ms */
|
||||
#define DEFAULT_WATCHDOG_INTERVAL (3 * 60 * 1000)
|
||||
|
||||
/* Support memory.grow opcode and enlargeMemory function */
|
||||
#define WASM_ENABLE_MEMORY_GROW 1
|
||||
|
||||
/* The max percentage of global heap that app memory space can grow */
|
||||
#define APP_MEMORY_MAX_GLOBAL_HEAP_PERCENT 1 / 3
|
||||
|
||||
/* Default base offset of app heap space */
|
||||
#define DEFAULT_APP_HEAP_BASE_OFFSET (1 * BH_GB)
|
||||
|
||||
/* Default min/max heap size of each app */
|
||||
#define APP_HEAP_SIZE_DEFAULT (8 * 1024)
|
||||
#define APP_HEAP_SIZE_MIN (2 * 1024)
|
||||
#define APP_HEAP_SIZE_MAX (1024 * 1024)
|
||||
|
||||
/* Default wasm stack size of each app */
|
||||
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)
|
||||
#define DEFAULT_WASM_STACK_SIZE (16 * 1024)
|
||||
#else
|
||||
#define DEFAULT_WASM_STACK_SIZE (12 * 1024)
|
||||
#endif
|
||||
|
||||
/* Default/min/max stack size of each app thread */
|
||||
#if !defined(BH_PLATFORM_ZEPHYR) && !defined(BH_PLATFORM_ALIOS_THINGS)
|
||||
#define APP_THREAD_STACK_SIZE_DEFAULT (20 * 1024)
|
||||
#define APP_THREAD_STACK_SIZE_MIN (16 * 1024)
|
||||
#define APP_THREAD_STACK_SIZE_MAX (256 * 1024)
|
||||
#else
|
||||
#define APP_THREAD_STACK_SIZE_DEFAULT (4 * 1024)
|
||||
#define APP_THREAD_STACK_SIZE_MIN (2 * 1024)
|
||||
#define APP_THREAD_STACK_SIZE_MAX (256 * 1024)
|
||||
#endif
|
||||
|
||||
#endif /* end of _CONFIG_H_ */
|
||||
|
||||
604
core/shared/include/jeff_export.h
Normal file
604
core/shared/include/jeff_export.h
Normal file
@ -0,0 +1,604 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
/**
|
||||
* @file jeff-export.h
|
||||
* @date Wed Aug 3 18:17:30 2011
|
||||
*
|
||||
* @brief Exported interface for operating or executing JEFF files.
|
||||
* All interface names start with "jeff_", which is the namespace name
|
||||
* of this module.
|
||||
*/
|
||||
|
||||
#ifndef JEFF_EXPORT_H
|
||||
#define JEFF_EXPORT_H
|
||||
|
||||
#include "bni.h"
|
||||
#include "bh_types.h"
|
||||
|
||||
/********************************************************************
|
||||
* Exported internal types
|
||||
********************************************************************/
|
||||
|
||||
/**
|
||||
* JEFF file handle type
|
||||
*/
|
||||
struct JeffFileHeaderLinked;
|
||||
typedef struct JeffFileHeaderLinked *jeff_file_t;
|
||||
|
||||
/**
|
||||
* JEFF class type
|
||||
*/
|
||||
struct JeffClassHeaderLinked;
|
||||
typedef struct JeffClassHeaderLinked *jeff_class_t;
|
||||
|
||||
/**
|
||||
* VM instance handle type
|
||||
*/
|
||||
struct JeffInstanceLocalRoot;
|
||||
typedef struct JeffInstanceLocalRoot *jeff_instance_t;
|
||||
|
||||
/**
|
||||
* Record of one native method's definition.
|
||||
*/
|
||||
struct JeffNativeMethodDef {
|
||||
/* Mangled name of the native method. NULL for initialization
|
||||
functions. */
|
||||
const char *mangled_name;
|
||||
|
||||
/* Points to the native C function. */
|
||||
void (*func_ptr)(uint32 *);
|
||||
|
||||
/* Return size type of the native function. */
|
||||
uint32 return_size_type;
|
||||
};
|
||||
|
||||
/********************************************************************
|
||||
* Interface for operating global environment of the JEFF VM
|
||||
********************************************************************/
|
||||
|
||||
/**
|
||||
* Load the core library from the given file buffer and initialize the
|
||||
* runtime environment (global objects etc.) of the VM. The thread
|
||||
* calls this function becomes the supervisor thread, which belongs to
|
||||
* a unique supervisor instance. Currently, if this init failed,
|
||||
* partially initialized states of the VM runtime environment won't be
|
||||
* cleaned up, so the VM must be shutdown and restarted. method_defs
|
||||
* points to an array of native method definition records.
|
||||
* Initialization functions must be in the front of the array and
|
||||
* following native method definitions must be sorted by their mangled
|
||||
* names.
|
||||
*
|
||||
* @param file the JEFF file of the core library
|
||||
* @param file_size the size of the JEFF file of the core library
|
||||
* @param method_defs native method definition records
|
||||
* @param method_defs_num number of native method records
|
||||
* @param heap the heap for the current (supervisor) instance
|
||||
*
|
||||
* @return true if succeeds, otherwise the error cannot be recovered
|
||||
*/
|
||||
bool
|
||||
jeff_runtime_init(jeff_file_t file, unsigned file_size,
|
||||
struct JeffNativeMethodDef *method_defs, unsigned method_defs_num,
|
||||
void *heap);
|
||||
|
||||
/**
|
||||
* Load a JEFF file into the VM from the given file buffer. It can be
|
||||
* called from any VM thread.
|
||||
*
|
||||
* @param file the JEFF file to be loaded
|
||||
* @param size the size of the JEFF file
|
||||
* @param is_library whether the JEFF file is a library
|
||||
* @param allow_to_load a function that returns true if classes in the
|
||||
* given package is allowed to be loaded. The NULL function pointer
|
||||
* allows all packages.
|
||||
* @param allow_to_link a function that returns true if classes in the
|
||||
* given package is allowed to be linked to. The NULL function
|
||||
* pointer allows all packages.
|
||||
*
|
||||
* @return true if succeeds, otherwise detailed error information is
|
||||
* passed to vmci_diagnostic_print. The caller can catch it by
|
||||
* implementing that function.
|
||||
*/
|
||||
bool
|
||||
jeff_runtime_load(jeff_file_t file, unsigned size, bool is_library,
|
||||
bool (*allow_to_load)(const uint8 *pname, unsigned len),
|
||||
bool (*allow_to_link)(const uint8 *pname, unsigned plen,
|
||||
const uint8 *cname, unsigned clen));
|
||||
|
||||
/**
|
||||
* Unload a JEFF file from the VM. All resources related to the JEFF
|
||||
* file except the JEFF file itself are released. It can be called
|
||||
* from any VM thread.
|
||||
*
|
||||
* @param file the JEFF file to be unloaded
|
||||
*
|
||||
* @return true if succeeds, otherwise detailed error information is
|
||||
* passed to vmci_diagnostic_print. The caller can catch it by
|
||||
* implementing that function.
|
||||
*/
|
||||
bool
|
||||
jeff_runtime_unload(jeff_file_t file);
|
||||
|
||||
/**
|
||||
* Return the JEFF file with the given file uid.
|
||||
*
|
||||
* @param fuid the unique id of a loaded JEFF file
|
||||
*
|
||||
* @return the JEFF file is exists, otherwise NULL
|
||||
*/
|
||||
jeff_file_t
|
||||
jeff_runtime_fuid_to_file(unsigned fuid);
|
||||
|
||||
/**
|
||||
* Return the file uid of the given JEFF file.
|
||||
*
|
||||
* @param file a loaded JEFF file
|
||||
*
|
||||
* @return the unique id of the given JEFF file
|
||||
*/
|
||||
unsigned
|
||||
jeff_runtime_file_to_fuid(jeff_file_t file);
|
||||
|
||||
/**
|
||||
* Create a supervisor thread belonging to the supervisor instance.
|
||||
* Threads that may interact with VM core must be either the main
|
||||
* thread of supervisor instance (which calls jeff_runtime_init) or
|
||||
* created by this function so that VM core required data structures
|
||||
* can be set up correctly.
|
||||
*
|
||||
* @param start_routine the start routine of the new thread
|
||||
* @param arg argument to the start routine
|
||||
*
|
||||
* @return true if succeeds, false otherwise
|
||||
*/
|
||||
bool
|
||||
jeff_runtime_create_supervisor_thread(void* (*start_routine)(void *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Create a supervisor thread belonging to the supervisor instance.
|
||||
* Threads that may interact with VM core must be either the main
|
||||
* thread of supervisor instance (which calls jeff_runtime_init) or
|
||||
* created by this function so that VM core required data structures
|
||||
* can be set up correctly.
|
||||
*
|
||||
* @param start_routine the start routine of the new thread
|
||||
* @param arg argument to the start routine
|
||||
* @param prio thread priority
|
||||
*
|
||||
* @return true if succeeds, false otherwise
|
||||
*/
|
||||
bool
|
||||
jeff_runtime_create_supervisor_thread_with_prio(void* (*start_routine)(void *),
|
||||
void *arg, int prio);
|
||||
|
||||
/********************************************************************
|
||||
* Interface for operating instance local environment
|
||||
********************************************************************/
|
||||
|
||||
/**
|
||||
* Create a VM instance with the given JEFF file as its main file,
|
||||
* (i.e. the file containing the main class of the VM instance). This
|
||||
* function can be called from any VM thread, but it must be isolated
|
||||
* from JEFF file's unloading operation so that the main file won't be
|
||||
* unloaded before it's locked by the new instance. All instance
|
||||
* local memory except stacks of threads are allocated from the given
|
||||
* heap. If succeeds, it increases reference count of the main_file
|
||||
* and returns the handle of the new VM instance. The new instance's
|
||||
* main thread will run the start_routine with argument arg. If the
|
||||
* cleanup_routine is not NULL, it will be called after start_routine
|
||||
* returns and just before the main thread exits. It will also be
|
||||
* called after the instance is destroied. It is guaranteed to be
|
||||
* called exactly once no matter how the instance terminates.
|
||||
*
|
||||
* @param main_file the main JEFF file of the new instance
|
||||
* @param heap the private heap of the new instance
|
||||
* @param stack_depth the maximal nesting levels of Java methods of
|
||||
* the new instance. It must be <= 16 * 1024. Otherwise the instance
|
||||
* creation will fail.
|
||||
* @param start_routine start routine of the main thread. Don't
|
||||
* destroy the heap or inform other thread to do this at the end of
|
||||
* this routine since after it returns, VM core will call destroy
|
||||
* functions on objects allocated in this heap (e.g. locks and
|
||||
* condition variables). Do the destroying or informing of destroying
|
||||
* in the cleanup_routine.
|
||||
* @param arg the instance argument that will be passed to the start
|
||||
* routine. It can be get or set by jeff_runtime_get_instance_arg and
|
||||
* jeff_runtime_set_instance arg from threads of the instance. The
|
||||
* caller can use it to store instance local data.
|
||||
* @param cleanup_routine the optional cleanup routine for the
|
||||
* instance, which may be NULL. It may be executed in the end of the
|
||||
* main thread of the created instance by this function if this
|
||||
* instance exits normally, or it may be executed in a thread of other
|
||||
* instance in case this instance is being killed by that instance.
|
||||
* In both cases, this routine regards it is executed in a thread of
|
||||
* this instance (the instance created by this function) because
|
||||
* jeff_runtime_get_instance_arg will always return the argument of
|
||||
* this instance.
|
||||
*
|
||||
* @return the VM instance handle if succeeds, NULL otherwise
|
||||
*/
|
||||
jeff_instance_t
|
||||
jeff_runtime_create_instance(jeff_file_t main_file, void *heap,
|
||||
unsigned stack_depth, void* (*start_routine)(void *), void *arg,
|
||||
void (*cleanup_routine)(void));
|
||||
|
||||
/**
|
||||
* Destroy the given VM instance and decrease the reference count of
|
||||
* its main file and all explicitly used JEFF files. It can be called
|
||||
* from any VM thread. If there are alive threads of the instance,
|
||||
* they will be terminated mandatorily and then the cleanup routine is
|
||||
* called if it's not NULL.
|
||||
*
|
||||
* @param handle the handle of the instance to be destroyed
|
||||
*/
|
||||
void
|
||||
jeff_runtime_destroy_instance(jeff_instance_t handle);
|
||||
|
||||
/**
|
||||
* Retrieve the current instance's argument.
|
||||
*
|
||||
* @return the current instance's argument
|
||||
*/
|
||||
void*
|
||||
jeff_runtime_get_instance_arg(void);
|
||||
|
||||
/**
|
||||
* Set the current instance's argument.
|
||||
*
|
||||
* @return the new argument for the current instance
|
||||
*/
|
||||
void
|
||||
jeff_runtime_set_instance_arg(void *arg);
|
||||
|
||||
/**
|
||||
* Retrieve the current instance's heap.
|
||||
*
|
||||
* @return the current instance's heap
|
||||
*/
|
||||
void*
|
||||
jeff_runtime_get_instance_heap(void);
|
||||
|
||||
/**
|
||||
* Suspend all threads of the given VM instance. This function can
|
||||
* only be called from thread that is not of the given VM instance.
|
||||
*
|
||||
* @param handle the handle of the instance to be suspended
|
||||
*/
|
||||
void
|
||||
jeff_runtime_suspend_instance(jeff_instance_t handle);
|
||||
|
||||
/**
|
||||
* Resume all threads of the given VM instance. This function can
|
||||
* only be called from thread that is not of the given VM instance.
|
||||
*
|
||||
* @param handle the handle of the instance to be resumed
|
||||
*/
|
||||
void
|
||||
jeff_runtime_resume_instance(jeff_instance_t handle);
|
||||
|
||||
/**
|
||||
* Interrupt all threads of the given VM instance. This function can
|
||||
* only be called from thread that is not of the given VM instance.
|
||||
*
|
||||
* @param handle the handle of the instance to be interrupted
|
||||
* @param by_force whether the interruption is by force
|
||||
*/
|
||||
void
|
||||
jeff_runtime_interrupt_instance(jeff_instance_t handle, bool by_force);
|
||||
|
||||
/**
|
||||
* Wait for the given VM instance to terminate.
|
||||
*
|
||||
* @param ilr the VM instance to be waited for
|
||||
* @param mills wait millseconds to return
|
||||
*/
|
||||
void
|
||||
jeff_runtime_wait_for_instance(jeff_instance_t ilr, int mills);
|
||||
|
||||
/********************************************************************
|
||||
* Interface for operating thread local environment
|
||||
********************************************************************/
|
||||
|
||||
/**
|
||||
* Return true if there is an uncaught exception (thrown during
|
||||
* running an application or applet command).
|
||||
*
|
||||
* @return true if there is an uncaught exception
|
||||
*/
|
||||
bool
|
||||
jeff_runtime_check_uncaught_exception(void);
|
||||
|
||||
/**
|
||||
* Print qualified name of the uncaught exception (and stack trace if
|
||||
* enabled) by calling vmci_diagnostic_print.
|
||||
*/
|
||||
void
|
||||
jeff_runtime_print_uncaught_exception(void);
|
||||
|
||||
/**
|
||||
* Clear the uncaught exception.
|
||||
*/
|
||||
void
|
||||
jeff_runtime_reset_uncaught_exception(void);
|
||||
|
||||
/**
|
||||
* Change current thread to a safe state (VMWAIT). After calling this
|
||||
* and before calling jeff_runtime_exit_safe_state, all operations
|
||||
* must be safe, i.e. no GC or system level resource operations are
|
||||
* allowed because in a safe state, the VM instance is assumed to be
|
||||
* able to perform GC, JDWP or termination at any time. Usually, this
|
||||
* function is called just before the native code is going to wait for
|
||||
* something and the exiting safe state function is called just after
|
||||
* the waiting returns.
|
||||
*/
|
||||
void
|
||||
jeff_runtime_enter_safe_state(void);
|
||||
|
||||
/**
|
||||
* Change current thread to an unsafe state (RUNNING) so that unsafe
|
||||
* operations can also be done.
|
||||
*/
|
||||
void
|
||||
jeff_runtime_exit_safe_state(void);
|
||||
|
||||
/**
|
||||
* Set thread local error code for the current thread.
|
||||
*
|
||||
* @param code the error code to be set
|
||||
*/
|
||||
void
|
||||
jeff_runtime_set_error(unsigned code);
|
||||
|
||||
/**
|
||||
* Get the last error code of current thread.
|
||||
*
|
||||
* @return the last error code of current thread
|
||||
*/
|
||||
unsigned
|
||||
jeff_runtime_get_error(void);
|
||||
|
||||
/********************************************************************
|
||||
* Interface for GC support
|
||||
********************************************************************/
|
||||
|
||||
/**
|
||||
* Traverse all objects of the given heap that are global or locate in
|
||||
* threads' frames and return them by calling vmci_gc_rootset_elem.
|
||||
* This function will suspend all threads except the current one of
|
||||
* the VM instance owning the given heap before traversing. It
|
||||
* traverses either all or none of the rootset objects, and returns
|
||||
* true and false respectively. If it returns false, the GC process
|
||||
* shouldn't proceed and is not necessary to unmark anything because
|
||||
* no objects are marked. The function jeff_runtime_gc_finished must
|
||||
* be called if and only if this function returns true so as to resume
|
||||
* threads that are suspended during GC process.
|
||||
*
|
||||
* @param heap the heap for which rootset objects are looked up
|
||||
*
|
||||
* @return true if succeeds, false otherwise
|
||||
*/
|
||||
bool
|
||||
jeff_runtime_traverse_gc_rootset(void *heap);
|
||||
|
||||
/**
|
||||
* Get the reference offset table of the given object. If the
|
||||
* returned value R >= 0, *ret points to the reference offset table of
|
||||
* the object and R is the number of offsets in the table. Otherwise,
|
||||
* if the returned value R < 0, all reference fields of the object
|
||||
* must be in a continuous region (usually the object is an array),
|
||||
* then *ret is the offset to the first field in the region and R is
|
||||
* the number of such fields in the region.
|
||||
*
|
||||
* @param obj pointer to the Java object
|
||||
* @param ret points to a pointer for storing the reference offset
|
||||
* table if return value >= 0, or for storing the offset to the first
|
||||
* object reference in the Java object if return value < 0
|
||||
*
|
||||
* @return number of offsets in the reference_offset table if >= 0, or
|
||||
* number of object references in the object if < 0
|
||||
*/
|
||||
int
|
||||
jeff_object_get_reference_offsets(const jobject obj, uint16 **ret);
|
||||
|
||||
/**
|
||||
* Inform the containing VM instance that GC has finished and all
|
||||
* suspended threads can be resumed. This function must be called if
|
||||
* and only if jeff_runtime_traverse_gc_rootset returns true.
|
||||
*/
|
||||
void
|
||||
jeff_runtime_gc_finished(void);
|
||||
|
||||
/********************************************************************
|
||||
* Interface for tooling support
|
||||
********************************************************************/
|
||||
|
||||
/**
|
||||
* This function is used to suspend the main thread of VM instance so
|
||||
* that debugger can have chance to connect to the VM instance, set
|
||||
* breakpoints and do any other debug settings. It must be called
|
||||
* from the main thread of VM instance at the point just after VM
|
||||
* instance initialization finishes and just before application code
|
||||
* is to be executed.
|
||||
*/
|
||||
void
|
||||
jeff_tool_suspend_self(void);
|
||||
|
||||
/**
|
||||
* Start up tool agent thread for the given VM instance. It can be
|
||||
* called from any VM thread.
|
||||
*
|
||||
* @param handle the VM instance for which tool agent is started up
|
||||
* @param queue queue of the tool agent
|
||||
* @return true if succeeds, false otherwise
|
||||
*/
|
||||
bool
|
||||
jeff_tool_start_agent(jeff_instance_t handle, void *queue);
|
||||
|
||||
/********************************************************************
|
||||
* Interface for toolkit support
|
||||
********************************************************************/
|
||||
|
||||
/**
|
||||
* Return the JEFF class pointer of the given class name.
|
||||
*
|
||||
* @param class_name the qualified class name
|
||||
*
|
||||
* @return the JEFF class pointer
|
||||
*/
|
||||
jeff_class_t
|
||||
jeff_tool_get_jeff_class(const char *class_name);
|
||||
|
||||
/**
|
||||
* Get the mangled class name of the given class.
|
||||
*
|
||||
* @param clz the JEFF class
|
||||
* @param buf buffer for returning the mangled name
|
||||
* @param buf_size size of the buffer
|
||||
*
|
||||
* @return actual size of the mangled class name including the
|
||||
* terminating null byte
|
||||
*/
|
||||
unsigned
|
||||
jeff_tool_get_mangled_class_name(jeff_class_t clz, char *buf,
|
||||
unsigned buf_size);
|
||||
|
||||
/**
|
||||
* Get class index of given class in its containing JEFF file.
|
||||
*
|
||||
* @param clz the JEFF class
|
||||
*
|
||||
* @return class index in the containing JEFF file
|
||||
*/
|
||||
int
|
||||
jeff_tool_get_class_index(jeff_class_t clz);
|
||||
|
||||
/**
|
||||
* Callback handler prototype for traversing fields of class.
|
||||
*
|
||||
* @param arg argument passed to the handler from caller
|
||||
* @param access_flag access flag of the method
|
||||
* @param name the field name
|
||||
* @param descriptor mangled field type descriptor
|
||||
* @param offset the offset of the field in the class
|
||||
* @param size size of the field
|
||||
*/
|
||||
typedef void
|
||||
(*JeffToolFieldHandler)(void *arg, unsigned access_flag, const char *name,
|
||||
const char *descriptor, unsigned offset, unsigned size);
|
||||
|
||||
/**
|
||||
* Traverse all fields of the given class, including those inherited
|
||||
* from super classes. The fields are traversed in the same order as
|
||||
* the field layout of the class.
|
||||
*
|
||||
* @param arg argument to be passed to the handler
|
||||
* @param clz the JEFF class
|
||||
* @param instance instance fields or static fielts
|
||||
* @param handler the callback handler for each field
|
||||
*/
|
||||
void
|
||||
jeff_tool_foreach_field(void *arg, jeff_class_t clz, bool instance,
|
||||
JeffToolFieldHandler handler);
|
||||
|
||||
/**
|
||||
* Callback handler prototype for traversing methods of class.
|
||||
*
|
||||
* @param arg argument passed to the handler from caller
|
||||
* @param access_flag access flag of the method
|
||||
* @param name mangled name of the method
|
||||
* @param descriptor mangled method arguments descriptor
|
||||
* @param retune_type mangled descriptor of method's return type
|
||||
*/
|
||||
typedef void
|
||||
(*JeffToolMethodHandler)(void *arg, unsigned access_flag, const char *name,
|
||||
const char *descriptor, const char *return_type);
|
||||
|
||||
/**
|
||||
* Traverse all methods of the given class.
|
||||
*
|
||||
* @param arg argument to be passed to the handler
|
||||
* @param clz the JEFF class
|
||||
* @param handler the callback handler for each method
|
||||
*/
|
||||
void
|
||||
jeff_tool_foreach_method(void *arg, jeff_class_t clz,
|
||||
JeffToolMethodHandler handler);
|
||||
|
||||
/**
|
||||
* Callback handler prototype for traversing classes of main file.
|
||||
*
|
||||
* @param arg argument passed to the handler from caller
|
||||
* @param clz pointer to one class in the main file
|
||||
*/
|
||||
typedef void
|
||||
(*JeffToolClassHandler)(void *arg, jeff_class_t clz);
|
||||
|
||||
/**
|
||||
* Traverse all classes of the main file.
|
||||
*
|
||||
* @param arg argument to be passed to the handler
|
||||
* @param handler the callback handler for each class
|
||||
*/
|
||||
void
|
||||
jeff_tool_foreach_class(void *arg, JeffToolClassHandler handler);
|
||||
|
||||
/********************************************************************
|
||||
* Interface for executing applications
|
||||
********************************************************************/
|
||||
|
||||
/**
|
||||
* Initialize global environment for executing Java applications.
|
||||
*
|
||||
* @return true if succeeds, false otherwise
|
||||
*/
|
||||
bool
|
||||
jeff_application_env_init(void);
|
||||
|
||||
/**
|
||||
* Find the unique class containing a public static "main
|
||||
* ([Ljava.lang.String;)V" method from the main JEFF file of the
|
||||
* current instance and execute that method.
|
||||
*
|
||||
* @param argc the number of arguments
|
||||
* @param argv the arguments array
|
||||
*
|
||||
* @return true if the main method is called, false otherwise (e.g. an
|
||||
* exception occurs when preparing the arguments Java string array)
|
||||
*/
|
||||
bool
|
||||
jeff_application_execute(int argc, char *argv[]);
|
||||
|
||||
/********************************************************************
|
||||
* Interface for executing applets
|
||||
********************************************************************/
|
||||
|
||||
/**
|
||||
* Initialize global environment for executing applets.
|
||||
*
|
||||
* @return true if succeeds, false otherwise
|
||||
*/
|
||||
bool
|
||||
jeff_applet_env_init(void);
|
||||
|
||||
/**
|
||||
* Start to run from com.intel.runtime.core.RuntimeContext.main with a
|
||||
* default message queue size and a default service class object. If
|
||||
* the main JEFF file of the current VM instance contains exactly one
|
||||
* class that is derived from com.intel.util.IntelApplet, then use it
|
||||
* as the default service class.
|
||||
*
|
||||
* @param queue_size the default main message queue size
|
||||
* @param default_service_class qualified class name of the default
|
||||
* service class (entry point class), which must be in the main JEFF
|
||||
* file. If NULL, find the default main class with rules described
|
||||
* above.
|
||||
*
|
||||
* @return true if succeeds, false otherwise
|
||||
*/
|
||||
bool
|
||||
jeff_applet_start(int queue_size, const char *default_service_class);
|
||||
|
||||
#endif
|
||||
34
core/shared/include/mem_alloc.h
Normal file
34
core/shared/include/mem_alloc.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef __MEM_ALLOC_H
|
||||
#define __MEM_ALLOC_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *mem_allocator_t;
|
||||
|
||||
mem_allocator_t
|
||||
mem_allocator_create(void *mem, uint32_t size);
|
||||
|
||||
void
|
||||
mem_allocator_destroy(mem_allocator_t allocator);
|
||||
|
||||
void *
|
||||
mem_allocator_malloc(mem_allocator_t allocator, uint32_t size);
|
||||
|
||||
void
|
||||
mem_allocator_free(mem_allocator_t allocator, void *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef __MEM_ALLOC_H */
|
||||
|
||||
Reference in New Issue
Block a user