lib_export.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. typedef struct NativeSymbol {
  11. const char *symbol;
  12. void *func_ptr;
  13. const char *signature;
  14. } NativeSymbol;
  15. #define EXPORT_WASM_API(symbol) {#symbol, (void*)symbol, NULL}
  16. #define EXPORT_WASM_API2(symbol) {#symbol, (void*)symbol##_wrapper, NULL}
  17. #define EXPORT_WASM_API_WITH_SIG(symbol, signature) \
  18. {#symbol, (void*)symbol, signature}
  19. #define EXPORT_WASM_API_WITH_SIG2(symbol, signature) \
  20. {#symbol, (void*)symbol##_wrapper, signature}
  21. /**
  22. * Get the exported APIs of base lib
  23. *
  24. * @param p_base_lib_apis return the exported API array of base lib
  25. *
  26. * @return the number of the exported API
  27. */
  28. int
  29. get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
  30. /**
  31. * Get the exported APIs of extended lib, this API isn't provided by WASM VM,
  32. * it must be provided by developer to register the extended native APIs,
  33. * for example, developer can register his native APIs to extended_native_symbol_defs,
  34. * array, and include file ext_lib_export.h which implements this API.
  35. * And if developer hasn't any native API to register, he can define an empty
  36. * extended_native_symbol_defs array, and then include file ext_lib_export.h to
  37. * implements this API.
  38. *
  39. * @param p_base_lib_apis return the exported API array of extend lib
  40. *
  41. * @return the number of the exported API
  42. */
  43. int
  44. get_extend_lib_export_apis(NativeSymbol **p_base_lib_apis);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif