lib_export.h 1.5 KB

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