F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
spacewasm.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Classes

struct  spacewasm_host_t
 
union  spacewasm_value_payload_t
 
struct  spacewasm_value_t
 
struct  spacewasm_compiler_options_t
 

Macros

#define SPACEWASM_NORETURN   /* Fallback: do nothing on unsupported compilers */
 
#define CustomSection_MAX_NAME_LENGTH   32
 

Typedefs

typedef int32_t spacewasm_status_t
 
typedef int32_t spacewasm_hostcall_result_t
 
typedef uint8_t spacewasm_valtype_t
 
typedef int32_t spacewasm_read_result_t
 
typedef int32_t spacewasm_run_status_t
 
typedef int32_t spacewasm_trap_t
 
typedef struct spacewasm_allocator_t spacewasm_allocator_t
 
typedef struct spacewasm_t spacewasm_t
 
typedef struct spacewasm_host_module_t spacewasm_host_module_t
 
typedef struct spacewasm_caller_t spacewasm_caller_t
 
typedef uint8_t *(* spacewasm_alloc_fn_t) (void *userdata, size_t size, size_t align)
 
typedef uint8_t *(* spacewasm_realloc_fn_t) (void *userdata, uint8_t *ptr, size_t old_size, size_t new_size, size_t align)
 
typedef void(* spacewasm_dealloc_fn_t) (void *userdata, uint8_t *ptr, size_t size, size_t align)
 
typedef struct spacewasm_host_t spacewasm_host_t
 
typedef union spacewasm_value_payload_t spacewasm_value_payload_t
 
typedef struct spacewasm_value_t spacewasm_value_t
 
typedef spacewasm_hostcall_result_t(* spacewasm_host_fn_t) (struct spacewasm_caller_t *caller, void *userdata, const struct spacewasm_value_t *params, size_t n_params, struct spacewasm_value_t *out_result)
 
typedef spacewasm_read_result_t(* spacewasm_read_fn_t) (void *userdata, const uint8_t **out_buf, size_t *out_len)
 
typedef struct spacewasm_compiler_options_t spacewasm_compiler_options_t
 
typedef uint8_t *(* spacewasm_global_alloc_fn_t) (void *userdata, size_t size, size_t align)
 
typedef void(* spacewasm_global_dealloc_fn_t) (void *userdata, uint8_t *ptr, size_t size, size_t align)
 

Enumerations

enum  spacewasm_status_t {
  SPACEWASM_OK = 0, SPACEWASM_ERR_NULL_ARG = 1, SPACEWASM_ERR_BAD_ARG = 2, SPACEWASM_ERR_BAD_UTF8 = 3,
  SPACEWASM_ERR_NAME_TOO_LONG = 4, SPACEWASM_ERR_BAD_SIGNATURE = 5, SPACEWASM_ERR_CAPACITY = 6, SPACEWASM_ERR_NOT_FOUND = 7,
  SPACEWASM_ERR_WRONG_STATE = 8, SPACEWASM_ERR_GUEST_MEMORY_ALLOC_FAILED = 15, SPACEWASM_ERR_ALLOC_FAILED = 16, SPACEWASM_ERR_OUT_OF_MEMORY = 17,
  SPACEWASM_ERR_PAGE_TOO_SMALL = 18, SPACEWASM_ERR_MEM_OUT_OF_BOUNDS = 32, SPACEWASM_ERR_PARAM_LEN_MISMATCH = 48, SPACEWASM_ERR_PARAM_TYPE_MISMATCH = 49,
  SPACEWASM_ERR_STACK_OVERFLOW = 50, SPACEWASM_ERR_EOF = 64, SPACEWASM_ERR_MALFORMED_INTEGER = 65, SPACEWASM_ERR_I33_IS_NEGATIVE = 66,
  SPACEWASM_ERR_MALFORMED_MAGIC = 67, SPACEWASM_ERR_MALFORMED_VERSION = 68, SPACEWASM_ERR_MALFORMED_UTF8 = 69, SPACEWASM_ERR_DUPLICATE_MODULE_NAME = 70,
  SPACEWASM_ERR_DUPLICATE_EXPORT_NAME = 71, SPACEWASM_ERR_MALFORMED_SECTION_ID = 72, SPACEWASM_ERR_MALFORMED_VALUE_TYPE = 73, SPACEWASM_ERR_MALFORMED_FUNCTION = 74,
  SPACEWASM_ERR_MALFORMED_LIMIT = 75, SPACEWASM_ERR_MALFORMED_ELEM_TYPE = 76, SPACEWASM_ERR_MALFORMED_SECTION_SIZE = 77, SPACEWASM_ERR_EXPECTED_CONST_OR_VAR = 78,
  SPACEWASM_ERR_MALFORMED_IMPORT_EXPORT_DESC = 79, SPACEWASM_ERR_MALFORMED_MEM_TYPE = 80, SPACEWASM_ERR_INVALID_PAGE_SIZE = 81, SPACEWASM_ERR_INVALID_SECTION_ORDERING = 82,
  SPACEWASM_ERR_DUPLICATE_SECTION = 83, SPACEWASM_ERR_INVALID_MAX_LIMIT = 84, SPACEWASM_ERR_EXPECTED_TERMINAL = 85, SPACEWASM_ERR_INVALID_OPCODE = 86,
  SPACEWASM_ERR_MALFORMED_CODE_SIZE = 87, SPACEWASM_ERR_INVALID_CODE_SECTION_FUNCTION_COUNT = 88, SPACEWASM_ERR_VEC_TOO_LONG = 89, SPACEWASM_ERR_IDX_TOO_LARGE = 90,
  SPACEWASM_ERR_MODULE_IDX_TOO_LARGE = 91, SPACEWASM_ERR_MEMORY_TOO_LARGE = 92, SPACEWASM_ERR_MEMORY_IMPORT_TOO_LARGE = 93, SPACEWASM_ERR_MEM_ALIGN_TOO_LARGE = 94,
  SPACEWASM_ERR_TABLE_TOO_LARGE = 95, SPACEWASM_ERR_CONTROL_FLOW_TOO_DEEP = 96, SPACEWASM_ERR_STACK_UNDERFLOW = 97, SPACEWASM_ERR_STACK_TOO_LARGE = 98,
  SPACEWASM_ERR_LABEL_STACK_JUMP_TOO_DEEP = 99, SPACEWASM_ERR_LABEL_JUMP_TOO_LARGE = 100, SPACEWASM_ERR_TYPE_MISMATCH = 101, SPACEWASM_ERR_BLOCK_RESULT_TYPE_MISMATCH = 102,
  SPACEWASM_ERR_FUNCTION_RESULT_TYPE_MISMATCH = 103, SPACEWASM_ERR_BR_TABLE_RESULT_TYPE_MISMATCH = 104, SPACEWASM_ERR_ILLEGAL_MEMORY_GROW = 112, SPACEWASM_ERR_INVALID_ELEMENT_OFFSET = 113,
  SPACEWASM_ERR_INVALID_ELEMENT_OUT_OF_BOUNDS = 114, SPACEWASM_ERR_INVALID_TABLE_INDEX = 115, SPACEWASM_ERR_TABLE_NOT_DEFINED = 116, SPACEWASM_ERR_INVALID_ELEMENT_COUNT = 117,
  SPACEWASM_ERR_INVALID_MEM_INDEX = 118, SPACEWASM_ERR_MEMORY_NOT_DEFINED = 119, SPACEWASM_ERR_INVALID_MEM_OFFSET_TYPE = 120, SPACEWASM_ERR_INVALID_NEGATIVE_MEM_OFFSET = 121,
  SPACEWASM_ERR_INVALID_MEM_OFFSET = 122, SPACEWASM_ERR_MULTIPLE_MEMORIES = 123, SPACEWASM_ERR_MULTIPLE_TABLES = 124, SPACEWASM_ERR_INVALID_LABEL_INDEX = 128,
  SPACEWASM_ERR_INVALID_ELSE_BLOCK = 129, SPACEWASM_ERR_INVALID_END_BLOCK = 130, SPACEWASM_ERR_INSTRUCTION_OUTSIDE_OF_FUNCTION = 131, SPACEWASM_ERR_LOCAL_IDX_OUT_OF_RANGE = 132,
  SPACEWASM_ERR_FUNCTION_IDX_OUT_OF_RANGE = 133, SPACEWASM_ERR_TYPE_IDX_OUT_OF_RANGE = 134, SPACEWASM_ERR_FUNCTION_TEXT_OUT_OF_RANGE = 135, SPACEWASM_ERR_GLOBAL_IDX_OUT_OF_RANGE = 136,
  SPACEWASM_ERR_FUNCTION_IMPORT_NOT_FOUND = 144, SPACEWASM_ERR_GLOBAL_IMPORT_NOT_FOUND = 145, SPACEWASM_ERR_MEMORY_IMPORT_NOT_FOUND = 146, SPACEWASM_ERR_TABLE_IMPORT_NOT_FOUND = 147,
  SPACEWASM_ERR_FUNCTION_IMPORT_OUT_OF_RANGE = 148, SPACEWASM_ERR_FUNCTION_IMPORT_TYPE_MISMATCH = 149, SPACEWASM_ERR_GLOBAL_NOT_MUTABLE = 150, SPACEWASM_ERR_GLOBAL_IMPORT_TYPE_MISMATCH = 151,
  SPACEWASM_ERR_MEMORY_IMPORT_TYPE_MISMATCH = 152, SPACEWASM_ERR_TABLE_IMPORT_TYPE_MISMATCH = 153, SPACEWASM_ERR_TABLE_IMPORT_INCOMPATIBLE_SIZE = 154, SPACEWASM_ERR_TABLE_REF_NOT_UNIQUE = 155,
  SPACEWASM_ERR_FUNCTION_PARAMETERS_TOO_LARGE = 160, SPACEWASM_ERR_FUNCTION_RETURNS_TOO_LARGE = 161, SPACEWASM_ERR_TOO_MANY_LOCALS = 162, SPACEWASM_ERR_INVALID_CONST_INSTRUCTION = 163,
  SPACEWASM_ERR_GLOBAL_TYPE_MISMATCH = 164, SPACEWASM_ERR_ALIGNMENT_LARGER_THAN_TYPE = 165, SPACEWASM_ERR_INVALID_START_FUNCTION_SIGNATURE = 166, SPACEWASM_ERR_INVALID_HOST_START_FUNCTION = 167,
  SPACEWASM_ERR_CONST_ALREADY_HAS_VALUE = 176, SPACEWASM_ERR_CONST_NO_VALUE = 177, SPACEWASM_ERR_CONST_INVALID_GLOBAL = 178, SPACEWASM_ERR_POSSIBLE_BACKPATCH_CYCLE = 192,
  SPACEWASM_ERR_PAGE_FAULT = 193, SPACEWASM_ERR_READER_ERROR = 194
}
 
enum  spacewasm_hostcall_result_t { SPACEWASM_CONTINUE_NONE = 0, SPACEWASM_CONTINUE_SOME = 1, SPACEWASM_TRAP = 2, SPACEWASM_PAUSE = 3 }
 
enum  spacewasm_valtype_t { SPACEWASM_I32 = 0, SPACEWASM_I64 = 1, SPACEWASM_F32 = 2, SPACEWASM_F64 = 3 }
 
enum  spacewasm_read_result_t { SPACEWASM_READ_OK = 0, SPACEWASM_READ_EOF = 1, SPACEWASM_READ_ERROR = 2 }
 
enum  spacewasm_run_status_t { SPACEWASM_RUN_FINISHED = 0, SPACEWASM_RUN_OUT_OF_FUEL = 1, SPACEWASM_RUN_PAUSE = 2, SPACEWASM_RUN_TRAP = 3 }
 
enum  spacewasm_trap_t {
  SPACEWASM_TRAP_NONE = -1, SPACEWASM_TRAP_UNREACHABLE = 0, SPACEWASM_TRAP_HOST = 1, SPACEWASM_TRAP_DIVIDE_BY_ZERO = 2,
  SPACEWASM_TRAP_INVALID_TABLE_INDEX = 3, SPACEWASM_TRAP_INVALID_TABLE_FUNCTION_TYPE = 4, SPACEWASM_TRAP_UNINITIALIZED_TABLE_ELEMENT = 5, SPACEWASM_TRAP_GLOBAL_GET_FAILED = 6,
  SPACEWASM_TRAP_GLOBAL_SET_FAILED = 7, SPACEWASM_TRAP_OUT_OF_MEMORY = 8, SPACEWASM_TRAP_MEMORY_REF_NOT_UNIQUE = 9, SPACEWASM_TRAP_MEMORY_OUT_OF_BOUNDS = 10,
  SPACEWASM_TRAP_STACK_OVERFLOW = 11, SPACEWASM_TRAP_UNREPRESENTABLE_RESULT = 12, SPACEWASM_TRAP_INTEGER_OVERFLOW = 13, SPACEWASM_TRAP_BAD_CONVERSION_TO_INTEGER = 14,
  SPACEWASM_TRAP_MALFORMED_IR = 15
}
 

Functions

struct spacewasm_allocator_tspacewasm_allocator_new (spacewasm_alloc_fn_t alloc, spacewasm_realloc_fn_t realloc, spacewasm_dealloc_fn_t dealloc, void *userdata)
 
void spacewasm_allocator_destroy (struct spacewasm_allocator_t *allocator)
 
spacewasm_status_t spacewasm_host_new (size_t len, struct spacewasm_host_t *dest)
 
spacewasm_status_t spacewasm_add_host_module (struct spacewasm_host_t *host, const char *name, size_t max_functions, size_t max_globals, uint32_t *out_idx)
 
spacewasm_status_t spacewasm_add_host_function (struct spacewasm_host_t *host, uint32_t module_idx, const char *name, const char *params_sig, const char *returns_sig, spacewasm_host_fn_t f, void *userdata)
 
spacewasm_status_t spacewasm_load_module (struct spacewasm_t *engine, const char *name, spacewasm_read_fn_t read, void *read_userdata, struct spacewasm_allocator_t *allocator, uint32_t *out_module_idx)
 
spacewasm_status_t spacewasm_new (struct spacewasm_host_t *host, size_t stack_size, size_t max_modules, struct spacewasm_compiler_options_t options, struct spacewasm_t **out_engine)
 
void spacewasm_host_destroy (struct spacewasm_host_t *host)
 
spacewasm_status_t spacewasm_find_module (struct spacewasm_t *engine, const char *name, uint32_t *out_index)
 
spacewasm_status_t spacewasm_find_export_func (struct spacewasm_t *engine, uint32_t module_idx, const char *name, uint32_t *out_index)
 
spacewasm_status_t spacewasm_module_start (struct spacewasm_t *engine, uint32_t module_idx, uint32_t *out_module_idx, uint32_t *out_func_index)
 
spacewasm_status_t spacewasm_check_func_signature (struct spacewasm_t *engine, uint32_t module_idx, uint32_t func_index, const char *params_sig, const char *returns_sig)
 
spacewasm_status_t spacewasm_find_global (struct spacewasm_t *engine, uint32_t module_idx, const char *name, uint32_t *out_index)
 
spacewasm_status_t spacewasm_get_global (struct spacewasm_t *engine, uint32_t module_idx, uint32_t global_index, struct spacewasm_value_t *out)
 
spacewasm_status_t spacewasm_set_global (struct spacewasm_t *engine, uint32_t module_idx, uint32_t global_index, struct spacewasm_value_t value)
 
spacewasm_status_t spacewasm_invoke (struct spacewasm_t *engine, uint32_t module_idx, uint32_t func_index, const struct spacewasm_value_t *params, size_t n)
 
spacewasm_run_status_t spacewasm_run (struct spacewasm_t *engine, size_t fuel, spacewasm_trap_t *out_trap)
 
spacewasm_status_t spacewasm_resume (struct spacewasm_t *engine)
 
spacewasm_status_t spacewasm_resume_value (struct spacewasm_t *engine, struct spacewasm_value_t resume_value)
 
spacewasm_status_t spacewasm_reset (struct spacewasm_t *engine)
 
spacewasm_status_t spacewasm_get_result (struct spacewasm_t *engine, spacewasm_valtype_t expected, struct spacewasm_value_t *out)
 
void spacewasm_destroy (struct spacewasm_t *engine)
 
spacewasm_status_t spacewasm_mem_read (struct spacewasm_caller_t *caller, uint32_t addr, uint8_t *dst, size_t len)
 
spacewasm_status_t spacewasm_mem_write (struct spacewasm_caller_t *caller, uint32_t addr, const uint8_t *src, size_t len)
 
spacewasm_status_t spacewasm_mem_size (struct spacewasm_caller_t *caller, uint32_t *out_pages)
 
SPACEWASM_NORETURN void spacewasm_panic (const uint8_t *filename, size_t filename_len, uint32_t line, const uint8_t *msg, size_t len)
 
spacewasm_status_t spacewasm_set_global_allocator (spacewasm_global_alloc_fn_t alloc, spacewasm_global_dealloc_fn_t dealloc, void *userdata)
 

Macro Definition Documentation

◆ CustomSection_MAX_NAME_LENGTH

#define CustomSection_MAX_NAME_LENGTH   32

Definition at line 31 of file spacewasm.h.

◆ SPACEWASM_NORETURN

#define SPACEWASM_NORETURN   /* Fallback: do nothing on unsupported compilers */

Definition at line 27 of file spacewasm.h.

Typedef Documentation

◆ spacewasm_alloc_fn_t

typedef uint8_t*(* spacewasm_alloc_fn_t) (void *userdata, size_t size, size_t align)

Definition at line 374 of file spacewasm.h.

◆ spacewasm_allocator_t

Definition at line 355 of file spacewasm.h.

◆ spacewasm_caller_t

Definition at line 369 of file spacewasm.h.

◆ spacewasm_compiler_options_t

◆ spacewasm_dealloc_fn_t

typedef void(* spacewasm_dealloc_fn_t) (void *userdata, uint8_t *ptr, size_t size, size_t align)

Definition at line 389 of file spacewasm.h.

◆ spacewasm_global_alloc_fn_t

typedef uint8_t*(* spacewasm_global_alloc_fn_t) (void *userdata, size_t size, size_t align)

Definition at line 461 of file spacewasm.h.

◆ spacewasm_global_dealloc_fn_t

typedef void(* spacewasm_global_dealloc_fn_t) (void *userdata, uint8_t *ptr, size_t size, size_t align)

Definition at line 466 of file spacewasm.h.

◆ spacewasm_host_fn_t

typedef spacewasm_hostcall_result_t(* spacewasm_host_fn_t) (struct spacewasm_caller_t *caller, void *userdata, const struct spacewasm_value_t *params, size_t n_params, struct spacewasm_value_t *out_result)

Definition at line 419 of file spacewasm.h.

◆ spacewasm_host_module_t

Definition at line 363 of file spacewasm.h.

◆ spacewasm_host_t

◆ spacewasm_hostcall_result_t

typedef int32_t spacewasm_hostcall_result_t

Definition at line 186 of file spacewasm.h.

◆ spacewasm_read_fn_t

typedef spacewasm_read_result_t(* spacewasm_read_fn_t) (void *userdata, const uint8_t **out_buf, size_t *out_len)

Definition at line 431 of file spacewasm.h.

◆ spacewasm_read_result_t

typedef int32_t spacewasm_read_result_t

Definition at line 237 of file spacewasm.h.

◆ spacewasm_realloc_fn_t

typedef uint8_t*(* spacewasm_realloc_fn_t) (void *userdata, uint8_t *ptr, size_t old_size, size_t new_size, size_t align)

Definition at line 380 of file spacewasm.h.

◆ spacewasm_run_status_t

typedef int32_t spacewasm_run_status_t

Definition at line 258 of file spacewasm.h.

◆ spacewasm_status_t

typedef int32_t spacewasm_status_t

Definition at line 153 of file spacewasm.h.

◆ spacewasm_t

typedef struct spacewasm_t spacewasm_t

Definition at line 361 of file spacewasm.h.

◆ spacewasm_trap_t

typedef int32_t spacewasm_trap_t

Definition at line 344 of file spacewasm.h.

◆ spacewasm_valtype_t

typedef uint8_t spacewasm_valtype_t

Definition at line 207 of file spacewasm.h.

◆ spacewasm_value_payload_t

◆ spacewasm_value_t

Enumeration Type Documentation

◆ spacewasm_hostcall_result_t

Enumerator
SPACEWASM_CONTINUE_NONE 
SPACEWASM_CONTINUE_SOME 
SPACEWASM_TRAP 
SPACEWASM_PAUSE 

Definition at line 160 of file spacewasm.h.

◆ spacewasm_read_result_t

Enumerator
SPACEWASM_READ_OK 
SPACEWASM_READ_EOF 
SPACEWASM_READ_ERROR 

Definition at line 214 of file spacewasm.h.

◆ spacewasm_run_status_t

Enumerator
SPACEWASM_RUN_FINISHED 
SPACEWASM_RUN_OUT_OF_FUEL 
SPACEWASM_RUN_PAUSE 
SPACEWASM_RUN_TRAP 

Definition at line 244 of file spacewasm.h.

◆ spacewasm_status_t

Enumerator
SPACEWASM_OK 
SPACEWASM_ERR_NULL_ARG 
SPACEWASM_ERR_BAD_ARG 
SPACEWASM_ERR_BAD_UTF8 
SPACEWASM_ERR_NAME_TOO_LONG 
SPACEWASM_ERR_BAD_SIGNATURE 
SPACEWASM_ERR_CAPACITY 
SPACEWASM_ERR_NOT_FOUND 
SPACEWASM_ERR_WRONG_STATE 
SPACEWASM_ERR_GUEST_MEMORY_ALLOC_FAILED 
SPACEWASM_ERR_ALLOC_FAILED 
SPACEWASM_ERR_OUT_OF_MEMORY 
SPACEWASM_ERR_PAGE_TOO_SMALL 
SPACEWASM_ERR_MEM_OUT_OF_BOUNDS 
SPACEWASM_ERR_PARAM_LEN_MISMATCH 
SPACEWASM_ERR_PARAM_TYPE_MISMATCH 
SPACEWASM_ERR_STACK_OVERFLOW 
SPACEWASM_ERR_EOF 
SPACEWASM_ERR_MALFORMED_INTEGER 
SPACEWASM_ERR_I33_IS_NEGATIVE 
SPACEWASM_ERR_MALFORMED_MAGIC 
SPACEWASM_ERR_MALFORMED_VERSION 
SPACEWASM_ERR_MALFORMED_UTF8 
SPACEWASM_ERR_DUPLICATE_MODULE_NAME 
SPACEWASM_ERR_DUPLICATE_EXPORT_NAME 
SPACEWASM_ERR_MALFORMED_SECTION_ID 
SPACEWASM_ERR_MALFORMED_VALUE_TYPE 
SPACEWASM_ERR_MALFORMED_FUNCTION 
SPACEWASM_ERR_MALFORMED_LIMIT 
SPACEWASM_ERR_MALFORMED_ELEM_TYPE 
SPACEWASM_ERR_MALFORMED_SECTION_SIZE 
SPACEWASM_ERR_EXPECTED_CONST_OR_VAR 
SPACEWASM_ERR_MALFORMED_IMPORT_EXPORT_DESC 
SPACEWASM_ERR_MALFORMED_MEM_TYPE 
SPACEWASM_ERR_INVALID_PAGE_SIZE 
SPACEWASM_ERR_INVALID_SECTION_ORDERING 
SPACEWASM_ERR_DUPLICATE_SECTION 
SPACEWASM_ERR_INVALID_MAX_LIMIT 
SPACEWASM_ERR_EXPECTED_TERMINAL 
SPACEWASM_ERR_INVALID_OPCODE 
SPACEWASM_ERR_MALFORMED_CODE_SIZE 
SPACEWASM_ERR_INVALID_CODE_SECTION_FUNCTION_COUNT 
SPACEWASM_ERR_VEC_TOO_LONG 
SPACEWASM_ERR_IDX_TOO_LARGE 
SPACEWASM_ERR_MODULE_IDX_TOO_LARGE 
SPACEWASM_ERR_MEMORY_TOO_LARGE 
SPACEWASM_ERR_MEMORY_IMPORT_TOO_LARGE 
SPACEWASM_ERR_MEM_ALIGN_TOO_LARGE 
SPACEWASM_ERR_TABLE_TOO_LARGE 
SPACEWASM_ERR_CONTROL_FLOW_TOO_DEEP 
SPACEWASM_ERR_STACK_UNDERFLOW 
SPACEWASM_ERR_STACK_TOO_LARGE 
SPACEWASM_ERR_LABEL_STACK_JUMP_TOO_DEEP 
SPACEWASM_ERR_LABEL_JUMP_TOO_LARGE 
SPACEWASM_ERR_TYPE_MISMATCH 
SPACEWASM_ERR_BLOCK_RESULT_TYPE_MISMATCH 
SPACEWASM_ERR_FUNCTION_RESULT_TYPE_MISMATCH 
SPACEWASM_ERR_BR_TABLE_RESULT_TYPE_MISMATCH 
SPACEWASM_ERR_ILLEGAL_MEMORY_GROW 
SPACEWASM_ERR_INVALID_ELEMENT_OFFSET 
SPACEWASM_ERR_INVALID_ELEMENT_OUT_OF_BOUNDS 
SPACEWASM_ERR_INVALID_TABLE_INDEX 
SPACEWASM_ERR_TABLE_NOT_DEFINED 
SPACEWASM_ERR_INVALID_ELEMENT_COUNT 
SPACEWASM_ERR_INVALID_MEM_INDEX 
SPACEWASM_ERR_MEMORY_NOT_DEFINED 
SPACEWASM_ERR_INVALID_MEM_OFFSET_TYPE 
SPACEWASM_ERR_INVALID_NEGATIVE_MEM_OFFSET 
SPACEWASM_ERR_INVALID_MEM_OFFSET 
SPACEWASM_ERR_MULTIPLE_MEMORIES 
SPACEWASM_ERR_MULTIPLE_TABLES 
SPACEWASM_ERR_INVALID_LABEL_INDEX 
SPACEWASM_ERR_INVALID_ELSE_BLOCK 
SPACEWASM_ERR_INVALID_END_BLOCK 
SPACEWASM_ERR_INSTRUCTION_OUTSIDE_OF_FUNCTION 
SPACEWASM_ERR_LOCAL_IDX_OUT_OF_RANGE 
SPACEWASM_ERR_FUNCTION_IDX_OUT_OF_RANGE 
SPACEWASM_ERR_TYPE_IDX_OUT_OF_RANGE 
SPACEWASM_ERR_FUNCTION_TEXT_OUT_OF_RANGE 
SPACEWASM_ERR_GLOBAL_IDX_OUT_OF_RANGE 
SPACEWASM_ERR_FUNCTION_IMPORT_NOT_FOUND 
SPACEWASM_ERR_GLOBAL_IMPORT_NOT_FOUND 
SPACEWASM_ERR_MEMORY_IMPORT_NOT_FOUND 
SPACEWASM_ERR_TABLE_IMPORT_NOT_FOUND 
SPACEWASM_ERR_FUNCTION_IMPORT_OUT_OF_RANGE 
SPACEWASM_ERR_FUNCTION_IMPORT_TYPE_MISMATCH 
SPACEWASM_ERR_GLOBAL_NOT_MUTABLE 
SPACEWASM_ERR_GLOBAL_IMPORT_TYPE_MISMATCH 
SPACEWASM_ERR_MEMORY_IMPORT_TYPE_MISMATCH 
SPACEWASM_ERR_TABLE_IMPORT_TYPE_MISMATCH 
SPACEWASM_ERR_TABLE_IMPORT_INCOMPATIBLE_SIZE 
SPACEWASM_ERR_TABLE_REF_NOT_UNIQUE 
SPACEWASM_ERR_FUNCTION_PARAMETERS_TOO_LARGE 
SPACEWASM_ERR_FUNCTION_RETURNS_TOO_LARGE 
SPACEWASM_ERR_TOO_MANY_LOCALS 
SPACEWASM_ERR_INVALID_CONST_INSTRUCTION 
SPACEWASM_ERR_GLOBAL_TYPE_MISMATCH 
SPACEWASM_ERR_ALIGNMENT_LARGER_THAN_TYPE 
SPACEWASM_ERR_INVALID_START_FUNCTION_SIGNATURE 
SPACEWASM_ERR_INVALID_HOST_START_FUNCTION 
SPACEWASM_ERR_CONST_ALREADY_HAS_VALUE 
SPACEWASM_ERR_CONST_NO_VALUE 
SPACEWASM_ERR_CONST_INVALID_GLOBAL 
SPACEWASM_ERR_POSSIBLE_BACKPATCH_CYCLE 
SPACEWASM_ERR_PAGE_FAULT 
SPACEWASM_ERR_READER_ERROR 

Definition at line 37 of file spacewasm.h.

◆ spacewasm_trap_t

Enumerator
SPACEWASM_TRAP_NONE 
SPACEWASM_TRAP_UNREACHABLE 
SPACEWASM_TRAP_HOST 
SPACEWASM_TRAP_DIVIDE_BY_ZERO 
SPACEWASM_TRAP_INVALID_TABLE_INDEX 
SPACEWASM_TRAP_INVALID_TABLE_FUNCTION_TYPE 
SPACEWASM_TRAP_UNINITIALIZED_TABLE_ELEMENT 
SPACEWASM_TRAP_GLOBAL_GET_FAILED 
SPACEWASM_TRAP_GLOBAL_SET_FAILED 
SPACEWASM_TRAP_OUT_OF_MEMORY 
SPACEWASM_TRAP_MEMORY_REF_NOT_UNIQUE 
SPACEWASM_TRAP_MEMORY_OUT_OF_BOUNDS 
SPACEWASM_TRAP_STACK_OVERFLOW 
SPACEWASM_TRAP_UNREPRESENTABLE_RESULT 
SPACEWASM_TRAP_INTEGER_OVERFLOW 
SPACEWASM_TRAP_BAD_CONVERSION_TO_INTEGER 
SPACEWASM_TRAP_MALFORMED_IR 

Definition at line 266 of file spacewasm.h.

◆ spacewasm_valtype_t

Enumerator
SPACEWASM_I32 
SPACEWASM_I64 
SPACEWASM_F32 
SPACEWASM_F64 

Definition at line 193 of file spacewasm.h.

Function Documentation

◆ spacewasm_add_host_function()

spacewasm_status_t spacewasm_add_host_function ( struct spacewasm_host_t host,
uint32_t  module_idx,
const char *  name,
const char *  params_sig,
const char *  returns_sig,
spacewasm_host_fn_t  f,
void *  userdata 
)

◆ spacewasm_add_host_module()

spacewasm_status_t spacewasm_add_host_module ( struct spacewasm_host_t host,
const char *  name,
size_t  max_functions,
size_t  max_globals,
uint32_t *  out_idx 
)

◆ spacewasm_allocator_destroy()

void spacewasm_allocator_destroy ( struct spacewasm_allocator_t allocator)

◆ spacewasm_allocator_new()

struct spacewasm_allocator_t* spacewasm_allocator_new ( spacewasm_alloc_fn_t  alloc,
spacewasm_realloc_fn_t  realloc,
spacewasm_dealloc_fn_t  dealloc,
void *  userdata 
)

◆ spacewasm_check_func_signature()

spacewasm_status_t spacewasm_check_func_signature ( struct spacewasm_t engine,
uint32_t  module_idx,
uint32_t  func_index,
const char *  params_sig,
const char *  returns_sig 
)

◆ spacewasm_destroy()

void spacewasm_destroy ( struct spacewasm_t engine)

◆ spacewasm_find_export_func()

spacewasm_status_t spacewasm_find_export_func ( struct spacewasm_t engine,
uint32_t  module_idx,
const char *  name,
uint32_t *  out_index 
)

◆ spacewasm_find_global()

spacewasm_status_t spacewasm_find_global ( struct spacewasm_t engine,
uint32_t  module_idx,
const char *  name,
uint32_t *  out_index 
)

◆ spacewasm_find_module()

spacewasm_status_t spacewasm_find_module ( struct spacewasm_t engine,
const char *  name,
uint32_t *  out_index 
)

◆ spacewasm_get_global()

spacewasm_status_t spacewasm_get_global ( struct spacewasm_t engine,
uint32_t  module_idx,
uint32_t  global_index,
struct spacewasm_value_t out 
)

◆ spacewasm_get_result()

spacewasm_status_t spacewasm_get_result ( struct spacewasm_t engine,
spacewasm_valtype_t  expected,
struct spacewasm_value_t out 
)

◆ spacewasm_host_destroy()

void spacewasm_host_destroy ( struct spacewasm_host_t host)

◆ spacewasm_host_new()

spacewasm_status_t spacewasm_host_new ( size_t  len,
struct spacewasm_host_t dest 
)

◆ spacewasm_invoke()

spacewasm_status_t spacewasm_invoke ( struct spacewasm_t engine,
uint32_t  module_idx,
uint32_t  func_index,
const struct spacewasm_value_t params,
size_t  n 
)

◆ spacewasm_load_module()

spacewasm_status_t spacewasm_load_module ( struct spacewasm_t engine,
const char *  name,
spacewasm_read_fn_t  read,
void *  read_userdata,
struct spacewasm_allocator_t allocator,
uint32_t *  out_module_idx 
)

◆ spacewasm_mem_read()

spacewasm_status_t spacewasm_mem_read ( struct spacewasm_caller_t caller,
uint32_t  addr,
uint8_t *  dst,
size_t  len 
)

◆ spacewasm_mem_size()

spacewasm_status_t spacewasm_mem_size ( struct spacewasm_caller_t caller,
uint32_t *  out_pages 
)

◆ spacewasm_mem_write()

spacewasm_status_t spacewasm_mem_write ( struct spacewasm_caller_t caller,
uint32_t  addr,
const uint8_t *  src,
size_t  len 
)

◆ spacewasm_module_start()

spacewasm_status_t spacewasm_module_start ( struct spacewasm_t engine,
uint32_t  module_idx,
uint32_t *  out_module_idx,
uint32_t *  out_func_index 
)

◆ spacewasm_new()

spacewasm_status_t spacewasm_new ( struct spacewasm_host_t host,
size_t  stack_size,
size_t  max_modules,
struct spacewasm_compiler_options_t  options,
struct spacewasm_t **  out_engine 
)

◆ spacewasm_panic()

SPACEWASM_NORETURN void spacewasm_panic ( const uint8_t *  filename,
size_t  filename_len,
uint32_t  line,
const uint8_t *  msg,
size_t  len 
)

◆ spacewasm_reset()

spacewasm_status_t spacewasm_reset ( struct spacewasm_t engine)

◆ spacewasm_resume()

spacewasm_status_t spacewasm_resume ( struct spacewasm_t engine)

◆ spacewasm_resume_value()

spacewasm_status_t spacewasm_resume_value ( struct spacewasm_t engine,
struct spacewasm_value_t  resume_value 
)

◆ spacewasm_run()

spacewasm_run_status_t spacewasm_run ( struct spacewasm_t engine,
size_t  fuel,
spacewasm_trap_t out_trap 
)

◆ spacewasm_set_global()

spacewasm_status_t spacewasm_set_global ( struct spacewasm_t engine,
uint32_t  module_idx,
uint32_t  global_index,
struct spacewasm_value_t  value 
)

◆ spacewasm_set_global_allocator()

spacewasm_status_t spacewasm_set_global_allocator ( spacewasm_global_alloc_fn_t  alloc,
spacewasm_global_dealloc_fn_t  dealloc,
void *  userdata 
)