lib_export.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _LIB_EXPORT_H_
  6. #define _LIB_EXPORT_H_
  7. #include <stdint.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. typedef struct NativeSymbol {
  12. const char *symbol;
  13. void *func_ptr;
  14. const char *signature;
  15. /* attachment which can be retrieved in native API by
  16. calling wasm_runtime_get_function_attachment(exec_env) */
  17. void *attachment;
  18. } NativeSymbol;
  19. #define EXPORT_WASM_API(symbol) {#symbol, (void*)symbol, NULL, NULL}
  20. #define EXPORT_WASM_API2(symbol) {#symbol, (void*)symbol##_wrapper, NULL, NULL}
  21. #define EXPORT_WASM_API_WITH_SIG(symbol, signature) \
  22. {#symbol, (void*)symbol, signature, NULL}
  23. #define EXPORT_WASM_API_WITH_SIG2(symbol, signature) \
  24. {#symbol, (void*)symbol##_wrapper, signature, NULL}
  25. #define EXPORT_WASM_API_WITH_ATT(symbol, signature, attachment) \
  26. {#symbol, (void*)symbol, signature, attachment}
  27. #define EXPORT_WASM_API_WITH_ATT2(symbol, signature, attachment) \
  28. {#symbol, (void*)symbol##_wrapper, signature, attachment}
  29. /**
  30. * Get the exported APIs of base lib
  31. *
  32. * @param p_base_lib_apis return the exported API array of base lib
  33. *
  34. * @return the number of the exported API
  35. */
  36. uint32_t
  37. get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif