Skip to content

WIP: Use a more type safe alternative for sigaction types#5076

Open
lewis-belsten-revill wants to merge 1 commit intorust-lang:libc-0.2from
lewis-belsten-revill:0.2.185-sigaction-cheri
Open

WIP: Use a more type safe alternative for sigaction types#5076
lewis-belsten-revill wants to merge 1 commit intorust-lang:libc-0.2from
lewis-belsten-revill:0.2.185-sigaction-cheri

Conversation

@lewis-belsten-revill
Copy link
Copy Markdown

Description

We cannot safely rely on considering usize and pointers as interchangeable, especially on CHERI where the pointer size is larger than a usize. Using a union is a much safer option and it actually communicates the fact that we interpret these fields differently in different situations.

Sources

E.G: https://git.musl-libc.org/cgit/musl/tree/include/signal.h#n170

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

This would be a disruptive change to crates currently using these types, however it (or something similar) is absolutely necessary in order for us to be compatible on targets where the size of a function pointer is not equal to a size_t. C is obviously less strict about things which appear to not be unions but that are treated as such, however on the C side, at least the type used in these declarations is the maximum of the two types (fn ptr > size_t), whereas we are just currently using size_t. For an example of the changes this implies to other crates, see lewis-belsten-revill/wait-timeout@f5e0175

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 24, 2026

⚠️ Warning ⚠️

  • Pull requests are usually filed against the main branch for this repo, but this one is against libc-0.2. Please double check that you specified the right target!

@lewis-belsten-revill lewis-belsten-revill force-pushed the 0.2.185-sigaction-cheri branch 2 times, most recently from 2d90d99 to c6fffa1 Compare May 1, 2026 15:47
We cannot safely rely on considering usize and pointers as
interchangeable, especially on CHERI where the pointer size is larger
than a usize. Using a union is a much safer option and it actually
communicates the fact that we interpret these fields differently in
different situations.
@lewis-belsten-revill lewis-belsten-revill force-pushed the 0.2.185-sigaction-cheri branch from c6fffa1 to c7aad86 Compare May 1, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants