Rollup merge of #70553 - hermitcore:abi, r=dtolnay

move OS constants to platform crate

to reduce platform specific constants move O_RDONLY etc. and the definition of thread priorities to hermit-abi
This commit is contained in:
Mazdak Farrokhzad 2020-04-06 00:53:42 +02:00 committed by GitHub
commit be93b1cdc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 36 deletions

View File

@ -1377,9 +1377,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.1.8"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
dependencies = [
"compiler_builtins",
"libc",

View File

@ -41,7 +41,7 @@ dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }
fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }
[target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies]
hermit-abi = { version = "0.1", features = ['rustc-dep-of-std'] }
hermit-abi = { version = "0.1.10", features = ['rustc-dep-of-std'] }
[target.wasm32-wasi.dependencies]
wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false }

View File

@ -6,6 +6,7 @@ use crate::io::{IoSlice, IoSliceMut, SeekFrom};
use crate::path::{Path, PathBuf};
use crate::sys::cvt;
use crate::sys::hermit::abi;
use crate::sys::hermit::abi::{O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
use crate::sys::hermit::fd::FileDesc;
use crate::sys::time::SystemTime;
use crate::sys::{unsupported, Void};
@ -17,14 +18,6 @@ pub use crate::sys_common::fs::copy;
fn cstr(path: &Path) -> io::Result<CString> {
Ok(CString::new(path.as_os_str().as_bytes())?)
}
//const O_ACCMODE: i32 = 00000003;
const O_RDONLY: i32 = 00000000;
const O_WRONLY: i32 = 00000001;
const O_RDWR: i32 = 00000002;
const O_CREAT: i32 = 00000100;
const O_EXCL: i32 = 00000200;
const O_TRUNC: i32 = 00001000;
const O_APPEND: i32 = 00002000;
#[derive(Debug)]
pub struct File(FileDesc);

View File

@ -1,7 +1,6 @@
#![allow(dead_code)]
use crate::ffi::CStr;
use crate::fmt;
use crate::io;
use crate::mem;
use crate::sys::hermit::abi;
@ -9,28 +8,6 @@ use crate::time::Duration;
pub type Tid = abi::Tid;
/// Priority of a task
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy)]
pub struct Priority(u8);
impl Priority {
pub const fn into(self) -> u8 {
self.0
}
pub const fn from(x: u8) -> Self {
Priority(x)
}
}
impl fmt::Display for Priority {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
pub const NORMAL_PRIO: Priority = Priority::from(2);
pub struct Thread {
tid: Tid,
}
@ -51,8 +28,8 @@ impl Thread {
let ret = abi::spawn(
&mut tid as *mut Tid,
thread_start,
p as usize,
Priority::into(NORMAL_PRIO),
&*p as *const _ as *const u8 as usize,
abi::Priority::into(abi::NORMAL_PRIO),
core_id,
);