-
Notifications
You must be signed in to change notification settings - Fork 113
Add support for allocating statically-aligned and dynamically-sized memory #1750
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
Comments
One thing I don't understand from the linked code: let mut buffer = AlignedMem::<Header>::new(
(BLOCK_SIZE + self.header.vpartition_table_size) as usize
+ self.header.allocation_size()?,
); What role does alloc::Layout::from_size_align(size, std::mem::align_of::<T>()).unwrap(), Is it guaranteed somehow that this won't happen? |
Okay, I whipped up something that does roughly what your code does, although it doesn't address the Does that do roughly what you're hoping for? |
Yes. BLOCK_SIZE and
Not quite. The size needs to be variable. |
Where is |
Yeah, I have a TODO to add checks for this: https://cs.opensource.google/fuchsia/fuchsia/+/main:src/storage/fvm/src/main.rs;drc=b04c5108ca31a3a8880119d06dad7e857c2a9b12;l=206. This code is under active development; nothing outside of tests uses it yet. |
Okay gotcha. The dynamic size does make this difficult to support. I can see us supporting it at some point in the future, but the combination of statically-bounded alignment plus dynamic sizing makes things tricky. I'll follow up here if we end up adding features that could make this easier. |
Uh oh!
There was an error while loading. Please reload this page.
See also: #885, #249, #280.
What is the name of your project?
Fuchsia
Please provide a link to your project (GitHub repository, crates.io page, etc).
https://cs.opensource.google/fuchsia/fuchsia/+/main:src/storage/fvm/src/main.rs;drc=b04c5108ca31a3a8880119d06dad7e857c2a9b12;l=1598
What features would you like from zerocopy?
We have a need to allocate memory that has the same alignment as some other type T (that has the zerocopy traits) but is larger than T (it's used for storage so it needs to be rounded to block sizes). Once that's memory as been allocated, ideally it would be possible to use infallible zerocopy methods since the alignment (it's aligned) and size (it's big enough) should be known to be valid.
The text was updated successfully, but these errors were encountered: