Skip to content

Add pthread_sigqueue to linux/other #991

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

Closed
wants to merge 1 commit into from

Conversation

martinhath
Copy link

I'm not too sure about where to put this, as it seems to be a GNU extension, but other pthread functions that were also GNU extensions, like pthread_rwlockattr_setkind_np was in the same file, so I just put it directly above.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@alexcrichton
Copy link
Member

Thanks! Looks like there's some style errors on CI though?

@martinhath
Copy link
Author

Yeah, there's something off here.

cargo:warning=/checkout/target/x86_64-unknown-linux-gnu/debug/build/libc-test-c51dd8e7821c7fe7/out/main.c:20982:76: error: 'sigval' defined as wrong kind of tag
cargo:warning=             int (*__test_fn_pthread_sigqueue(void))(pthread_t, int, struct sigval) {
cargo:warning=                                                                            ^~~~~~
cargo:warning=/checkout/target/x86_64-unknown-linux-gnu/debug/build/libc-test-c51dd8e7821c7fe7/out/main.c:20982:76: error: 'struct sigval' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
cargo:warning=/checkout/target/x86_64-unknown-linux-gnu/debug/build/libc-test-c51dd8e7821c7fe7/out/main.c: In function '__test_fn_pthread_sigqueue':
cargo:warning=/checkout/target/x86_64-unknown-linux-gnu/debug/build/libc-test-c51dd8e7821c7fe7/out/main.c:20983:24: error: return from incompatible pointer type [-Werror=incompatible-pointer-types]
cargo:warning=                 return pthread_sigqueue;
cargo:warning=                        ^~~~~~~~~~~~~~~~
cargo:warning=cc1: all warnings being treated as errors
exit code: 1

It looks like it complaints about the sigval type, which is defined in src/unix/mod.rs:156:

pub struct sigval {
    // Actually a union of an int and a void*
    pub sival_ptr: *mut ::c_void
}

although its use seems fine in other contexts, like src/unix/notbsd/mod.rs:168

pub struct sigevent {
    pub sigev_value: ::sigval,
    pub sigev_signo: ::c_int,

According to the man pages I found online (and for sigevent), the types should be the same: union sigval (well, sigqueue uses const union sigval, but from the error message it looks like its the struct that's the problem?)

@alexcrichton
Copy link
Member

I think that error is because in C the signature is different, maybe sigval is taken by a pointer?

@martinhath
Copy link
Author

Both are supposed to be sigval, but in C the sigval is a

union sigval {
    int     sival_int;
    void   *sival_ptr;
};

The current sigval that we have is just the void * variant, as shown in my previous comment. It seems that enum arguments are a problem for libc in any case? rg "union" shows quite a few "Actually a union of ..."

@alexcrichton
Copy link
Member

Looks like on CI the signature may still not match?

Especially with signals I've found that the documented standard and the actual headers tend to differ a bit...

@alexcrichton
Copy link
Member

I'm gonna close this now due to inactivity, but it can of course be resubmitted!

@pirocks pirocks mentioned this pull request Aug 13, 2022
bors added a commit that referenced this pull request Aug 15, 2022
Add pthread_sigqueue.

This resurrects #991.

Should be a pretty straightforward addition of pthread_sigqueue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants