From 50ebd98da084fa685962b611c6d2ad3d6a72c4aa Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Sat, 27 Jan 2024 09:50:48 +0000 Subject: [PATCH] sel4-externally-shared: Refactor Including splitting out sel4-atomic-ptr into its own crate Signed-off-by: Nick Spinale --- Cargo.lock | 11 ++- Cargo.toml | 1 + crates/sel4-atomic-ptr/Cargo.nix | 18 +++++ crates/sel4-atomic-ptr/Cargo.toml | 20 +++++ .../src}/generic.rs | 0 .../mod.rs => sel4-atomic-ptr/src/lib.rs} | 31 +++----- .../atomics => sel4-atomic-ptr/src}/ops.rs | 8 +- .../src}/ordering.rs | 0 crates/sel4-externally-shared/Cargo.nix | 11 +-- crates/sel4-externally-shared/Cargo.toml | 8 +- crates/sel4-externally-shared/src/lib.rs | 19 ++--- .../src/ops/bytewise_ops.rs | 18 ++--- crates/sel4-externally-shared/src/ops/mod.rs | 2 +- .../src/ops/normal_ops.rs | 12 +-- .../src/ops/unordered_atomic_ops.rs | 75 +++++++++---------- .../src/ops/zerocopy_ops.rs | 16 ++-- .../manifest-scope.nix | 2 +- .../manual-manifests.nix | 1 + 18 files changed, 135 insertions(+), 118 deletions(-) create mode 100644 crates/sel4-atomic-ptr/Cargo.nix create mode 100644 crates/sel4-atomic-ptr/Cargo.toml rename crates/{sel4-externally-shared/src/atomics => sel4-atomic-ptr/src}/generic.rs (100%) rename crates/{sel4-externally-shared/src/atomics/mod.rs => sel4-atomic-ptr/src/lib.rs} (79%) rename crates/{sel4-externally-shared/src/atomics => sel4-atomic-ptr/src}/ops.rs (95%) rename crates/{sel4-externally-shared/src/atomics => sel4-atomic-ptr/src}/ordering.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index cfc3d4388..05cbb6352 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1917,6 +1917,13 @@ dependencies = [ "async-unsync", ] +[[package]] +name = "sel4-atomic-ptr" +version = "0.1.0" +dependencies = [ + "cfg-if", +] + [[package]] name = "sel4-backtrace" version = "0.1.0" @@ -2190,6 +2197,8 @@ dependencies = [ name = "sel4-externally-shared" version = "0.1.0" dependencies = [ + "cfg-if", + "sel4-atomic-ptr", "volatile", "zerocopy 0.7.32", ] @@ -3129,7 +3138,7 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "volatile" version = "0.5.1" -source = "git+https://github.com/coliasgroup/volatile.git?tag=keep/8aee5539716d3d38247f46eddd42b382#8aee5539716d3d38247f46eddd42b3828406c008" +source = "git+https://github.com/coliasgroup/volatile.git?tag=keep/aa7512906e9b76066ed928eb6986b0f9#aa7512906e9b76066ed928eb6986b0f9b1750e91" [[package]] name = "wasi" diff --git a/Cargo.toml b/Cargo.toml index c3ece0ee4..814d567b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,7 @@ members = [ "crates/sel4-async/single-threaded-executor", "crates/sel4-async/time", "crates/sel4-async/unsync", + "crates/sel4-atomic-ptr", "crates/sel4-backtrace", "crates/sel4-backtrace/addr2line-context-helper", "crates/sel4-backtrace/cli", diff --git a/crates/sel4-atomic-ptr/Cargo.nix b/crates/sel4-atomic-ptr/Cargo.nix new file mode 100644 index 000000000..02db64c98 --- /dev/null +++ b/crates/sel4-atomic-ptr/Cargo.nix @@ -0,0 +1,18 @@ +# +# Copyright 2023, Colias Group, LLC +# +# SPDX-License-Identifier: MIT OR Apache-2.0 +# + +{ mk, mkDefaultFrontmatterWithReuseArgs, defaultReuseFrontmatterArgs, versions }: + +mk rec { + nix.frontmatter = mkDefaultFrontmatterWithReuseArgs (defaultReuseFrontmatterArgs // { + licenseID = package.license; + }); + package.name = "sel4-atomic-ptr"; + package.license = "MIT OR Apache-2.0"; + dependencies = { + inherit (versions) cfg-if; + }; +} diff --git a/crates/sel4-atomic-ptr/Cargo.toml b/crates/sel4-atomic-ptr/Cargo.toml new file mode 100644 index 000000000..6641b95e3 --- /dev/null +++ b/crates/sel4-atomic-ptr/Cargo.toml @@ -0,0 +1,20 @@ +# +# Copyright 2023, Colias Group, LLC +# +# SPDX-License-Identifier: MIT OR Apache-2.0 +# +# +# This file is generated from './Cargo.nix'. You can edit this file directly +# if you are not using this project's Cargo manifest management tools. +# See 'hacking/cargo-manifest-management/README.md' for more information. +# + +[package] +name = "sel4-atomic-ptr" +version = "0.1.0" +authors = ["Nick Spinale "] +edition = "2021" +license = "MIT OR Apache-2.0" + +[dependencies] +cfg-if = "1.0.0" diff --git a/crates/sel4-externally-shared/src/atomics/generic.rs b/crates/sel4-atomic-ptr/src/generic.rs similarity index 100% rename from crates/sel4-externally-shared/src/atomics/generic.rs rename to crates/sel4-atomic-ptr/src/generic.rs diff --git a/crates/sel4-externally-shared/src/atomics/mod.rs b/crates/sel4-atomic-ptr/src/lib.rs similarity index 79% rename from crates/sel4-externally-shared/src/atomics/mod.rs rename to crates/sel4-atomic-ptr/src/lib.rs index a49fe372f..9a30b5e6a 100644 --- a/crates/sel4-externally-shared/src/atomics/mod.rs +++ b/crates/sel4-atomic-ptr/src/lib.rs @@ -4,14 +4,16 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 // +#![no_std] +#![feature(core_intrinsics)] +#![allow(internal_features)] + use core::fmt; use core::marker::PhantomData; use core::mem; use core::ptr::NonNull; use core::sync::atomic; -use volatile::access::{ReadOnly, ReadWrite, WriteOnly}; - mod generic; mod ops; mod ordering; @@ -19,30 +21,26 @@ mod ordering; use ordering::OrderingExhaustive; #[repr(transparent)] -pub struct AtomicPtr<'a, T, A = ReadWrite> { +pub struct AtomicPtr<'a, T> { pointer: NonNull, reference: PhantomData<&'a T>, - access: PhantomData, } -impl<'a, T, A> Copy for AtomicPtr<'a, T, A> {} +impl<'a, T> Copy for AtomicPtr<'a, T> {} -impl Clone for AtomicPtr<'_, T, A> { +impl Clone for AtomicPtr<'_, T> { fn clone(&self) -> Self { *self } } -impl fmt::Debug for AtomicPtr<'_, T, A> { +impl fmt::Debug for AtomicPtr<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("AtomicPtr") - .field("pointer", &self.pointer) - .field("access", &self.access) - .finish() + f.debug_tuple("AtomicPtr").field(&self.pointer).finish() } } -impl<'a, T, A> AtomicPtr<'a, T, A> { +impl<'a, T> AtomicPtr<'a, T> { /// # Safety /// /// Necessary but not sufficient: @@ -52,21 +50,12 @@ impl<'a, T, A> AtomicPtr<'a, T, A> { AtomicPtr { pointer, reference: PhantomData, - access: PhantomData, } } pub fn as_raw_ptr(self) -> NonNull { self.pointer } - - pub fn read_only(self) -> AtomicPtr<'a, T, ReadOnly> { - unsafe { AtomicPtr::new(self.pointer) } - } - - pub fn write_only(self) -> AtomicPtr<'a, T, WriteOnly> { - unsafe { AtomicPtr::new(self.pointer) } - } } #[allow(clippy::missing_safety_doc)] diff --git a/crates/sel4-externally-shared/src/atomics/ops.rs b/crates/sel4-atomic-ptr/src/ops.rs similarity index 95% rename from crates/sel4-externally-shared/src/atomics/ops.rs rename to crates/sel4-atomic-ptr/src/ops.rs index 6033c5e8f..d04e067b9 100644 --- a/crates/sel4-externally-shared/src/atomics/ops.rs +++ b/crates/sel4-atomic-ptr/src/ops.rs @@ -6,11 +6,9 @@ use core::sync::atomic::Ordering; -use volatile::access::{Readable, Writable}; - use super::{generic, Atomic, AtomicPtr}; -impl<'a, T, A> AtomicPtr<'a, T, A> { +impl<'a, T> AtomicPtr<'a, T> { fn as_mut_ptr(self) -> *mut T { self.pointer.as_ptr() } @@ -20,15 +18,13 @@ impl<'a, T, A> AtomicPtr<'a, T, A> { } } -impl<'a, T: Atomic, A: Readable> AtomicPtr<'a, T, A> { +impl<'a, T: Atomic> AtomicPtr<'a, T> { #[inline] pub fn load(self, order: Ordering) -> T { // SAFETY: data races are prevented by atomic intrinsics. unsafe { generic::atomic_load(self.as_const_ptr(), order.into()) } } -} -impl<'a, T: Atomic, A: Readable + Writable> AtomicPtr<'a, T, A> { #[inline] pub fn store(self, val: T, order: Ordering) { // SAFETY: data races are prevented by atomic intrinsics. diff --git a/crates/sel4-externally-shared/src/atomics/ordering.rs b/crates/sel4-atomic-ptr/src/ordering.rs similarity index 100% rename from crates/sel4-externally-shared/src/atomics/ordering.rs rename to crates/sel4-atomic-ptr/src/ordering.rs diff --git a/crates/sel4-externally-shared/Cargo.nix b/crates/sel4-externally-shared/Cargo.nix index c1d4ebbed..25627a978 100644 --- a/crates/sel4-externally-shared/Cargo.nix +++ b/crates/sel4-externally-shared/Cargo.nix @@ -1,21 +1,18 @@ # # Copyright 2023, Colias Group, LLC # -# SPDX-License-Identifier: MIT OR Apache-2.0 +# SPDX-License-Identifier: BSD-2-Clause # -{ mk, mkDefaultFrontmatterWithReuseArgs, defaultReuseFrontmatterArgs, localCrates, versions, volatileSource }: +{ mk, localCrates, versions, volatileSource }: mk rec { - nix.frontmatter = mkDefaultFrontmatterWithReuseArgs (defaultReuseFrontmatterArgs // { - licenseID = package.license; - }); package.name = "sel4-externally-shared"; - package.license = "MIT OR Apache-2.0"; dependencies = { - inherit (versions) zerocopy; + inherit (versions) cfg-if zerocopy; volatile = volatileSource; inherit (localCrates) + sel4-atomic-ptr # volatile ; }; diff --git a/crates/sel4-externally-shared/Cargo.toml b/crates/sel4-externally-shared/Cargo.toml index e7144a149..028efcfa9 100644 --- a/crates/sel4-externally-shared/Cargo.toml +++ b/crates/sel4-externally-shared/Cargo.toml @@ -1,7 +1,7 @@ # # Copyright 2023, Colias Group, LLC # -# SPDX-License-Identifier: MIT OR Apache-2.0 +# SPDX-License-Identifier: BSD-2-Clause # # # This file is generated from './Cargo.nix'. You can edit this file directly @@ -14,15 +14,17 @@ name = "sel4-externally-shared" version = "0.1.0" authors = ["Nick Spinale "] edition = "2021" -license = "MIT OR Apache-2.0" +license = "BSD-2-Clause" [features] unstable = ["volatile/unstable"] very_unstable = ["volatile/very_unstable"] [dependencies] +cfg-if = "1.0.0" +sel4-atomic-ptr = { path = "../sel4-atomic-ptr" } zerocopy = "0.7.32" [dependencies.volatile] git = "https://github.com/coliasgroup/volatile.git" -tag = "keep/8aee5539716d3d38247f46eddd42b382" +tag = "keep/aa7512906e9b76066ed928eb6986b0f9" diff --git a/crates/sel4-externally-shared/src/lib.rs b/crates/sel4-externally-shared/src/lib.rs index 38866b6d5..8f0f01011 100644 --- a/crates/sel4-externally-shared/src/lib.rs +++ b/crates/sel4-externally-shared/src/lib.rs @@ -1,12 +1,12 @@ // // Copyright 2023, Colias Group, LLC // -// SPDX-License-Identifier: MIT OR Apache-2.0 +// SPDX-License-Identifier: BSD-2-Clause // #![no_std] -#![feature(core_intrinsics)] -#![allow(internal_features)] +#![cfg_attr(feature = "unstable", feature(core_intrinsics))] +#![cfg_attr(feature = "unstable", allow(internal_features))] use core::ptr::NonNull; @@ -14,11 +14,9 @@ use volatile::access::{Access, ReadWrite}; pub use volatile::{access, map_field, VolatilePtr, VolatileRef}; -mod atomics; - pub mod ops; -pub use atomics::{Atomic, AtomicPtr}; +pub use sel4_atomic_ptr::{Atomic, AtomicPtr}; // TODO pub type ExternallySharedOps = ops::ZerocopyOps; @@ -26,7 +24,6 @@ pub type ExternallySharedOps = ops::ZerocopyOps; // pub type ExternallySharedOps = ops::ZerocopyOps>; pub type ExternallySharedRef<'a, T, A = ReadWrite> = VolatileRef<'a, T, A, ExternallySharedOps>; - pub type ExternallySharedPtr<'a, T, A = ReadWrite> = VolatilePtr<'a, T, A, ExternallySharedOps>; pub trait ExternallySharedRefExt<'a, T: ?Sized, A: Access> { @@ -43,14 +40,14 @@ impl<'a, T: ?Sized, A: Access> ExternallySharedRefExt<'a, T, A> for ExternallySh } } -pub trait ExternallySharedPtrExt<'a, T: ?Sized, A> { - fn atomic(self) -> AtomicPtr<'a, T, A> +pub trait ExternallySharedPtrExt<'a, T: ?Sized> { + fn atomic(self) -> AtomicPtr<'a, T> where T: Atomic; } -impl<'a, T: ?Sized, A> ExternallySharedPtrExt<'a, T, A> for ExternallySharedPtr<'a, T, A> { - fn atomic(self) -> AtomicPtr<'a, T, A> +impl<'a, T: ?Sized> ExternallySharedPtrExt<'a, T> for ExternallySharedPtr<'a, T, ReadWrite> { + fn atomic(self) -> AtomicPtr<'a, T> where T: Atomic, { diff --git a/crates/sel4-externally-shared/src/ops/bytewise_ops.rs b/crates/sel4-externally-shared/src/ops/bytewise_ops.rs index 23bde8eae..960e57f22 100644 --- a/crates/sel4-externally-shared/src/ops/bytewise_ops.rs +++ b/crates/sel4-externally-shared/src/ops/bytewise_ops.rs @@ -1,25 +1,22 @@ // // Copyright 2023, Colias Group, LLC // -// SPDX-License-Identifier: MIT OR Apache-2.0 +// SPDX-License-Identifier: BSD-2-Clause // -#![cfg_attr(not(feature = "unstable"), allow(unused_imports))] - +use core::marker::PhantomData; use core::mem; -use volatile::ops::{Ops, UnitaryOps}; +use volatile::ops::{BulkOps, Ops, UnitaryOps}; use zerocopy::{AsBytes, FromBytes}; -#[cfg(feature = "unstable")] -use volatile::ops::BulkOps; - -#[derive(Debug, Default, Copy, Clone)] -pub struct BytewiseOps(O); +#[derive(Default, Copy, Clone)] +pub struct BytewiseOps { + _phantom: PhantomData, +} impl Ops for BytewiseOps {} -#[cfg(feature = "unstable")] impl, T: FromBytes + AsBytes> UnitaryOps for BytewiseOps { unsafe fn read(src: *const T) -> T { let mut val = T::new_zeroed(); @@ -34,7 +31,6 @@ impl, T: FromBytes + AsBytes> UnitaryOps for BytewiseOps { } } -#[cfg(feature = "unstable")] impl, T: FromBytes + AsBytes> BulkOps for BytewiseOps { unsafe fn memmove(dst: *mut T, src: *const T, count: usize) { unsafe { O::memmove(dst.cast(), src.cast(), count * mem::size_of::()) } diff --git a/crates/sel4-externally-shared/src/ops/mod.rs b/crates/sel4-externally-shared/src/ops/mod.rs index fb80b86b2..877f51b27 100644 --- a/crates/sel4-externally-shared/src/ops/mod.rs +++ b/crates/sel4-externally-shared/src/ops/mod.rs @@ -1,7 +1,7 @@ // // Copyright 2023, Colias Group, LLC // -// SPDX-License-Identifier: MIT OR Apache-2.0 +// SPDX-License-Identifier: BSD-2-Clause // pub use volatile::ops::*; diff --git a/crates/sel4-externally-shared/src/ops/normal_ops.rs b/crates/sel4-externally-shared/src/ops/normal_ops.rs index dcab1784c..485df6c7d 100644 --- a/crates/sel4-externally-shared/src/ops/normal_ops.rs +++ b/crates/sel4-externally-shared/src/ops/normal_ops.rs @@ -1,18 +1,15 @@ // // Copyright 2023, Colias Group, LLC // -// SPDX-License-Identifier: MIT OR Apache-2.0 +// SPDX-License-Identifier: BSD-2-Clause // use core::ptr; -use volatile::ops::{Ops, UnitaryOps}; +use volatile::ops::{BulkOps, Ops, UnitaryOps}; -#[cfg(feature = "unstable")] -use volatile::ops::BulkOps; - -#[derive(Debug, Default, Copy, Clone)] -pub struct NormalOps; +#[derive(Default, Copy, Clone)] +pub struct NormalOps(()); impl Ops for NormalOps {} @@ -26,7 +23,6 @@ impl UnitaryOps for NormalOps { } } -#[cfg(feature = "unstable")] impl BulkOps for NormalOps { unsafe fn memmove(dst: *mut T, src: *const T, count: usize) { unsafe { ptr::copy(src, dst, count) } diff --git a/crates/sel4-externally-shared/src/ops/unordered_atomic_ops.rs b/crates/sel4-externally-shared/src/ops/unordered_atomic_ops.rs index 39d76fb6e..302c14584 100644 --- a/crates/sel4-externally-shared/src/ops/unordered_atomic_ops.rs +++ b/crates/sel4-externally-shared/src/ops/unordered_atomic_ops.rs @@ -1,29 +1,24 @@ // // Copyright 2023, Colias Group, LLC // -// SPDX-License-Identifier: MIT OR Apache-2.0 +// SPDX-License-Identifier: BSD-2-Clause // -#![cfg_attr(not(feature = "unstable"), allow(dead_code))] -#![cfg_attr(not(feature = "unstable"), allow(unused_imports))] - use core::mem; #[cfg(feature = "unstable")] use core::intrinsics; -use volatile::ops::{Ops, UnitaryOps}; - -#[cfg(feature = "unstable")] -use volatile::ops::BulkOps; +use cfg_if::cfg_if; +use volatile::ops::{BulkOps, Ops, UnitaryOps}; -#[derive(Debug, Default, Copy, Clone)] -pub struct UnorderedAtomicOps; +#[derive(Default, Copy, Clone)] +pub struct UnorderedAtomicOps(()); impl Ops for UnorderedAtomicOps {} #[cfg(feature = "unstable")] -impl UnitaryOps for UnorderedAtomicOps { +impl UnitaryOps for UnorderedAtomicOps { unsafe fn read(src: *const T) -> T { unsafe { intrinsics::atomic_load_unordered(src) } } @@ -34,70 +29,71 @@ impl UnitaryOps for Unordere } #[allow(clippy::missing_safety_doc)] -pub unsafe trait UnsignedPrimitiveWithUnorderedAtomics {} +pub unsafe trait UnsignedPrimitiveWithUnorderedAtomics: Copy {} macro_rules! impl_unsigned_primitive_with_unordered_atomics { ( - $prim:path, $target_has_atomic_key:literal, + $prim:path, $memmove:ident, $memcpy:ident, $memset:ident, ) => { - #[cfg(target_has_atomic = $target_has_atomic_key)] - unsafe impl UnsignedPrimitiveWithUnorderedAtomics for $prim {} - - #[cfg(feature = "unstable")] - #[cfg(target_has_atomic = $target_has_atomic_key)] - impl BulkOps<$prim> for UnorderedAtomicOps { - unsafe fn memmove(dst: *mut $prim, src: *const $prim, count: usize) { - unsafe { $memmove(dst, src, count * mem::size_of::<$prim>()) } + cfg_if! { + if #[cfg(target_has_atomic = $target_has_atomic_key)] { + unsafe impl UnsignedPrimitiveWithUnorderedAtomics for $prim {} + + impl BulkOps<$prim> for UnorderedAtomicOps { + unsafe fn memmove(dst: *mut $prim, src: *const $prim, count: usize) { + unsafe { $memmove(dst, src, count * mem::size_of::<$prim>()) } + } + + unsafe fn memcpy(dst: *mut $prim, src: *const $prim, count: usize) { + unsafe { $memcpy(dst, src, count * mem::size_of::<$prim>()) } + } + + unsafe fn memset(dst: *mut $prim, val: u8, count: usize) { + unsafe { $memset(dst, val, count * mem::size_of::<$prim>()) } + } + } + + extern "C" { + fn $memmove(dest: *mut $prim, src: *const $prim, bytes: usize); + fn $memcpy(dest: *mut $prim, src: *const $prim, bytes: usize); + fn $memset(s: *mut $prim, c: u8, bytes: usize); + } } - - unsafe fn memcpy(dst: *mut $prim, src: *const $prim, count: usize) { - unsafe { $memcpy(dst, src, count * mem::size_of::<$prim>()) } - } - - unsafe fn memset(dst: *mut $prim, val: u8, count: usize) { - unsafe { $memset(dst, val, count * mem::size_of::<$prim>()) } - } - } - - extern "C" { - fn $memmove(dest: *mut $prim, src: *const $prim, bytes: usize); - fn $memcpy(dest: *mut $prim, src: *const $prim, bytes: usize); - fn $memset(s: *mut $prim, c: u8, bytes: usize); } }; } impl_unsigned_primitive_with_unordered_atomics! { - u8, "8", + u8, __llvm_memmove_element_unordered_atomic_1, __llvm_memcpy_element_unordered_atomic_1, __llvm_memset_element_unordered_atomic_1, } impl_unsigned_primitive_with_unordered_atomics! { - u16, "16", + u16, __llvm_memmove_element_unordered_atomic_2, __llvm_memcpy_element_unordered_atomic_2, __llvm_memset_element_unordered_atomic_2, } impl_unsigned_primitive_with_unordered_atomics! { - u32, "32", + u32, __llvm_memmove_element_unordered_atomic_4, __llvm_memcpy_element_unordered_atomic_4, __llvm_memset_element_unordered_atomic_4, } impl_unsigned_primitive_with_unordered_atomics! { - u64, "64", + u64, __llvm_memmove_element_unordered_atomic_8, __llvm_memcpy_element_unordered_atomic_8, __llvm_memset_element_unordered_atomic_8, @@ -109,7 +105,6 @@ type UsizeCastTarget = u32; #[cfg(target_pointer_width = "64")] type UsizeCastTarget = u64; -#[cfg(feature = "unstable")] #[cfg(any( all(target_pointer_width = "32", target_has_atomic = "32"), all(target_pointer_width = "64", target_has_atomic = "64"), diff --git a/crates/sel4-externally-shared/src/ops/zerocopy_ops.rs b/crates/sel4-externally-shared/src/ops/zerocopy_ops.rs index ceb3580d3..b69caf2b5 100644 --- a/crates/sel4-externally-shared/src/ops/zerocopy_ops.rs +++ b/crates/sel4-externally-shared/src/ops/zerocopy_ops.rs @@ -1,17 +1,18 @@ // // Copyright 2023, Colias Group, LLC // -// SPDX-License-Identifier: MIT OR Apache-2.0 +// SPDX-License-Identifier: BSD-2-Clause // -use volatile::ops::{Ops, UnitaryOps}; -use zerocopy::{AsBytes, FromBytes}; +use core::marker::PhantomData; -#[cfg(feature = "unstable")] -use volatile::ops::BulkOps; +use volatile::ops::{BulkOps, Ops, UnitaryOps}; +use zerocopy::{AsBytes, FromBytes}; -#[derive(Debug, Default, Copy, Clone)] -pub struct ZerocopyOps(O); +#[derive(Default, Copy, Clone)] +pub struct ZerocopyOps { + _phantom: PhantomData, +} impl Ops for ZerocopyOps {} @@ -25,7 +26,6 @@ impl, T: FromBytes + AsBytes> UnitaryOps for ZerocopyOps } } -#[cfg(feature = "unstable")] impl, T: FromBytes + AsBytes> BulkOps for ZerocopyOps { unsafe fn memmove(dst: *mut T, src: *const T, count: usize) { unsafe { O::memmove(dst, src, count) } diff --git a/hacking/cargo-manifest-management/manifest-scope.nix b/hacking/cargo-manifest-management/manifest-scope.nix index a897836df..11d334ff0 100644 --- a/hacking/cargo-manifest-management/manifest-scope.nix +++ b/hacking/cargo-manifest-management/manifest-scope.nix @@ -177,7 +177,7 @@ in rec { volatileSource = { git = "https://github.com/coliasgroup/volatile.git"; - tag = "keep/8aee5539716d3d38247f46eddd42b382"; # branch coliasgroup + tag = "keep/aa7512906e9b76066ed928eb6986b0f9"; # branch coliasgroup }; fatSource = { diff --git a/hacking/cargo-manifest-management/manual-manifests.nix b/hacking/cargo-manifest-management/manual-manifests.nix index 398b608c2..ab12e7b96 100644 --- a/hacking/cargo-manifest-management/manual-manifests.nix +++ b/hacking/cargo-manifest-management/manual-manifests.nix @@ -14,4 +14,5 @@ in { # ring = relativeToTmpSrc "ring"; # rustls = relativeToTmpSrc "rustls/rustls"; # lock_api = relativeToTmpSrc "parking_lot/lock_api"; + # volatile = relativeToTmpSrc "volatile"; }