Skip to content

Commit a6a7c75

Browse files
authored
Rollup merge of #71591 - hermitcore:thread_create, r=hanna-kruppe
use new interface to create threads on HermitCore - the new interface allows to define the stack size - increase the default stack size to 1 MByte
2 parents 14d608f + 2c43746 commit a6a7c75

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1375,9 +1375,9 @@ dependencies = [
13751375

13761376
[[package]]
13771377
name = "hermit-abi"
1378-
version = "0.1.10"
1378+
version = "0.1.12"
13791379
source = "registry+https://github.com/rust-lang/crates.io-index"
1380-
checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
1380+
checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4"
13811381
dependencies = [
13821382
"compiler_builtins",
13831383
"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.10", features = ['rustc-dep-of-std'] }
44+
hermit-abi = { version = "0.1.12", 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/thread.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,24 @@ pub struct Thread {
1616
unsafe impl Send for Thread {}
1717
unsafe impl Sync for Thread {}
1818

19-
pub const DEFAULT_MIN_STACK_SIZE: usize = 262144;
19+
pub const DEFAULT_MIN_STACK_SIZE: usize = 1 << 20;
2020

2121
impl Thread {
2222
pub unsafe fn new_with_coreid(
23-
_stack: usize,
23+
stack: usize,
2424
p: Box<dyn FnOnce()>,
2525
core_id: isize,
2626
) -> io::Result<Thread> {
2727
let p = Box::into_raw(box p);
28-
let mut tid: Tid = u32::MAX;
29-
let ret = abi::spawn(
30-
&mut tid as *mut Tid,
28+
let tid = abi::spawn2(
3129
thread_start,
32-
&*p as *const _ as *const u8 as usize,
30+
p as usize,
3331
abi::Priority::into(abi::NORMAL_PRIO),
32+
stack,
3433
core_id,
3534
);
3635

37-
return if ret != 0 {
36+
return if tid == 0 {
3837
// The thread failed to start and as a result p was not consumed. Therefore, it is
3938
// safe to reconstruct the box so that it gets deallocated.
4039
drop(Box::from_raw(p));

0 commit comments

Comments
 (0)