Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upOverhaul API #33
Comments
This was referenced May 7, 2017
This comment has been minimized.
This comment has been minimized.
brson
commented
May 9, 2017
|
This looks like something somebody new to the memmap crate could pick off, but maybe needs some guidance from @danburkert. |
This comment has been minimized.
This comment has been minimized.
|
Note that a way of converting Mmap <=> MmapMut is required in order to not lose features like the ability to write a safe JIT. Also I think someone requested a way to make unreadable but executable mappings, how would those be integrated? |
This comment has been minimized.
This comment has been minimized.
|
We discussed adding a third |
This comment has been minimized.
This comment has been minimized.
ghost
commented
May 11, 2017
|
Hey hi! II'm new to memmap as @brson said, but I'd like to help here :) |
This comment has been minimized.
This comment has been minimized.
brson
commented
May 13, 2017
|
@z1mvader it looks like @bugaevc has a [PR] opened on this subject already. |
This comment has been minimized.
This comment has been minimized.
|
@bugaevc landed the first cleanup patch, thanks! I think the next major piece that needs to be overhauled is the impl<'a> FileMmapOptions<'a> {
/// mmap(ptr, len, PROT_READ, MAP_SHARED, fd, offset)
pub fn map(&self) -> Result<Mmap> { ... }
/// mmap(ptr, len, PROT_READ | PROT_EXECUTE, MAP_SHARED, fd, offset)
pub fn map_execute(&self) -> Result<Mmap> { ... }
/// mmap(ptr, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset)
pub fn map_mut(&self) -> Result<MmapMut> { ... }
/// mmap(ptr, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, offset)
pub fn map_copy(&self) -> Result<MmapMut> { ... }
}
impl AnonymousMmapOptions {
/// mmap(ptr, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, fd, offset)
pub fn map_mut(&self) -> Result<MmapMut> { ... }
}
impl Mmap {
// mprotect(ptr, len, PROT_READ | PROT_WRITE)
pub fn make_mut(mut self, protection: Protection) -> Result<MmapMut> { ... }
}
impl MmapMut {
// mprotect(ptr, len, PROT_READ)
pub fn make_read_only(mut self) -> Result<Mmap> { ... }
// mprotect(ptr, len, PROT_READ | PROT_EXEC)
pub fn make_read_exec(mut self) -> Result<Mmap> { ... }
...
// flush methods
}Open questions:
|
This comment has been minimized.
This comment has been minimized.
What you really want here is an API for managing virtual memory, not an API for anonymous memory mapped files. While they may both use In my opinion, the needs and use cases that people express for memory maps are probably quite skewed by the fact that people abuse memory maps for virtual memory management due to the a lack of good alternative. As a result, the sooner we get a dedicated API for virtual memory management, the sooner we'd be able to know what we actually need from regular memory maps. |
This was referenced May 29, 2017
This comment has been minimized.
This comment has been minimized.
brson
commented
Jul 6, 2017
|
I see all the op checkboxes are checked but that @danburkert has a linked PR open. So I take it that there's one more thing to do here. |
This comment has been minimized.
This comment has been minimized.
Lapin0t
commented
Jul 30, 2017
|
I would love to have a higher-level API which would much more look like an allocator, ie something that return something more or less like |
This comment has been minimized.
This comment has been minimized.
|
I think higher level abstractions are going to be out of scope for this crate, we used to have some in crate but they've since been taken out. I think it would be interesting to do experiments with the new Allocator API and memory maps, but ideally it can be done outside this crate (if not, we should fix that). |
danburkert
closed this
Aug 17, 2017
This comment has been minimized.
This comment has been minimized.
|
Woops, there are definitely still refactors coming (see #46). |
sfackler commentedMay 7, 2017
•
edited by danburkert
MmapViewandMmapViewSynctypesMmapandMmapMutfor readable and readable/writable mappings respectively. They implementDeref<Target= [u8]>/DerefMutas appropriate. In contexts where access to the mapped region could cause faults (e.g. file backed maps on Unix) make the constructor unsafe.MmapandMmapMut, but move advanced configuration to anOpenOptions-style builder. The builder will provide a cross-platform API directly with OS specific extension traits.