Skip to content

Commit

Permalink
Merge pull request tock#511 from jrvanwhy/toolchain-update
Browse files Browse the repository at this point in the history
Update the Rust toolchain to `nightly-2023-08-22`.
  • Loading branch information
jrvanwhy authored Aug 23, 2023
2 parents b61d048 + 20a1b8b commit 93c48c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions platform/src/register.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::mem::transmute;

/// In order to work with Miri's `-Zmiri-track-raw-pointers` flag, we cannot
/// pass pointers to the kernel through `usize` values (as casting to and from
/// `usize` drops the pointer`s tag). Instead, `RawSyscalls` uses the `Register`
Expand All @@ -16,19 +18,28 @@ pub struct Register(pub *mut ());

impl From<crate::ErrorCode> for Register {
fn from(value: crate::ErrorCode) -> Register {
Register(value as u16 as *mut ())
(value as usize).into()
}
}

impl From<u32> for Register {
fn from(value: u32) -> Register {
Register(value as *mut ())
(value as usize).into()
}
}

impl From<usize> for Register {
fn from(value: usize) -> Register {
Register(value as *mut ())
// Note: clippy is wrong here; transmute has different semantics than
// `as` casts under strict provenance.
#[allow(clippy::useless_transmute)]
// We want to convert using the same semantics as core::ptr::invalid:
// convert the usize into a pointer with that address without attaching
// provenance to it. However, core::ptr::invalid is a nightly-only
// function. In order to build on stable, we copy its implementation.
// Safety: Raw pointers do not have any validity invariants that usize
// does not have; a raw pointer can point to any address.
Register(unsafe { transmute(value) })
}
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[toolchain]
# See https://rust-lang.github.io/rustup-components-history/ for a list of
# recently nightlies and what components are available for them.
channel = "nightly-2022-06-10"
channel = "nightly-2023-08-22"
components = ["clippy", "miri", "rustfmt"]
targets = ["thumbv6m-none-eabi",
"thumbv7em-none-eabi",
Expand Down
2 changes: 1 addition & 1 deletion unittest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ version = "0.1.0"

[dependencies]
libtock_platform = { path = "../platform" }
thiserror = "1.0"
thiserror = "1.0.44"

0 comments on commit 93c48c6

Please sign in to comment.