Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7674ede
Detect long types in E0308 and write them to disk
estebank Nov 26, 2022
360c0a7
Tweak shortening logic to be less trigger happy
estebank Nov 26, 2022
73b371a
Further tweak the type shortening logic
estebank Nov 26, 2022
be02bd9
Remove unneeded test change
estebank Nov 26, 2022
360bcb6
fix test
estebank Nov 26, 2022
34b3c49
fix rebase
estebank Nov 28, 2022
427a079
kmc-solid: Use `expose_addr` and `from_exposed_addr` for pointer-inte…
kawadakk Dec 1, 2022
47f2f6d
kmc-solid: Add a stub implementation of `is_terminal`
kawadakk Dec 1, 2022
f482e55
kmc-solid: Address compiler warnings
kawadakk Dec 1, 2022
ae7633f
kmc-solid: Don't do `Box::from_raw(&*(x: Box<T>) as *const T as *mut T)`
kawadakk Dec 1, 2022
e2d41f4
Make nested RPITIT inherit the parent opaque's generics.
cjgillot Dec 4, 2022
9397ea1
make retagging work even with 'unstable' places
RalfJung Dec 5, 2022
34c58e8
Stacked Borrows: factor the logic determining the new permissions on …
RalfJung Dec 5, 2022
3a07aa9
Stop passing -export-dynamic to wasm-ld.
sunfishcode Dec 7, 2022
e9dd591
Add help for `#![feature(impl_trait_in_fn_trait_return)]`
cuviper Dec 7, 2022
d30848b
Use `Symbol` for the crate name instead of `String`/`str`
oli-obk Dec 6, 2022
8bc30cb
CI: add missing line continuation marker
ComputerDruid Dec 7, 2022
a3c4c2e
Fix warning when libcore is compiled with no_fp_fmt_parse
nbdd0121 Dec 8, 2022
7a46692
Remove `UnsafetyState`.
nnethercote Dec 8, 2022
9af48e5
Fix a typo.
nnethercote Dec 8, 2022
086bdbb
Rollup merge of #104922 - estebank:fur-elize, r=oli-obk
matthiaskrgr Dec 8, 2022
cd936cc
Rollup merge of #105120 - solid-rs:patch/kmc-solid/maintainance, r=th…
matthiaskrgr Dec 8, 2022
e826a9a
Rollup merge of #105255 - cjgillot:issue-105197, r=compiler-errors
matthiaskrgr Dec 8, 2022
f1f7560
Rollup merge of #105317 - RalfJung:retag-rework, r=oli-obk
matthiaskrgr Dec 8, 2022
4d5a2f3
Rollup merge of #105405 - sunfishcode:sunfishcode/export-dynamic, r=T…
matthiaskrgr Dec 8, 2022
2fbde2b
Rollup merge of #105408 - cuviper:help-rpitirpit, r=compiler-errors
matthiaskrgr Dec 8, 2022
fbfc5ad
Rollup merge of #105423 - oli-obk:symbols, r=jackh726
matthiaskrgr Dec 8, 2022
d429e46
Rollup merge of #105433 - ComputerDruid:docker_continuation_fix, r=jy…
matthiaskrgr Dec 8, 2022
433189b
Rollup merge of #105434 - nbdd0121:lib, r=thomcc
matthiaskrgr Dec 8, 2022
660795e
Rollup merge of #105441 - nnethercote:rm-UnsafetyState, r=lcnr
matthiaskrgr Dec 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/std/src/sys/itron/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Condvar {
}
}

unsafe { mutex.lock() };
mutex.lock();
}

pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
Expand Down Expand Up @@ -109,7 +109,7 @@ impl Condvar {
// we woke up because of `notify_*`.
let success = self.waiters.with_locked(|waiters| unsafe { !waiters.remove(waiter) });

unsafe { mutex.lock() };
mutex.lock();
success
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/itron/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub(super) struct MutexGuard<'a>(&'a Mutex);
impl<'a> MutexGuard<'a> {
#[inline]
pub(super) fn lock(x: &'a Mutex) -> Self {
unsafe { x.lock() };
x.lock();
Self(x)
}
}
Expand Down
48 changes: 30 additions & 18 deletions library/std/src/sys/itron/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,25 @@ use crate::{
ffi::CStr,
hint, io,
mem::ManuallyDrop,
ptr::NonNull,
sync::atomic::{AtomicUsize, Ordering},
sys::thread_local_dtor::run_dtors,
time::Duration,
};

pub struct Thread {
inner: ManuallyDrop<Box<ThreadInner>>,
p_inner: NonNull<ThreadInner>,

/// The ID of the underlying task.
task: abi::ID,
}

// Safety: There's nothing in `Thread` that ties it to the original creator. It
// can be dropped by any threads.
unsafe impl Send for Thread {}
// Safety: `Thread` provides no methods that take `&self`.
unsafe impl Sync for Thread {}

/// State data shared between a parent thread and child thread. It's dropped on
/// a transition to one of the final states.
struct ThreadInner {
Expand Down Expand Up @@ -90,8 +97,9 @@ impl Thread {
});

unsafe extern "C" fn trampoline(exinf: isize) {
let p_inner: *mut ThreadInner = crate::ptr::from_exposed_addr_mut(exinf as usize);
// Safety: `ThreadInner` is alive at this point
let inner = unsafe { &*(exinf as *const ThreadInner) };
let inner = unsafe { &*p_inner };

// Safety: Since `trampoline` is called only once for each
// `ThreadInner` and only `trampoline` touches `start`,
Expand Down Expand Up @@ -119,13 +127,13 @@ impl Thread {
// No one will ever join, so we'll ask the collector task to
// delete the task.

// In this case, `inner`'s ownership has been moved to us,
// And we are responsible for dropping it. The acquire
// In this case, `*p_inner`'s ownership has been moved to
// us, and we are responsible for dropping it. The acquire
// ordering is not necessary because the parent thread made
// no memory access needing synchronization since the call
// to `acre_tsk`.
// Safety: See above.
let _ = unsafe { Box::from_raw(inner as *const _ as *mut ThreadInner) };
let _ = unsafe { Box::from_raw(p_inner) };

// Safety: There are no pinned references to the stack
unsafe { terminate_and_delete_current_task() };
Expand Down Expand Up @@ -162,13 +170,14 @@ impl Thread {
}
}

let inner_ptr = (&*inner) as *const ThreadInner;
// Safety: `Box::into_raw` returns a non-null pointer
let p_inner = unsafe { NonNull::new_unchecked(Box::into_raw(inner)) };

let new_task = ItronError::err_if_negative(unsafe {
abi::acre_tsk(&abi::T_CTSK {
// Activate this task immediately
tskatr: abi::TA_ACT,
exinf: inner_ptr as abi::EXINF,
exinf: p_inner.as_ptr().expose_addr() as abi::EXINF,
// The entry point
task: Some(trampoline),
// Inherit the calling task's base priority
Expand All @@ -180,7 +189,7 @@ impl Thread {
})
.map_err(|e| e.as_io_error())?;

Ok(Self { inner: ManuallyDrop::new(inner), task: new_task })
Ok(Self { p_inner, task: new_task })
}

pub fn yield_now() {
Expand All @@ -197,8 +206,9 @@ impl Thread {
}
}

pub fn join(mut self) {
let inner = &*self.inner;
pub fn join(self) {
// Safety: `ThreadInner` is alive at this point
let inner = unsafe { self.p_inner.as_ref() };
// Get the current task ID. Panicking here would cause a resource leak,
// so just abort on failure.
let current_task = task::current_task_id_aborting();
Expand Down Expand Up @@ -243,8 +253,8 @@ impl Thread {
unsafe { terminate_and_delete_task(self.task) };

// In either case, we are responsible for dropping `inner`.
// Safety: The contents of `self.inner` will not be accessed hereafter
let _inner = unsafe { ManuallyDrop::take(&mut self.inner) };
// Safety: The contents of `*p_inner` will not be accessed hereafter
let _inner = unsafe { Box::from_raw(self.p_inner.as_ptr()) };

// Skip the destructor (because it would attempt to detach the thread)
crate::mem::forget(self);
Expand All @@ -253,13 +263,16 @@ impl Thread {

impl Drop for Thread {
fn drop(&mut self) {
// Safety: `ThreadInner` is alive at this point
let inner = unsafe { self.p_inner.as_ref() };

// Detach the thread.
match self.inner.lifecycle.swap(LIFECYCLE_DETACHED_OR_JOINED, Ordering::Acquire) {
match inner.lifecycle.swap(LIFECYCLE_DETACHED_OR_JOINED, Ordering::Acquire) {
LIFECYCLE_INIT => {
// [INIT → DETACHED]
// When the time comes, the child will figure out that no
// one will ever join it.
// The ownership of `self.inner` is moved to the child thread.
// The ownership of `*p_inner` is moved to the child thread.
// However, the release ordering is not necessary because we
// made no memory access needing synchronization since the call
// to `acre_tsk`.
Expand All @@ -278,10 +291,9 @@ impl Drop for Thread {
// delete by entering the `FINISHED` state.
unsafe { terminate_and_delete_task(self.task) };

// Wwe are responsible for dropping `inner`.
// Safety: The contents of `self.inner` will not be accessed
// hereafter
unsafe { ManuallyDrop::drop(&mut self.inner) };
// Wwe are responsible for dropping `*p_inner`.
// Safety: The contents of `*p_inner` will not be accessed hereafter
let _ = unsafe { Box::from_raw(self.p_inner.as_ptr()) };
}
_ => unsafe { hint::unreachable_unchecked() },
}
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/solid/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ impl<'a> IoSliceMut<'a> {
unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) }
}
}

pub fn is_terminal<T>(_: &T) -> bool {
false
}
3 changes: 1 addition & 2 deletions library/std/src/sys/solid/os.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::unsupported;
use crate::convert::TryFrom;
use crate::error::Error as StdError;
use crate::ffi::{CStr, CString, OsStr, OsString};
use crate::ffi::{CStr, OsStr, OsString};
use crate::fmt;
use crate::io;
use crate::os::{
Expand Down