Coder Social home page Coder Social logo

Comments (1)

marc-casperlabs avatar marc-casperlabs commented on July 18, 2024

After some advice from the Rust Discord, the code still has issues:

let slice = &self[offset..(offset + mem::size_of::<T>())];
let item_ptr = slice.as_ptr() as *const T;
let item = unsafe { &*item_ptr };
item

  • Unaligned access must be done through ptr::read_unaligned & similar. It is probably necessary to implement #14 and in the constructor ensure that the chosen alignment is divisible by mem::align_of::<RecordHeader> when offset by the length
  • There must not exist any (even temporary) aliased references to mutable memory at the same time, like there is with slice and item in the mutable version of the function. Better to do pointer math instead.
  • A check for the enforced alignment should also be done, as the page boundary needs to be divisible by it - as that's the alignment that will be returned by mmap usually.

Volatile itself does not seem to be an issues, as it is mainly concerned about ensuring that multiple repeated writes to a location are not reordered or omitted, as would be the case for an IO device.

from stuffer_shack-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.