Skip to content

Commit be93b1c

Browse files
authored
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
2 parents b543afc + e2780b3 commit be93b1c

File tree

4 files changed

+6
-36
lines changed

4 files changed

+6
-36
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1377,9 +1377,9 @@ dependencies = [
13771377

13781378
[[package]]
13791379
name = "hermit-abi"
1380-
version = "0.1.8"
1380+
version = "0.1.10"
13811381
source = "registry+https://github.com/rust-lang/crates.io-index"
1382-
checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
1382+
checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
13831383
dependencies = [
13841384
"compiler_builtins",
13851385
"libc",

src/libstd/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }
4141
fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }
4242

4343
[target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies]
44-
hermit-abi = { version = "0.1", features = ['rustc-dep-of-std'] }
44+
hermit-abi = { version = "0.1.10", features = ['rustc-dep-of-std'] }
4545

4646
[target.wasm32-wasi.dependencies]
4747
wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false }

src/libstd/sys/hermit/fs.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::io::{IoSlice, IoSliceMut, SeekFrom};
66
use crate::path::{Path, PathBuf};
77
use crate::sys::cvt;
88
use crate::sys::hermit::abi;
9+
use crate::sys::hermit::abi::{O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
910
use crate::sys::hermit::fd::FileDesc;
1011
use crate::sys::time::SystemTime;
1112
use crate::sys::{unsupported, Void};
@@ -17,14 +18,6 @@ pub use crate::sys_common::fs::copy;
1718
fn cstr(path: &Path) -> io::Result<CString> {
1819
Ok(CString::new(path.as_os_str().as_bytes())?)
1920
}
20-
//const O_ACCMODE: i32 = 00000003;
21-
const O_RDONLY: i32 = 00000000;
22-
const O_WRONLY: i32 = 00000001;
23-
const O_RDWR: i32 = 00000002;
24-
const O_CREAT: i32 = 00000100;
25-
const O_EXCL: i32 = 00000200;
26-
const O_TRUNC: i32 = 00001000;
27-
const O_APPEND: i32 = 00002000;
2821

2922
#[derive(Debug)]
3023
pub struct File(FileDesc);

src/libstd/sys/hermit/thread.rs

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,13 @@
11
#![allow(dead_code)]
22

33
use crate::ffi::CStr;
4-
use crate::fmt;
54
use crate::io;
65
use crate::mem;
76
use crate::sys::hermit::abi;
87
use crate::time::Duration;
98

109
pub type Tid = abi::Tid;
1110

12-
/// Priority of a task
13-
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy)]
14-
pub struct Priority(u8);
15-
16-
impl Priority {
17-
pub const fn into(self) -> u8 {
18-
self.0
19-
}
20-
21-
pub const fn from(x: u8) -> Self {
22-
Priority(x)
23-
}
24-
}
25-
26-
impl fmt::Display for Priority {
27-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28-
write!(f, "{}", self.0)
29-
}
30-
}
31-
32-
pub const NORMAL_PRIO: Priority = Priority::from(2);
33-
3411
pub struct Thread {
3512
tid: Tid,
3613
}
@@ -51,8 +28,8 @@ impl Thread {
5128
let ret = abi::spawn(
5229
&mut tid as *mut Tid,
5330
thread_start,
54-
p as usize,
55-
Priority::into(NORMAL_PRIO),
31+
&*p as *const _ as *const u8 as usize,
32+
abi::Priority::into(abi::NORMAL_PRIO),
5633
core_id,
5734
);
5835

0 commit comments

Comments
 (0)