lib_export.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. /* clang-format off */
  20. #define EXPORT_WASM_API(symbol) \
  21. { #symbol, (void *)symbol, NULL, NULL }
  22. #define EXPORT_WASM_API2(symbol) \
  23. { #symbol, (void *)symbol##_wrapper, NULL, NULL }
  24. #define EXPORT_WASM_API_WITH_SIG(symbol, signature) \
  25. { #symbol, (void *)symbol, signature, NULL }
  26. #define EXPORT_WASM_API_WITH_SIG2(symbol, signature) \
  27. { #symbol, (void *)symbol##_wrapper, signature, NULL }
  28. #define EXPORT_WASM_API_WITH_ATT(symbol, signature, attachment) \
  29. { #symbol, (void *)symbol, signature, attachment }
  30. #define EXPORT_WASM_API_WITH_ATT2(symbol, signature, attachment) \
  31. { #symbol, (void *)symbol##_wrapper, signature, attachment }
  32. /* clang-format on */
  33. /**
  34. * Get the exported APIs of base lib
  35. *
  36. * @param p_base_lib_apis return the exported API array of base lib
  37. *
  38. * @return the number of the exported API
  39. */
  40. uint32_t
  41. get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45. #endif /* end of _LIB_EXPORT_H_ */