lib_export.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _LIB_EXPORT_H_
  17. #define _LIB_EXPORT_H_
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. typedef struct NativeSymbol {
  22. const char *symbol;
  23. void *func_ptr;
  24. } NativeSymbol;
  25. #define EXPORT_WASM_API(symbol) {#symbol, symbol}
  26. #define EXPORT_WASM_API2(symbol) {#symbol, symbol##_wrapper}
  27. /**
  28. * Get the exported APIs of base lib
  29. *
  30. * @param p_base_lib_apis return the exported API array of base lib
  31. *
  32. * @return the number of the exported API
  33. */
  34. int
  35. get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
  36. /**
  37. * Get the exported APIs of extended lib, this API isn't provided by WASM VM,
  38. * it must be provided by developer to register the extended native APIs,
  39. * for example, developer can register his native APIs to extended_native_symbol_defs,
  40. * array, and include file ext_lib_export.h which implements this API.
  41. * And if developer hasn't any native API to register, he can define an empty
  42. * extended_native_symbol_defs array, and then include file ext_lib_export.h to
  43. * implements this API.
  44. *
  45. * @param p_base_lib_apis return the exported API array of extend lib
  46. *
  47. * @return the number of the exported API
  48. */
  49. int
  50. get_extend_lib_export_apis(NativeSymbol **p_base_lib_apis);
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif