Wasmtime
sharedmemory.h File Reference
#include <wasm.h>
#include <wasmtime/error.h>

Go to the source code of this file.

Typedefs

typedef struct wasmtime_sharedmemory wasmtime_sharedmemory_t
 Interface for shared memories. More...
 

Functions

wasmtime_error_twasmtime_sharedmemory_new (const wasm_engine_t *engine, const wasm_memorytype_t *ty, wasmtime_sharedmemory_t **ret)
 Creates a new WebAssembly shared linear memory. More...
 
void wasmtime_sharedmemory_delete (wasmtime_sharedmemory_t *memory)
 Deletes shared linear memory. More...
 
wasmtime_sharedmemory_twasmtime_sharedmemory_clone (const wasmtime_sharedmemory_t *memory)
 Clones shared linear memory. More...
 
wasm_memorytype_twasmtime_sharedmemory_type (const wasmtime_sharedmemory_t *memory)
 Returns the type of the shared memory specified.
 
uint8_t * wasmtime_sharedmemory_data (const wasmtime_sharedmemory_t *memory)
 Returns the base pointer in memory where the shared linear memory starts.
 
size_t wasmtime_sharedmemory_data_size (const wasmtime_sharedmemory_t *memory)
 Returns the byte length of this shared linear memory.
 
uint64_t wasmtime_sharedmemory_size (const wasmtime_sharedmemory_t *memory)
 Returns the length, in WebAssembly pages, of this shared linear memory.
 
wasmtime_error_twasmtime_sharedmemory_grow (const wasmtime_sharedmemory_t *memory, uint64_t delta, uint64_t *prev_size)
 Attempts to grow the specified shared memory by delta pages. More...
 

Detailed Description

Wasmtime API for interacting with wasm shared memories.

Typedef Documentation

◆ wasmtime_sharedmemory_t

typedef struct wasmtime_sharedmemory wasmtime_sharedmemory_t

Interface for shared memories.

For more information see the Rust documentation at: https://docs.wasmtime.dev/api/wasmtime/struct.SharedMemory.html

Function Documentation

◆ wasmtime_sharedmemory_clone()

wasmtime_sharedmemory_t * wasmtime_sharedmemory_clone ( const wasmtime_sharedmemory_t memory)

Clones shared linear memory.

Parameters
memorymemory to be cloned

This function makes shallow clone, ie. copy of reference counted memory handle.

◆ wasmtime_sharedmemory_delete()

void wasmtime_sharedmemory_delete ( wasmtime_sharedmemory_t memory)

Deletes shared linear memory.

Parameters
memorymemory to be deleted

◆ wasmtime_sharedmemory_grow()

wasmtime_error_t * wasmtime_sharedmemory_grow ( const wasmtime_sharedmemory_t memory,
uint64_t  delta,
uint64_t *  prev_size 
)

Attempts to grow the specified shared memory by delta pages.

Parameters
memorythe memory to grow
deltathe number of pages to grow by
prev_sizewhere to store the previous size of memory

If memory cannot be grown then prev_size is left unchanged and an error is returned. Otherwise prev_size is set to the previous size of the memory, in WebAssembly pages, and NULL is returned.

◆ wasmtime_sharedmemory_new()

wasmtime_error_t * wasmtime_sharedmemory_new ( const wasm_engine_t engine,
const wasm_memorytype_t ty,
wasmtime_sharedmemory_t **  ret 
)

Creates a new WebAssembly shared linear memory.

Parameters
engineengine that created shared memory is associated with
tythe type of the memory to create
retwhere to store the returned memory

If an error happens when creating the memory it's returned and owned by the caller. If an error happens then ret is not filled in.