diff options
Diffstat (limited to 'src/wasmrt.h')
| -rw-r--r-- | src/wasmrt.h | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/wasmrt.h b/src/wasmrt.h index 3800e94..f161392 100644 --- a/src/wasmrt.h +++ b/src/wasmrt.h @@ -212,6 +212,22 @@ uint32_t wasm_rt_memory_load32_unchecked(struct wasm_rt_memory_t const *mem, uint32_t addr); /** + * Loads a NUL-terminated string from memory. + * + * It copies at most `sz - 1` bytes and ensures that `buf` always ends with + * the NUL character. Returns the length of the string (excluding NUL) or + * `sz` in case the buffer was too small to load the entire string. + */ +size_t wasm_rt_memory_loada(struct wasm_rt_memory_t const *mem, uint32_t addr, + char *buf, size_t sz); + +/** + * Loads a NUL-terminated string from memory, without bounds checking. + */ +size_t wasm_rt_memory_loada_unchecked(struct wasm_rt_memory_t const *mem, + uint32_t addr, char *buf, size_t sz); + +/** * Stores bytes to memory. */ void wasm_rt_memory_store(struct wasm_rt_memory_t *mem, uint32_t addr, @@ -224,25 +240,25 @@ void wasm_rt_memory_store_unchecked(struct wasm_rt_memory_t *mem, uint32_t addr, void const *src, uint32_t len); /** - * Stores a 32-bit word to memory. + * Stores a byte to memory. */ void wasm_rt_memory_store8(struct wasm_rt_memory_t *mem, uint32_t addr, uint8_t value); /** - * Loads a 32-bit word from memory without bounds checks. + * Stores a byte to memory without bounds checks. */ void wasm_rt_memory_store8_unchecked(struct wasm_rt_memory_t *mem, uint32_t addr, uint8_t value); /** - * Stores a 32-bit word to memory. + * Stores a 16-bit value to memory. */ void wasm_rt_memory_store16(struct wasm_rt_memory_t *mem, uint32_t addr, uint16_t value); /** - * Loads a 32-bit word from memory without bounds checks. + * Stores a 16-bit value to memory without bounds checks. */ void wasm_rt_memory_store16_unchecked(struct wasm_rt_memory_t *mem, uint32_t addr, uint16_t value); @@ -254,12 +270,24 @@ void wasm_rt_memory_store32(struct wasm_rt_memory_t *mem, uint32_t addr, uint32_t value); /** - * Loads a 32-bit word from memory without bounds checks. + * Stores a 32-bit word to memory without bounds checks. */ void wasm_rt_memory_store32_unchecked(struct wasm_rt_memory_t *mem, uint32_t addr, uint32_t value); /** + * Stores a 64-bit value to memory. + */ +void wasm_rt_memory_store64(struct wasm_rt_memory_t *mem, uint32_t addr, + uint64_t value); + +/** + * Stores a 64-bit value to memory without bounds checks. + */ +void wasm_rt_memory_store64_unchecked(struct wasm_rt_memory_t *mem, + uint32_t addr, uint64_t value); + +/** * Sets all bytes in a memory range to a value. */ void wasm_rt_memory_set(struct wasm_rt_memory_t *mem, uint32_t addr, |
