wasm_loader_common.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (C) 2024 Amazon Inc. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _WASM_LOADER_COMMON_H
  6. #define _WASM_LOADER_COMMON_H
  7. #include "platform_common.h"
  8. #include "../interpreter/wasm.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #if WASM_ENABLE_MEMORY64 != 0
  13. /* check consistency of memory64 flags across all memories,
  14. * they must be either all wasm64 or all wasm32 */
  15. bool
  16. check_memory64_flags_consistency(WASMModule *module, char *error_buf,
  17. uint32 error_buf_size, bool is_aot);
  18. #endif
  19. bool
  20. wasm_memory_check_flags(const uint8 mem_flag, char *error_buf,
  21. uint32 error_buf_size, bool is_aot);
  22. bool
  23. wasm_table_check_flags(const uint8 table_flag, char *error_buf,
  24. uint32 error_buf_size, bool is_aot);
  25. bool
  26. is_valid_value_type(uint8 value_tpye);
  27. bool
  28. is_valid_value_type_for_interpreter(uint8 value_tpye);
  29. bool
  30. is_valid_func_type(const WASMFuncType *func_type);
  31. bool
  32. is_valid_packed_type(uint8 packed_type);
  33. bool
  34. is_valid_field_type(uint8 field_type);
  35. bool
  36. is_indices_overflow(uint32 import, uint32 other, char *error_buf,
  37. uint32 error_buf_size);
  38. bool
  39. read_leb(uint8 **p_buf, const uint8 *buf_end, uint32 maxbits, bool sign,
  40. uint64 *p_result, char *error_buf, uint32 error_buf_size);
  41. void
  42. wasm_loader_set_error_buf(char *error_buf, uint32 error_buf_size,
  43. const char *string, bool is_aot);
  44. #if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
  45. void
  46. destroy_init_expr_recursive(InitializerExpression *expr);
  47. #endif
  48. #ifdef __cplusplus
  49. }
  50. #endif
  51. #endif /* end of _WASM_LOADER_COMMON_H */