diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-05-06 16:58:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-06 16:58:53 +0200 |
| commit | a6a7c755fabefe46c36094de154a15a12ae2edbc (patch) | |
| tree | 9fada6231a2a977c378aa18d72fcaee201a1dd36 /src/libstd/sys/hermit | |
| parent | 14d608f1d8a0b84da5f3bccecb3efb3d35f980dc (diff) | |
| parent | 2c43746758f4bc60bd4dda30a761cf48d1f60635 (diff) | |
| download | rust-a6a7c755fabefe46c36094de154a15a12ae2edbc.tar.gz rust-a6a7c755fabefe46c36094de154a15a12ae2edbc.zip | |
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
Diffstat (limited to 'src/libstd/sys/hermit')
| -rw-r--r-- | src/libstd/sys/hermit/thread.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libstd/sys/hermit/thread.rs b/src/libstd/sys/hermit/thread.rs index 7e3fb4c6d20..e11afed6687 100644 --- a/src/libstd/sys/hermit/thread.rs +++ b/src/libstd/sys/hermit/thread.rs @@ -16,25 +16,24 @@ pub struct Thread { unsafe impl Send for Thread {} unsafe impl Sync for Thread {} -pub const DEFAULT_MIN_STACK_SIZE: usize = 262144; +pub const DEFAULT_MIN_STACK_SIZE: usize = 1 << 20; impl Thread { pub unsafe fn new_with_coreid( - _stack: usize, + stack: usize, p: Box<dyn FnOnce()>, core_id: isize, ) -> io::Result<Thread> { let p = Box::into_raw(box p); - let mut tid: Tid = u32::MAX; - let ret = abi::spawn( - &mut tid as *mut Tid, + let tid = abi::spawn2( thread_start, - &*p as *const _ as *const u8 as usize, + p as usize, abi::Priority::into(abi::NORMAL_PRIO), + stack, core_id, ); - return if ret != 0 { + return if tid == 0 { // The thread failed to start and as a result p was not consumed. Therefore, it is // safe to reconstruct the box so that it gets deallocated. drop(Box::from_raw(p)); |
