wasm_native.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _WASM_NATIVE_H
  6. #define _WASM_NATIVE_H
  7. #include "bh_common.h"
  8. #include "../include/wasm_export.h"
  9. #include "../interpreter/wasm.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. typedef struct NativeSymbolsNode {
  14. struct NativeSymbolsNode *next;
  15. const char *module_name;
  16. NativeSymbol *native_symbols;
  17. uint32 n_native_symbols;
  18. bool call_conv_raw;
  19. } NativeSymbolsNode, *NativeSymbolsList;
  20. /**
  21. * Lookup global variable of a given import global
  22. * from libc builtin globals
  23. *
  24. * @param module_name the module name of the import global
  25. * @param global_name the global name of the import global
  26. * @param global return the global data
  27. *
  28. * @param true if success, false otherwise
  29. */
  30. bool
  31. wasm_native_lookup_libc_builtin_global(const char *module_name,
  32. const char *global_name,
  33. WASMGlobalImport *global);
  34. /**
  35. * Resolve native symbol in all libraries, including libc-builtin, libc-wasi,
  36. * base lib and extension lib, and user registered natives
  37. * function, which can be auto checked by vm before calling native function
  38. *
  39. * @param module_name the module name of the import function
  40. * @param func_name the function name of the import function
  41. * @param func_type the function prototype of the import function
  42. * @param p_signature output the signature if resolve success
  43. *
  44. * @return the native function pointer if success, NULL otherwise
  45. */
  46. void *
  47. wasm_native_resolve_symbol(const char *module_name, const char *field_name,
  48. const WASMType *func_type, const char **p_signature,
  49. void **p_attachment, bool *p_call_conv_raw);
  50. bool
  51. wasm_native_register_natives(const char *module_name,
  52. NativeSymbol *native_symbols,
  53. uint32 n_native_symbols);
  54. bool
  55. wasm_native_register_natives_raw(const char *module_name,
  56. NativeSymbol *native_symbols,
  57. uint32 n_native_symbols);
  58. bool
  59. wasm_native_init();
  60. void
  61. wasm_native_destroy();
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* end of _WASM_NATIVE_H */