[wasi-common]: add armv7 support to wasi-common (#1269)

* Add armv7 support to wasi-common

This commit enables `target_pointer_width = 32` compatibility for
`wasi-common` (and by transitivity, any crate found inside, e.g., `yanix`).
I've also added a simplistic (bare minimum) check to our CI to ensure
that `wasi-common` cross-compiles to `armv7-unknown-gnueabihf` fine.
While here, I've done the same for `wasm32-unknown-emscripten`.

* Clean arch-specific impls + reuse libc consts

* Make SeekLoc::from_raw platform independent

* Collapse CI cc jobs into one
This commit is contained in:
Jakub Konka
2020-03-10 19:18:59 +01:00
committed by GitHub
parent 67bfeea16f
commit bd5e71b038
11 changed files with 76 additions and 129 deletions

View File

@@ -6,9 +6,6 @@ use std::fs::File;
use std::io::Result;
use std::sync::atomic::{AtomicBool, Ordering::Relaxed};
pub(crate) const UTIME_NOW: i64 = 1_073_741_823;
pub(crate) const UTIME_OMIT: i64 = 1_073_741_822;
/// Wrapper for `utimensat` syscall, however, with an added twist such that `utimensat` symbol
/// is firstly resolved (i.e., we check whether it exists on the host), and only used if that is
/// the case. Otherwise, the syscall resorts to a less accurate `utimesat` emulated syscall.

View File

@@ -3,13 +3,3 @@ pub(crate) mod fadvise;
pub(crate) mod file;
pub(crate) mod filetime;
pub(crate) mod utimesat;
use crate::dir::SeekLoc;
use std::io::Result;
impl SeekLoc {
pub unsafe fn from_raw(loc: i64) -> Result<Self> {
let loc = loc.into();
Ok(Self(loc))
}
}

View File

@@ -1,4 +1,5 @@
use crate::filetime::FileTime;
use crate::filetime::FileTimeExt;
use crate::from_success_code;
use std::fs;
use std::io::Result;
@@ -26,19 +27,16 @@ pub fn utimesat(
let fd = unsafe { libc::openat(dirfd.as_raw_fd(), p.as_ptr(), flags) };
let f = unsafe { fs::File::from_raw_fd(fd) };
let (atime, mtime) = get_times(atime, mtime, || f.metadata().map_err(Into::into))?;
let times = [to_timeval(atime), to_timeval(mtime)];
let times = [to_timeval(atime)?, to_timeval(mtime)?];
from_success_code(unsafe { libc::futimes(f.as_raw_fd(), times.as_ptr()) })
}
/// Converts `filetime::FileTime` to `libc::timeval`. This function was taken directly from
/// [filetime] crate.
///
/// [filetime]: https://github.com/alexcrichton/filetime/blob/master/src/unix/utimes.rs#L93
fn to_timeval(ft: filetime::FileTime) -> libc::timeval {
libc::timeval {
tv_sec: ft.seconds(),
tv_usec: (ft.nanoseconds() / 1000) as libc::suseconds_t,
}
/// Converts `filetime::FileTime` to `libc::timeval`.
fn to_timeval(ft: filetime::FileTime) -> Result<libc::timeval> {
Ok(libc::timeval {
tv_sec: ft.seconds_()?,
tv_usec: (ft.nanoseconds_() / 1000) as libc::suseconds_t,
})
}
/// For a provided pair of access and modified `FileTime`s, converts the input to