Insulate API from intricacies of memory mgmt of calling runtimes

This commit is contained in:
Jakub Konka
2019-05-11 10:44:54 +02:00
parent 751a1a1f7b
commit 75ad92b0f3
5 changed files with 228 additions and 295 deletions

View File

@@ -1,6 +1,5 @@
use crate::fdentry::FdEntry;
use crate::host;
use crate::wasm32;
use failure::{bail, format_err, Error};
use nix::unistd::dup;
@@ -11,17 +10,6 @@ use std::io::{stderr, stdin, stdout};
use std::os::unix::prelude::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::path::{Path, PathBuf};
pub trait VmContext {
fn as_wasi_ctx(&self) -> *const WasiCtx;
fn as_wasi_ctx_mut(&mut self) -> *mut WasiCtx;
unsafe fn dec_ptr(
&mut self,
ptr: wasm32::uintptr_t,
len: usize,
) -> Result<*mut u8, host::__wasi_errno_t>;
}
pub struct WasiCtxBuilder {
fds: HashMap<host::__wasi_fd_t, FdEntry>,
preopens: HashMap<PathBuf, File>,
@@ -198,16 +186,6 @@ pub struct WasiCtx {
pub env: Vec<CString>,
}
impl Default for WasiCtx {
fn default() -> Self {
Self {
fds: HashMap::new(),
args: Vec::new(),
env: Vec::new(),
}
}
}
impl WasiCtx {
/// Make a new `WasiCtx` with some default settings.
///