Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Implement safe bindings around pthread_sigqueue. #1798
base: master
Are you sure you want to change the base?
Implement safe bindings around pthread_sigqueue. #1798
Changes from 3 commits
227b45f
07a9d97
a79d7ed
124171a
1d89fef
8ff99ac
c7ce0f3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why not? It's possible to define unions in libc these days. Unless there is a very compelling reason not to, you should submit this as a PR for libc.
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.
The problem is there already is a sigval in libc and is defined as a struct(which is used in many places since signal handling has several syscalls associated with it). That struct has PartialEq/Hash/Debug etc implemented, and has done so for a long time. There's no practical way to implement PartialEq/Hash/Debug for a union b/c that would lead to hashing/equality checking/printing uninitialized memory. So changing the current struct to a union is a breaking change. (see: rust-lang/libc#2816)
I can add a second definition in libc, but it would have to have a different name. If that's desired I guess reply to this comment. I'll also update that comment with the info in this one.
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.
Have you seen rust-lang/libc#2813 ? It deals with another union that was originally defined as a struct in libc. The solution we came up with there was to define a
sigevent_0_2_126
struct identical to the oldsigevent
, and then definesigevent
with union fields as it ought to be. Then implement Deref and DerefMut for sigevent to sigevent_0_2_126 . That way consumers of the old version can still access the fields that should've been in a union. Would something similar work for sigval?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.
You can simplify this to
And likewise in the test
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.
Done.
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 part looks like a merge error. You should revert it.
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.
Removing the commit that does this causes this CI failure: https://github.com/nix-rust/nix/pull/1798/checks?check_run_id=7898677574