-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add sys/ucontext.h signatures for linux aarch64 glibc #3001
Conversation
r? @JohnTitor (rust-highfive has picked a reviewer for you, use r? to override) |
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.
Seems fine. Matches declaration in headers, assuming our struct ucontext
is right (which this PR doesn't add).
The iopl/ioperm stuff is a bit odd to have but I suppose this allows for following a consistent error handling path rather than cfg
ing it out.
This also matches the way we expose |
Thanks! @bors r+ |
Add sys/ucontext.h and sys/io.h signatures for linux aarch64 glibc ### `getcontext`, `setcontext`, `makecontext`, `swapcontext` From \<sys/ucontext.h\>. The specification for these was removed from POSIX.1-2008 in favor of POSIX threads, but glibc continues to ship an implementation for aarch64 just as it does for x86_64. Libc crate's existing x86_64 binding with the same signatures added in this PR: https://github.com/rust-lang/libc/blob/bbf929d2c8355fa19384b3551c5874c866be465f/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs#L810-L813 Glibc implementation: - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/getcontext.S - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/setcontext.S - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/makecontext.c - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/swapcontext.S <br> ### `iopl`, `ioperm` From \<sys/io.h\>. These are functions for accessing x86 I/O ports. ARM has no such I/O ports in the architecture. Linux's `man 2` for both functions contains: _"This call is mostly for the i386 architecture. On many other architectures it does not exist or will always return an error."_ Glibc ships one of these "always return an error" implementation of both functions for aarch64. Matching signatures from x86_64: https://github.com/rust-lang/libc/blob/bbf929d2c8355fa19384b3551c5874c866be465f/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs#L814-L815 Glibc implementation: - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/arm/ioperm.c The implementation has `unsigned int` for the argument of `iopl` but I've used int in the PR to match the Linux docs, which seems more authoritative. Unclear why glibc diverges from this but it doesn't make a difference in the ABI.
💔 Test failed - checks-actions |
/checkout/target/aarch64-unknown-linux-gnu/debug/build/libc-test-5a973a03a651b470/out/main.c: In function '__test_fn_iopl':
/checkout/target/aarch64-unknown-linux-gnu/debug/build/libc-test-5a973a03a651b470/out/main.c:53524:24: error: 'iopl' undeclared (first use in this function)
53524 | return iopl;
| ^~~~
/checkout/target/aarch64-unknown-linux-gnu/debug/build/libc-test-5a973a03a651b470/out/main.c:53524:24: note: each undeclared identifier is reported only once for each function it appears in
/checkout/target/aarch64-unknown-linux-gnu/debug/build/libc-test-5a973a03a651b470/out/main.c: In function '__test_fn_ioperm':
/checkout/target/aarch64-unknown-linux-gnu/debug/build/libc-test-5a973a03a651b470/out/main.c:53529:24: error: 'ioperm' undeclared (first use in this function); did you mean 'ipc_perm'?
53529 | return ioperm;
| ^~~~~~
| ipc_perm I did a bit of digging in glibc, it turns out glibc ships definitions of |
@bors r+ |
Add sys/ucontext.h signatures for linux aarch64 glibc ### `getcontext`, `setcontext`, `makecontext`, `swapcontext` From \<sys/ucontext.h\>. The specification for these was removed from POSIX.1-2008 in favor of POSIX threads, but glibc continues to ship an implementation for aarch64 just as it does for x86_64. Libc crate's existing x86_64 binding with the same signatures added in this PR: https://github.com/rust-lang/libc/blob/bbf929d2c8355fa19384b3551c5874c866be465f/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs#L810-L813 Glibc implementation: - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/getcontext.S - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/setcontext.S - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/makecontext.c - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/swapcontext.S <br> ### ~~`iopl`, `ioperm`~~ ~~From \<sys/io.h\>. These are functions for accessing x86 I/O ports. ARM has no such I/O ports in the architecture. Linux's `man 2` for both functions contains: _"This call is mostly for the i386 architecture. On many other architectures it does not exist or will always return an error."_ Glibc ships one of these "always return an error" implementation of both functions for aarch64.~~ ~~Matching signatures from x86_64:~~ https://github.com/rust-lang/libc/blob/bbf929d2c8355fa19384b3551c5874c866be465f/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs#L814-L815 ~~Glibc implementation:~~ - ~~https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/arm/ioperm.c~~ ~~The implementation has `unsigned int` for the argument of `iopl` but I've used int in the PR to match the Linux docs, which seems more authoritative. Unclear why glibc diverges from this but it doesn't make a difference in the ABI.~~
💔 Test failed - checks-actions |
Can't tell what failed. 😿 |
https://github.com/rust-lang/libc/actions/runs/3502179666/jobs/5866446110#step:5:2455 is supposed to print It doesn't look like it's caused by this PR, but it also doesn't seem to be failing in other PRs. |
Should be fixed by #3005 |
Sorry for the inconvenience! @bors retry |
Add sys/ucontext.h signatures for linux aarch64 glibc ### `getcontext`, `setcontext`, `makecontext`, `swapcontext` From \<sys/ucontext.h\>. The specification for these was removed from POSIX.1-2008 in favor of POSIX threads, but glibc continues to ship an implementation for aarch64 just as it does for x86_64. Libc crate's existing x86_64 binding with the same signatures added in this PR: https://github.com/rust-lang/libc/blob/bbf929d2c8355fa19384b3551c5874c866be465f/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs#L810-L813 Glibc implementation: - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/getcontext.S - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/setcontext.S - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/makecontext.c - https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/swapcontext.S <br> ### ~~`iopl`, `ioperm`~~ ~~From \<sys/io.h\>. These are functions for accessing x86 I/O ports. ARM has no such I/O ports in the architecture. Linux's `man 2` for both functions contains: _"This call is mostly for the i386 architecture. On many other architectures it does not exist or will always return an error."_ Glibc ships one of these "always return an error" implementation of both functions for aarch64.~~ ~~Matching signatures from x86_64:~~ https://github.com/rust-lang/libc/blob/bbf929d2c8355fa19384b3551c5874c866be465f/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs#L814-L815 ~~Glibc implementation:~~ - ~~https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/arm/ioperm.c~~ ~~The implementation has `unsigned int` for the argument of `iopl` but I've used int in the PR to match the Linux docs, which seems more authoritative. Unclear why glibc diverges from this but it doesn't make a difference in the ABI.~~
💔 Test failed - checks-actions |
CI for 1.13 fails because it ( |
👍 Moved to align.rs so that they're properly conditional on |
Thanks! @bors r+ |
☀️ Test successful - checks-actions, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13, checks-cirrus-freebsd-14 |
getcontext
,setcontext
,makecontext
,swapcontext
From <sys/ucontext.h>. The specification for these was removed from POSIX.1-2008 in favor of POSIX threads, but glibc continues to ship an implementation for aarch64 just as it does for x86_64.
Libc crate's existing x86_64 binding with the same signatures added in this PR:
libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
Lines 810 to 813 in bbf929d
Glibc implementation:
iopl
,ioperm
From <sys/io.h>. These are functions for accessing x86 I/O ports. ARM has no such I/O ports in the architecture. Linux'sman 2
for both functions contains: "This call is mostly for the i386 architecture. On many other architectures it does not exist or will always return an error." Glibc ships one of these "always return an error" implementation of both functions for aarch64.Matching signatures from x86_64:libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
Lines 814 to 815 in bbf929d
Glibc implementation:https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/arm/ioperm.cThe implementation hasunsigned int
for the argument ofiopl
but I've used int in the PR to match the Linux docs, which seems more authoritative. Unclear why glibc diverges from this but it doesn't make a difference in the ABI.