/// Creates a typed pointer. Note though that the pointer *isn't* guaranteed
/// to be aligned for `T`.
Creates a typed pointer. Note though that the pointer *isn't* guaranteed
to be aligned for `T`.
Creates a typed pointer . Note though that the pointer * isn ' t * guaranteed to be aligned for ` T ` .
pub fn new(ptr: PluginPtr, count: usize) -> Self {
        if log_enabled!(Debug) && usize::from(ptr) % std::mem::align_of::<T>() != 0 {
            // Linux allows unaligned pointers from user-space, being careful to
            // avoid unaligned accesses that aren's supported by the CPU.
            // https://www.kernel.org/doc/html/latest/core-api/unaligned-memory-access.html.
            //
            // We do the same (e.g. by avoiding direct dereference of such
            // pointers even if mmap'd into shadow), but some bugs may slip
            // through (e.g. by asking for a u8 pointer from the mapping code,
            // but then casting it to some other type). Here we leave a debug
            // message here as a sign-post that this could be the root cause of
            // weirdness that happens afterwards.
            debug!(
                "Creating unaligned pointer {:?}. This is legal, but could trigger latent bugs.",
                ptr
            );
        }
        TypedPluginPtr {
            base: ptr,
            count,
            _phantom: PhantomData,
        }
    }
pub fn new ( ptr : PluginPtr , count : usize ) -> Self { if log_enabled ! ( Debug ) && usize :: from ( ptr ) % std :: mem :: align_of :: < T > ( ) != 0 { // Linux allows unaligned pointers from user-space, being careful to // avoid unaligned accesses that aren's supported by the CPU. // https://www.kernel.org/doc/html/latest/core-api/unaligned-memory-access.html. // // We do the same (e.g. by avoiding direct dereference of such // pointers even if mmap'd into shadow), but some bugs may slip // through (e.g. by asking for a u8 pointer from the mapping code, // but then casting it to some other type). Here we leave a debug // message here as a sign-post that this could be the root cause of // weirdness that happens afterwards. debug ! ( " " ptr ) ; } TypedPluginPtr { base : ptr , count , _phantom : PhantomData , } }
Creates a typed pointer.
Creates a typed pointer .
ptr
PluginPtr
count
usize