-
Notifications
You must be signed in to change notification settings - Fork 245
Use libc::SYS_futex_time64 on riscv32 #485
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
base: master
Are you sure you want to change the base?
Conversation
On RISC-V 32-bit (riscv32), the SYS_futex system call is often handled indirectly due to the use of a 64-bit time_t type. Specifically, while SYS_futex is not directly defined, a related syscall like SYS_futex_time64 can be used, Upstream-Status: Submitted [Amanieu#485] Signed-off-by: Khem Raj <[email protected]>
@@ -108,9 +108,13 @@ impl ThreadParker { | |||
.as_ref() | |||
.map(|ts_ref| ts_ref as *const _) | |||
.unwrap_or(ptr::null()); | |||
#[cfg(not(all(target_arch = "riscv32", target_env = "musl")))] |
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.
Why is this specific to musl? Shouldn't this affect all riscv32 targets?
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.
Why is this specific to musl? Shouldn't this affect all riscv32 targets?
glibc seems to alias SYS_futex
to 64bit syscall, unlike musl
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.
This is still incorrect on musl because libc currently defines timespec
as using 32-bit time while the syscall expects a 64-bit timespec
:
src/unix/linux_like/linux/musl/mod.rs:pub type time_t = c_long;
Proper support for riscv32 would require some work in libc to support these types.
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.
Thats a rust libc bug you have uncovered :) because unlike glibc time_t
is always 64bit on musl for all architectures ( both 32bit and 64bit) so that value should perhaps use dedicated 64bit type instead of c_ulong
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.
This is what musl has
arch/aarch64/bits/alltypes.h.in:#define _Int64 long
arch/arm/bits/alltypes.h.in:#define _Int64 long long
arch/i386/bits/alltypes.h.in:#define _Int64 long long
arch/loongarch64/bits/alltypes.h.in:#define _Int64 long
arch/m68k/bits/alltypes.h.in:#define _Int64 long long
arch/microblaze/bits/alltypes.h.in:#define _Int64 long long
arch/mips/bits/alltypes.h.in:#define _Int64 long long
arch/mips64/bits/alltypes.h.in:#define _Int64 long
arch/mipsn32/bits/alltypes.h.in:#define _Int64 long long
arch/or1k/bits/alltypes.h.in:#define _Int64 long long
arch/powerpc/bits/alltypes.h.in:#define _Int64 long long
arch/powerpc64/bits/alltypes.h.in:#define _Int64 long
arch/riscv32/bits/alltypes.h.in:#define _Int64 long long
arch/riscv64/bits/alltypes.h.in:#define _Int64 long
arch/s390x/bits/alltypes.h.in:#define _Int64 long
arch/sh/bits/alltypes.h.in:#define _Int64 long long
arch/x32/bits/alltypes.h.in:#define _Int64 long long
arch/x86_64/bits/alltypes.h.in:#define _Int64 long
include/alltypes.h.in:TYPEDEF _Int64 time_t;
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.
Yes, the libc bug needs to be addressed before this PR can be merged.
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.
I don't see dependency with libc bug for this PR
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.
I have created a PR for rust libc as well
rust-lang/libc#4581
On RISC-V 32-bit (riscv32), the SYS_futex system call is often handled indirectly due to the use of a 64-bit time_t type. Specifically, while SYS_futex is not directly defined, a related syscall like SYS_futex_time64 can be used on target e.g. riscv32 Signed-off-by: Khem Raj <[email protected]>
On RISC-V 32-bit (riscv32), the SYS_futex system call is often handled indirectly due to the use of a 64-bit time_t type. Specifically, while SYS_futex is not directly defined, a related syscall like SYS_futex_time64 can be used,