Skip to content

Commit

Permalink
Rollup merge of rust-lang#70553 - hermitcore:abi, r=dtolnay
Browse files Browse the repository at this point in the history
move OS constants to platform crate

to reduce platform specific constants move O_RDONLY etc. and the definition of thread priorities to hermit-abi
  • Loading branch information
Centril authored Apr 5, 2020
2 parents b543afc + e2780b3 commit be93b1c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
9 changes: 1 addition & 8 deletions src/libstd/sys/hermit/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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);
Expand Down
27 changes: 2 additions & 25 deletions src/libstd/sys/hermit/thread.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
#![allow(dead_code)]

use crate::ffi::CStr;
use crate::fmt;
use crate::io;
use crate::mem;
use crate::sys::hermit::abi;
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,
}
Expand All @@ -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,
);

Expand Down

0 comments on commit be93b1c

Please sign in to comment.