wasm_shared_memory.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _WASM_SHARED_MEMORY_H
  6. #define _WASM_SHARED_MEMORY_H
  7. #include "bh_common.h"
  8. #if WASM_ENABLE_INTERP != 0
  9. #include "wasm_runtime.h"
  10. #endif
  11. #if WASM_ENABLE_AOT != 0
  12. #include "aot_runtime.h"
  13. #endif
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. typedef struct WASMSharedMemNode {
  18. bh_list_link l;
  19. /* Lock */
  20. korp_mutex lock;
  21. /* The module reference */
  22. WASMModuleCommon *module;
  23. /* The memory information */
  24. WASMMemoryInstanceCommon *memory_inst;
  25. /* reference count */
  26. uint32 ref_count;
  27. } WASMSharedMemNode;
  28. bool
  29. wasm_shared_memory_init();
  30. void
  31. wasm_shared_memory_destroy();
  32. WASMSharedMemNode*
  33. wasm_module_get_shared_memory(WASMModuleCommon *module);
  34. int32
  35. shared_memory_inc_reference(WASMModuleCommon *module);
  36. int32
  37. shared_memory_dec_reference(WASMModuleCommon *module);
  38. WASMMemoryInstanceCommon*
  39. shared_memory_get_memory_inst(WASMSharedMemNode *node);
  40. WASMSharedMemNode*
  41. shared_memory_set_memory_inst(WASMModuleCommon *module,
  42. WASMMemoryInstanceCommon *memory);
  43. uint32
  44. wasm_runtime_atomic_wait(WASMModuleInstanceCommon *module, void *address,
  45. uint64 expect, int64 timeout, bool wait64);
  46. uint32
  47. wasm_runtime_atomic_notify(WASMModuleInstanceCommon *module,
  48. void *address, uint32 count);
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif /* end of _WASM_SHARED_MEMORY_H */