wasm_memory.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _WASM_MEMORY_H
  6. #define _WASM_MEMORY_H
  7. #include "bh_common.h"
  8. #include "../include/wasm_export.h"
  9. #include "../interpreter/wasm_runtime.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #if WASM_ENABLE_SHARED_MEMORY != 0
  14. #define GET_LINEAR_MEMORY_SIZE(memory) \
  15. BH_ATOMIC_32_LOAD(memory->memory_data_size)
  16. #define SET_LINEAR_MEMORY_SIZE(memory, size) \
  17. BH_ATOMIC_32_STORE(memory->memory_data_size, size)
  18. #else
  19. #define GET_LINEAR_MEMORY_SIZE(memory) memory->memory_data_size
  20. #define SET_LINEAR_MEMORY_SIZE(memory, size) memory->memory_data_size = size
  21. #endif
  22. bool
  23. wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type,
  24. const MemAllocOption *alloc_option);
  25. void
  26. wasm_runtime_memory_destroy();
  27. unsigned
  28. wasm_runtime_memory_pool_size();
  29. void
  30. wasm_runtime_set_mem_bound_check_bytes(WASMMemoryInstance *memory,
  31. uint64 memory_data_size);
  32. void
  33. wasm_runtime_set_enlarge_mem_error_callback(
  34. const enlarge_memory_error_callback_t callback, void *user_data);
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif /* end of _WASM_MEMORY_H */