Add WASI support to runtime-c-api

This commit is contained in:
Mark McCaskey
2019-10-01 12:08:45 -07:00
parent b74e62af3d
commit b45b1c12f1
6 changed files with 195 additions and 1 deletions

View File

@ -154,6 +154,15 @@ struct wasmer_trampoline_buffer_t {
};
/// Opens a directory that's visible to the WASI module as `alias` but
/// is backed by the host file at `host_file_path`
struct wasmer_wasi_map_dir_entry_t {
/// What the WASI module will see in its virtual root
wasmer_byte_array alias;
/// The backing file that the WASI module will interact with via the alias
wasmer_byte_array host_file_path;
};
extern "C" {
/// Creates a new Module from the given wasm bytes.
@ -590,6 +599,23 @@ void *wasmer_trampoline_get_context();
/// Returns true for valid wasm bytes and false for invalid bytes
bool wasmer_validate(const uint8_t *wasm_bytes, uint32_t wasm_bytes_len);
/// Convenience function that creates a WASI import object with no arguments,
/// environment variables, preopened files, or mapped directories.
///
/// This function is the same as calling [`wasmer_wasi_generate_import_object`] with all
/// empty values.
wasmer_import_object_t *wasmer_wasi_generate_default_import_object();
/// Creates a WASI import object
wasmer_import_object_t *wasmer_wasi_generate_import_object(const wasmer_byte_array *args,
unsigned int args_len,
const wasmer_byte_array *envs,
unsigned int envs_len,
const wasmer_byte_array *preopened_files,
unsigned int preopened_files_len,
const wasmer_wasi_map_dir_entry_t *mapped_dirs,
unsigned int mapped_dirs_len);
} // extern "C"
#endif // WASMER_H