StephanvanSchaik / mmap-rs

A cross-platform and safe Rust API to create and manage memory mappings in the virtual address space of the calling process.
Apache License 2.0
61 stars 17 forks source link

Fixup 0.6.0 changelog // Copy on Write / Private #39

Closed baloo closed 1 year ago

baloo commented 1 year ago

I believe there was a mistake in the changelog when it got redacted and there a mix up between MmapFlags::PRIVATE and MmapFlags::SHARED.

I'm not 100% confident, sending the PR to raise the question! (feel free to just close)

StephanvanSchaik commented 1 year ago

Hi,

I had to look at the code again, since the change itself is a bit confusing. The flag got renamed to MmapFlags::SHARED here (https://github.com/StephanvanSchaik/mmap-rs/blob/master/src/mmap.rs#L21), such that it defaults to what would be MmapFlags::PRIVATE (but the flag itself is undefined) and you can opt into MmapFlags::SHARED. I hope that clears that up that particular modification.

Thanks!

baloo commented 1 year ago

oh! https://docs.rs/mmap-rs/0.5.0/mmap_rs/struct.MmapFlags.html#associatedconstant.COPY_ON_WRITE yeah the documentation for copy on write was misleading I think.

baloo commented 1 year ago

I actually used COPY_ON_WRITE in my code expecting PRIVATE, but that's not what I was using haha.

Anyway, thanks!

StephanvanSchaik commented 1 year ago

oh! https://docs.rs/mmap-rs/0.5.0/mmap_rs/struct.MmapFlags.html#associatedconstant.COPY_ON_WRITE yeah the documentation for copy on write was misleading I think.

Yes, you are right. That is why I decided to simplify this in mmap-rs 0.6 to private (default) vs. shared, as not every platform may even bother using copy-on-write, and there are usually no flags to choose between private vs. copy-on-write (i.e. a shared mapping that becomes private once written), and to most users that distinction shouldn't matter, as they are both seemingly private.

As a result the documentation for older versions is unfortunately misleading, but hopefully this clears up the situation a bit better.