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