Conversation
|
Would you be willing to write a testsuite for |
|
I don't think I'm the right person to do that; I don't know the APIs very deeply. |
|
Is there anything else I need to do so that this can be merged? It keeps picking up conflicts in the changelog... |
|
I would feel much better about the PR if there were some tests. Even a simple doc test would be good. Right now it's not obvious how to use it. Also, |
|
Got it; I was following the pattern of the rest of the definitions in that module, which don't have those things; I'll get a doctest merged shortly. |
|
Well, it looks like my test is only gonna pass on Linux, due to differences in how |
| /// | ||
| /// let mut slice: &mut [u8] = unsafe { | ||
| /// let mem = mmap(ptr::null_mut(), 1024, ProtFlags::PROT_NONE, | ||
| /// MapFlags::MAP_ANONYMOUS | MapFlags::MAP_PRIVATE, -1, 0).unwrap(); |
There was a problem hiding this comment.
MAP_ANONYMOUS is a nonstandard flag, so it doesn't make a great example.
There was a problem hiding this comment.
I've only ever used mmap with MAP_ANONYMOUS, but from what I can tell by the POSIX manpage, it would need a file descriptor if that flag isn't used. This has to either be backed by a real file or a typed memory object, the API for which nix doesn't support. This is starting to feel way too complicated for a 3 line wrapper function, and would be more appropriate for a larger mman test suite.
There was a problem hiding this comment.
It looks like MAP_ANON at least passes on all the CI platforms, even though it's also not in POSIX. Good enough?
6218aca to
6965172
Compare
asomers
left a comment
There was a problem hiding this comment.
You'll need to rebase this change before bors will agree to merge it. Our CI setup recently changed.
| /// See [`mprotect(3)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mprotect.html) for | ||
| /// details. | ||
| /// | ||
| /// # Safety Calls to `mprotect` are inherently unsafe, as changes to memory protections can lead to |
There was a problem hiding this comment.
You need a newline after "Safety". Also, is there any advice you can offer on how the user can use this function safely?
There was a problem hiding this comment.
Newline fixed; Emacs got overly enthusiastic about reflowing that paragraph.
As for advice, anything I write would be just rewriting the linked manpage. It's such a broad API with so many potential implications that I think it would serve folks best to just use that as a resource.
|
Can you please squash your two commits into one? We can't do that ourselves because of bors. |
b289f39 to
0d20c37
Compare
|
Squashed and rebased on the current master; I think this CI failure is unrelated to this PR though |
|
@asomers is this ready to merge now? |
|
Uh, could you remove that odd blank line in the CHANGELOG? |
|
Got it; of course the online editor first tried to make a merge conflict out of it :( |
Build succeeded
|
It doesn't look like there's an existing test suite for
mmapand friends, so this is regrettably untested.