2019-05-07 02:18:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
2019-11-11 23:45:21 +00:00
|
|
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2019-05-07 02:18:18 +00:00
|
|
|
*/
|
|
|
|
|
2024-04-10 23:50:08 +00:00
|
|
|
/**
|
|
|
|
* @file lib_export.h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-05-07 02:18:18 +00:00
|
|
|
#ifndef _LIB_EXPORT_H_
|
|
|
|
#define _LIB_EXPORT_H_
|
|
|
|
|
2020-06-02 06:53:06 +00:00
|
|
|
#include <stdint.h>
|
2020-03-07 14:20:38 +00:00
|
|
|
|
2019-05-07 02:18:18 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct NativeSymbol {
|
|
|
|
const char *symbol;
|
|
|
|
void *func_ptr;
|
2020-03-04 12:12:38 +00:00
|
|
|
const char *signature;
|
2020-04-01 04:52:08 +00:00
|
|
|
/* attachment which can be retrieved in native API by
|
|
|
|
calling wasm_runtime_get_function_attachment(exec_env) */
|
|
|
|
void *attachment;
|
2019-05-07 02:18:18 +00:00
|
|
|
} NativeSymbol;
|
|
|
|
|
2021-10-08 09:47:11 +00:00
|
|
|
/* clang-format off */
|
|
|
|
#define EXPORT_WASM_API(symbol) \
|
|
|
|
{ #symbol, (void *)symbol, NULL, NULL }
|
|
|
|
#define EXPORT_WASM_API2(symbol) \
|
|
|
|
{ #symbol, (void *)symbol##_wrapper, NULL, NULL }
|
2020-03-04 12:12:38 +00:00
|
|
|
|
|
|
|
#define EXPORT_WASM_API_WITH_SIG(symbol, signature) \
|
2021-10-08 09:47:11 +00:00
|
|
|
{ #symbol, (void *)symbol, signature, NULL }
|
2020-03-04 12:12:38 +00:00
|
|
|
#define EXPORT_WASM_API_WITH_SIG2(symbol, signature) \
|
2021-10-08 09:47:11 +00:00
|
|
|
{ #symbol, (void *)symbol##_wrapper, signature, NULL }
|
2020-04-01 04:52:08 +00:00
|
|
|
|
|
|
|
#define EXPORT_WASM_API_WITH_ATT(symbol, signature, attachment) \
|
2021-10-08 09:47:11 +00:00
|
|
|
{ #symbol, (void *)symbol, signature, attachment }
|
2020-04-01 04:52:08 +00:00
|
|
|
#define EXPORT_WASM_API_WITH_ATT2(symbol, signature, attachment) \
|
2021-10-08 09:47:11 +00:00
|
|
|
{ #symbol, (void *)symbol##_wrapper, signature, attachment }
|
|
|
|
/* clang-format on */
|
2019-05-07 02:18:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the exported APIs of base lib
|
|
|
|
*
|
|
|
|
* @param p_base_lib_apis return the exported API array of base lib
|
|
|
|
*
|
|
|
|
* @return the number of the exported API
|
|
|
|
*/
|
2020-03-07 14:20:38 +00:00
|
|
|
uint32_t
|
2019-05-07 02:18:18 +00:00
|
|
|
get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-10-08 09:47:11 +00:00
|
|
|
#endif /* end of _LIB_EXPORT_H_ */
|