wasm_memory.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. void
  36. wasm_deallocate_linear_memory(WASMMemoryInstance *memory_inst);
  37. int
  38. wasm_allocate_linear_memory(uint8 **data, bool is_shared_memory,
  39. uint64 num_bytes_per_page, uint64 init_page_count,
  40. uint64 max_page_count, uint64 *memory_data_size);
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif /* end of _WASM_MEMORY_H */