Use the libstd instead of the errno crate in wasmtime-runtime. (#408)

Rust's standard library now has a way to read the OS errno value, so use
that instead of depending on the errno crate in wasmtime-runtime.
This commit is contained in:
Dan Gohman
2019-10-17 17:14:57 -07:00
committed by GitHub
parent 50beb21b63
commit 877152ee5c
3 changed files with 7 additions and 9 deletions

View File

@@ -35,7 +35,6 @@ pretty_env_logger = "0.3.0"
file-per-thread-logger = "0.1.1"
wabt = "0.9.2"
libc = "0.2.60"
errno = "0.2.4"
rayon = "1.1"
wasm-webidl-bindings = "0.5"

View File

@@ -18,7 +18,6 @@ wasmtime-environ = { path = "../wasmtime-environ", default-features = false }
region = "2.0.0"
lazy_static = "1.2.0"
libc = { version = "0.2.60", default-features = false }
errno = "0.2.4"
memoffset = "0.5.1"
failure = { version = "0.1.3", default-features = false }
failure_derive = { version = "0.1.3", default-features = false }

View File

@@ -5,10 +5,10 @@ use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::ptr;
use core::slice;
use errno;
#[cfg(not(target_os = "windows"))]
use libc;
use region;
use std::io;
/// Round `size` up to the nearest multiple of `page_size`.
fn round_up_to_page_size(size: usize, page_size: usize) -> usize {
@@ -74,7 +74,7 @@ impl Mmap {
)
};
if ptr as isize == -1_isize {
return Err(errno::errno().to_string());
return Err(io::Error::last_os_error().to_string());
}
Self {
@@ -94,7 +94,7 @@ impl Mmap {
)
};
if ptr as isize == -1_isize {
return Err(errno::errno().to_string());
return Err(io::Error::last_os_error().to_string());
}
let mut result = Self {
@@ -138,7 +138,7 @@ impl Mmap {
)
};
if ptr.is_null() {
return Err(errno::errno().to_string());
return Err(io::Error::last_os_error().to_string());
}
Self {
@@ -150,7 +150,7 @@ impl Mmap {
let ptr =
unsafe { VirtualAlloc(ptr::null_mut(), mapping_size, MEM_RESERVE, PAGE_NOACCESS) };
if ptr.is_null() {
return Err(errno::errno().to_string());
return Err(io::Error::last_os_error().to_string());
}
let mut result = Self {
@@ -208,7 +208,7 @@ impl Mmap {
}
.is_null()
{
return Err(errno::errno().to_string());
return Err(io::Error::last_os_error().to_string());
}
Ok(())
@@ -245,7 +245,7 @@ impl Drop for Mmap {
fn drop(&mut self) {
if self.len != 0 {
let r = unsafe { libc::munmap(self.ptr as *mut libc::c_void, self.len) };
assert_eq!(r, 0, "munmap failed: {}", errno::errno());
assert_eq!(r, 0, "munmap failed: {}", io::Error::last_os_error());
}
}