diff --git a/Cargo.lock b/Cargo.lock index 634e81eaf80b4..a2172bdb51513 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2273,9 +2273,9 @@ checksum = "803ec87c9cfb29b9d2633f20cba1f488db3fd53f2158b1024cbefb47ba05d413" [[package]] name = "libc" -version = "0.2.189" +version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" [[package]] name = "libffi" @@ -2378,9 +2378,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "litemap" @@ -5191,9 +5191,9 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.2" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" dependencies = [ "bitflags", "errno", diff --git a/library/std/src/sys/sync/futex/unix.rs b/library/std/src/sys/sync/futex/unix.rs index 004d8323060e5..82861c35e4c43 100644 --- a/library/std/src/sys/sync/futex/unix.rs +++ b/library/std/src/sys/sync/futex/unix.rs @@ -11,6 +11,18 @@ pub type SmallFutex = Atomic; /// Must be the underlying type of SmallFutex pub type SmallPrimitive = u32; +#[cfg(any(target_os = "linux", target_os = "android"))] +cfg_select! { + // riscv32 only exposes the `SYS_futex_time64` syscall, + // whereas other 32-bit targets also expose `SYS_futex`, which uses 32-bit time. + target_arch = "riscv32" => { + use libc::SYS_futex_time64 as SYS_futex; + } + _ => { + use libc::SYS_futex; + } +} + /// Waits for a `futex_wake` operation to wake us. /// /// Returns directly if the futex doesn't hold the expected value. @@ -61,7 +73,7 @@ pub fn futex_wait(futex: &Atomic, expected: u32, timeout: Option) // Use FUTEX_WAIT_BITSET rather than FUTEX_WAIT to be able to give an // absolute time rather than a relative time. libc::syscall( - libc::SYS_futex, + SYS_futex, futex as *const Atomic as *const u32, libc::FUTEX_WAIT_BITSET | libc::FUTEX_PRIVATE_FLAG, expected, @@ -94,7 +106,7 @@ pub fn futex_wait(futex: &Atomic, expected: u32, timeout: Option) pub fn futex_wake(futex: &Atomic) -> bool { let ptr = futex as *const Atomic as *const u32; let op = libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG; - unsafe { libc::syscall(libc::SYS_futex, ptr, op, 1) > 0 } + unsafe { libc::syscall(SYS_futex, ptr, op, 1) > 0 } } /// Wakes up all threads that are waiting on `futex_wait` on this futex. @@ -103,7 +115,7 @@ pub fn futex_wake_all(futex: &Atomic) { let ptr = futex as *const Atomic as *const u32; let op = libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG; unsafe { - libc::syscall(libc::SYS_futex, ptr, op, i32::MAX); + libc::syscall(SYS_futex, ptr, op, i32::MAX); } }