Skip to content
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

[AIX] Use sa_sigaction instead of the union #4250

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xingxue-ibm
Copy link

Description

The current libc crate implementation for AIX defines struct sigaction as containing a union sa_union with two members: __su_handler and __su_sigaction. This mirrors the struct sigaction definition in the AIX system header. Consequently, any reference to sa_sigaction in Rust code, whether in shipped crates or user code, must be replaced with sa_union.__su_sigaction for AIX. Additionally, the types of these two union members are declared as function pointers rather than sighandler_t (i.e., usize), as is the case on other platforms. This discrepancy causes compiler errors when sighandler_t is used as the type for signal handlers. Other operating systems, such as Linux, also define a union for sa_handler and sa_sigaction in struct sigaction. However, the libc crate implementations on these platforms define sa_sigaction directly as a member of struct sigaction rather than as part of a union. This patch modifies the libc crate implementation for AIX to define sa_sigaction as a direct member of struct sigaction, aligning it with implementations for other similar platforms. We will also update affected crates and test cases to reflect this change.

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot
Copy link
Collaborator

rustbot commented Jan 23, 2025

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @tgross35 (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@xingxue-ibm
Copy link
Author

close GH-4249

@xingxue-ibm xingxue-ibm changed the title [AIX] Use sa_sigaction instead the union [AIX] Use sa_sigaction instead of the union Feb 13, 2025
Copy link

@daltenty daltenty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from the AIX perspective. This makes the implementation common with what is done on other targets


pub struct sigaction {
pub sa_union: __sigaction_sa_union,
pub sa_sigaction: crate::sighandler_t, //actually a union with sa_handle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that should be changed once we are able to use unions (1.0)? If so, could you label the comment FIXME(union)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed as suggested, thanks so much!

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a rebase but the change LGTM. @xingxue-ibm @daltenty do you want this in a stable release since it is a breaking change?

@xingxue-ibm
Copy link
Author

Needs a rebase but the change LGTM. @xingxue-ibm @daltenty do you want this in a stable release since it is a breaking change?

Done rebasing. Yeah, it would be great if this change could be included in a stable release. What do you think, @daltenty?

@tgross35 tgross35 enabled auto-merge February 24, 2025 20:31
@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-unix S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants