8000 various improvements for the new design by Freax13 · Pull Request #28 · rust-osdev/volatile · GitHub
[go: up one dir, main page]

Skip to content

various improvements for the new design #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 17, 2023
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
add missing access where bounds
  • Loading branch information
Freax13 committed Jun 15, 2022
commit aa93fb97f8eebd81fc01833c181652c7a6f510df
11 changes: 9 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
pub fn copy_into_slice(&self, dst: &mut [T])
where
T: Copy,
R: access::Safe,
{
let len = self.pointer.len();
assert_eq!(
Expand Down Expand Up @@ -591,6 +592,7 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
pub fn copy_from_slice(&mut self, src: &[T])
where
T: Copy,
W: access::Safe,
{
let len = self.pointer.len();
assert_eq!(
Expand Down Expand Up @@ -644,6 +646,8 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
pub fn copy_within(&mut self, src: impl RangeBounds<usize>, dest: usize)
where
T: Copy,
R: access::Safe,
W: access::Safe,
{
let len = self.pointer.len();
// implementation taken from https://github.com/rust-lang/rust/blob/683d1bcd405727fcc9209f64845bd3b9104878b8/library/core/src/slice/mod.rs#L2726-L2738
Expand Down Expand Up @@ -819,7 +823,7 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {

/// Methods for volatile byte slices
#[cfg(feature = "unstable")]
impl<A> VolatilePtr<'_, [u8], A> {
impl<R, W> VolatilePtr<'_, [u8], Access<R, W>> {
/// Sets all elements of the byte slice to the given `value` using a volatile `memset`.
///
/// This method is similar to the `slice::fill` method of the standard library, with the
Expand All @@ -841,7 +845,10 @@ impl<A> VolatilePtr<'_, [u8], A> {
/// buf.fill(1);
/// assert_eq!(unsafe { buf.as_ptr().as_mut() }, &mut vec![1; 10]);
/// ```
pub fn fill(&mut self, value: u8) {
pub fn fill(&mut self, value: u8)
where
W: access::Safe,
{
unsafe {
intrinsics::volatile_set_memory(self.pointer.as_mut_ptr(), value, self.pointer.len());
}
Expand Down
0