linux: complete siginfo_t definition - #5345
Conversation
siginfo_t definitionsiginfo_t definition
This comment was marked as outdated.
This comment was marked as outdated.
|
Would you mind using this as an opportunity to move Also fyi, @xtqqczze found https://github.com/sailfishos-mirror/glibc as a mirror for glibc that's much easier to search and less flaky, that's fine to link (as is sourceware, of course). |
|
There will be quite a bit less to review after that, so will hold off taking a closer look. Let me know if you need help figuring out the module structure. @rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
a6ba6f4 to
bd71182
Compare
This comment has been minimized.
This comment has been minimized.
b02986c to
08192fa
Compare
1e7631c to
72a1606
Compare
|
I'm not sure what, but I had something else to do in this patchset. Hopefully @rustbot ready |
This comment has been minimized.
This comment has been minimized.
72a1606 to
a8ee195
Compare
This comment has been minimized.
This comment has been minimized.
a8ee195 to
f920138
Compare
61ec092 to
796c4ae
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| si_utime: crate::clock_t, | ||
| si_stime: crate::clock_t, |
There was a problem hiding this comment.
On x32, this needs some kind of alignment adjustment https://github.com/sailfishos-mirror/glibc/blob/4a07bb292f921c10e71fbf48c4a7f44391feb06c/sysdeps/unix/sysv/linux/x86/bits/siginfo-arch.h#L12-L14, maybe a struct __SI_CLOCK_T(crate::clock_t) that gets an alignment attribute on specific platforms.
| }; | ||
|
|
||
| s_no_extra_traits! { | ||
| pub struct siginfo_t { |
There was a problem hiding this comment.
Similarly it needs an alignment attribute on x32 for __SI_ALIGNMENT. I guess these were preexisting but may as well be fixed here.
|
|
||
| #[cfg(target_pointer_width = "64")] | ||
| #[inline] | ||
| pub unsafe fn si_band(&self) -> c_int { |
There was a problem hiding this comment.
This can be a type __SI_BAND_TYPE = ... to match the header
There was a problem hiding this comment.
Could you merge the siginfo_arch files into siginfo_t? Since there are just a few changed fields we may as well reduce the duplication, and it's easier to see the differences (like the original source).
You could keep the files separate for __SI_BAND_TYPE and __SI_CLOCK_T but I don't think that's worth it for 1-2 cfg_ifs. Just make a note that this one file represents multiple headers.
| #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] | ||
| pub si_errno: c_int, | ||
| pub si_code: c_int, | ||
| #[cfg(any(target_arch = "mips", target_arch = "mips64"))] |
There was a problem hiding this comment.
You'll also need mips32r6 and mips64r6 here, and everywhere mips is configured. Somewhat annoyingly #t-compiler > mipsr6 targets `target_arch` confusion.
| // FIXME(pthread): eventually all platforms should use this module | ||
| #[cfg(target_os = "linux")] | ||
| pub(crate) use sysdeps::nptl::*; | ||
| #[allow(unused)] | ||
| pub(crate) use sysdeps::nptl::{ | ||
| bits as nptl_bits, | ||
| pthread, | ||
| }; | ||
| #[cfg(target_os = "linux")] | ||
| pub(crate) use sysdeps::unix::linux::*; | ||
| pub(crate) use sysdeps::unix::linux::{ | ||
| bits as linux_bits, | ||
| net, | ||
| }; |
There was a problem hiding this comment.
If bits isn't needed, can only pthread be reexported?
It might even be possible to just drop the pub(crate) from the bits modules, since they're not really needed at this level.
| #[cfg(target_env = "uclibc")] | ||
| pub use sysdeps::linux::common::bits::siginfo::*; | ||
|
|
||
| #[cfg(target_env = "gnu")] | ||
| pub use net::route::*; | ||
| #[cfg(target_env = "gnu")] | ||
| pub use signal::*; | ||
| pub use self::{ | ||
| linux_bits::types::siginfo_t::*, | ||
| net::route::*, | ||
| signal::*, | ||
| }; |
There was a problem hiding this comment.
The loose idea is that the modules reexported here should correspond to headers that are used. That is, #include <linux/tls.h> maps to pub use linux::tls::*;, and #include <signal.h> maps to pub use signal::*. So these probably need a mod signal somewhere that reexports from bits, since users don't import sysdeps/linux/common/bits/signinfo.h directly.
Replace references to `siginfo_t` in the regular repository layout with a crate-relative path that uses the reexport from the `new` module. This allows the next few patches to all work as individual revisions.
Replace alignment/padding fields with a one-to-one definition as that used upstream. These have been incorporated as definitions in the `new` module to avoid huge repetition across target triples without overrides. The glibc definitions are mostly the same across target architectures except for MIPS, SPARC and x86. x86 is confusing because there's only an override when running under x86_64 and compiling for x32. I'm not sure how Rust handles this, so the `#[path]`-redirected files for that architecture are the same as the generic ones. See [^1] for the generic file and the following list for the architecture-specific overrides. - `mips`: <https://github.com/sailfishos-mirror/glibc/blob/4a07bb292f921c10e71fbf48c4a7f44391feb06c/sysdeps/unix/sysv/linux/mips/bits/siginfo-arch.h> - `sparc`: <https://github.com/sailfishos-mirror/glibc/blob/4a07bb292f921c10e71fbf48c4a7f44391feb06c/sysdeps/unix/sysv/linux/sparc/bits/siginfo-arch.h> - `x86`: <https://github.com/sailfishos-mirror/glibc/blob/4a07bb292f921c10e71fbf48c4a7f44391feb06c/sysdeps/unix/sysv/linux/x86/bits/siginfo-arch.h> [^1]: <https://github.com/sailfishos-mirror/glibc/blob/4a07bb292f921c10e71fbf48c4a7f44391feb06c/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h>
Remove older bindings to `siginfo_t` using dummy fields instead of the upstream `union`. This follows from the patch providing a full definition for glibc bindings. Add reexports for `siginfo_t` under the `new` module. This has required renaming the reexport for the `nptl` module as it also contains a `bits` module of the same name as the `bits::types::siginfo_t` module path under `sysdeps`.
Replace alignment/padding fields with a mirrored definition of the upstream `union`. See [^1] for details. [^1]: <https://github.com/kraj/musl/blob/a42e9dee266f398026a33d0793c66225c7997755/include/signal.h>
Remove older bindings to `siginfo_t` using dummy fields instead of the upstream `union`. This follows from the patch providing a full definition for musl bindings. Add modified bindings under `new`.
Replace alignment/padding dummy fields with a mirrored definition fitting that of upstream's `union`. uClibc supports targets for which we have no support in Rust. No architecture-specific definition has been provided for those. See [^1] for details on the generic definition and [^2] for details on the MIPS definition. [^1]: <https://github.com/wbx-github/uclibc-ng/blob/60d8e8c0cb9be8a241f6f2645daba260c8aec33c/libc/sysdeps/linux/common/bits/siginfo.h> [^2]: <https://github.com/wbx-github/uclibc-ng/blob/60d8e8c0cb9be8a241f6f2645daba260c8aec33c/libc/sysdeps/linux/mips/bits/siginfo.h>
Remove older bindings to `siginfo_t` using dummy fields instead of the upstream `union`. This follows from the patch providing a full definition for uClibc bindings. Add modified bindings to `new` module.
796c4ae to
2de5e62
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Description
Completes the
siginfo_tdefinition under Linux targets. Closes #716.See the patch messages for details on each of the GNU targets, uClibc
targets and musl targets.
Checklist
libc-test/semverhave been updated*LASTor*MAXhave thestandard doc comment
cargo test -p libc-test --target mytarget);especially relevant for platforms that may not be checked in CI
@rustbot label +stable-nominated