-
Notifications
You must be signed in to change notification settings - Fork 683
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
mmap addr #1870
mmap addr #1870
Conversation
9793c7f
to
e19ab7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This increases the size of the argument. How about using Option<std::ptr::NonNull>
instead? Or Option<std::num::NonZeroUsize>
?
e19ab7f
to
96fa1b8
Compare
Good point, updated to use |
699e482
to
7468c81
Compare
CHANGELOG.md
Outdated
@@ -35,6 +35,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). | |||
|
|||
- The MSRV is now 1.56.1 | |||
([#1792](https://github.com/nix-rust/nix/pull/1792)) | |||
- Passes `addr` to `sys::mmap` as `Option<NonZeroUsize>` from `*mut c_void`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this wording confusing. How about this?
- Passes `addr` to `sys::mmap` as `Option<NonZeroUsize>` from `*mut c_void`. | |
- The `addr` argument to `sys::mman::mmap` is now of type `Option<NonZeroUsize>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
7468c81
to
d34696c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
Uses
Some<size_t>
instead of*mut c_void
for theaddr
passed tosys::mman::mmap
.In this instance we are not usefully passing a pointer, it will never be dereferenced. We are passing a location which represents where to attach the shared memory to.
In this case
size_t
better represents an address and not a pointer, andOption<size_t>
better represents an optional argument thanNULLPTR
.In C since there is no optional type this is a pointer as this allows it be null which is an alias here for
None
.