mirror of
https://git.yoctoproject.org/poky
synced 2026-07-16 03:47:03 +00:00
cargo-c: Update patches to latest versions
getrandom patch is accepted upstream with minor changes parking_lot patch has addressed upstream feedback (From OE-Core rev: 9f0f41d8e3fe00df37d926d99fb490614b51dde7) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
+26
-43
@@ -1,53 +1,36 @@
|
|||||||
From 71c356a07fbbf1530cfc87960e975f93bc9007e8 Mon Sep 17 00:00:00 2001
|
From 71c356a07fbbf1530cfc87960e975f93bc9007e8 Mon Sep 17 00:00:00 2001
|
||||||
From: Khem Raj <raj.khem@gmail.com>
|
From: Khem Raj <raj.khem@gmail.com>
|
||||||
Date: Tue, 22 Jul 2025 09:46:03 -0700
|
Date: Tue, 22 Jul 2025 09:46:03 -0700
|
||||||
Subject: [PATCH] Use libc::SYS_futex_time64 on riscv32
|
Subject: [PATCH] Use getrandom syscall on riscv32/riscv64 linux
|
||||||
|
|
||||||
On RISC-V 32-bit (riscv32), the SYS_futex system call is
|
Minimum kernel needed on RISCV is fairly new (4.15+) so we are sure
|
||||||
often handled indirectly due to the use of a 64-bit time_t
|
to have getrandom syscall, on glibc there is mimimal ABI kernel to denote
|
||||||
type. Specifically, while SYS_futex is not directly defined,
|
it but musl does not have any other way to indicate it, so add it
|
||||||
a related syscall like SYS_futex_time64 can be used,
|
as a condition here to choose getrandom backend for rv32/rv64 on linux
|
||||||
|
when using musl.
|
||||||
|
|
||||||
Upstream-Status: Submitted [https://github.com/rust-random/getrandom/pull/698]
|
Upstream-Status: Backport [https://github.com/rust-random/getrandom/pull/699]
|
||||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||||
---
|
---
|
||||||
src/backends/use_file.rs | 17 +++++++++++++++++
|
src/backends/use_file.rs | 17 +++++++++++++++++
|
||||||
1 file changed, 17 insertions(+)
|
1 file changed, 17 insertions(+)
|
||||||
|
|
||||||
diff --git a/src/backends/use_file.rs b/src/backends/use_file.rs
|
--- a/src/backends.rs
|
||||||
index 7b48d43..baa0c66 100644
|
+++ b/src/backends.rs
|
||||||
--- a/src/backends/use_file.rs
|
@@ -93,7 +93,15 @@ cfg_if! {
|
||||||
+++ b/src/backends/use_file.rs
|
// Minimum supported Linux kernel version for MUSL targets
|
||||||
@@ -158,7 +158,18 @@ mod sync {
|
// is not specified explicitly (as of Rust 1.77) and they
|
||||||
pub(super) fn wait() {
|
// are used in practice to target pre-3.17 kernels.
|
||||||
let op = libc::FUTEX_WAIT | libc::FUTEX_PRIVATE_FLAG;
|
- target_env = "musl",
|
||||||
let timeout_ptr = core::ptr::null::<libc::timespec>();
|
+ all(
|
||||||
+ #[cfg(not(target_arch = "riscv32"))]
|
+ target_env = "musl",
|
||||||
let ret = unsafe { libc::syscall(libc::SYS_futex, &FD, op, FD_ONGOING_INIT, timeout_ptr) };
|
+ not(
|
||||||
+ #[cfg(target_arch = "riscv32")]
|
+ any(
|
||||||
+ let ret = unsafe {
|
+ target_arch = "riscv64",
|
||||||
+ libc::syscall(
|
+ target_arch = "riscv32",
|
||||||
+ libc::SYS_futex_time64,
|
+ ),
|
||||||
+ &FD,
|
+ ),
|
||||||
+ op,
|
+ ),
|
||||||
+ FD_ONGOING_INIT,
|
),
|
||||||
+ timeout_ptr,
|
)
|
||||||
+ )
|
))] {
|
||||||
+ };
|
|
||||||
// FUTEX_WAIT should return either 0 or EAGAIN error
|
|
||||||
debug_assert!({
|
|
||||||
match ret {
|
|
||||||
@@ -172,7 +183,13 @@ mod sync {
|
|
||||||
/// Wake up all threads which wait for value of atomic `FD` to change.
|
|
||||||
pub(super) fn wake() {
|
|
||||||
let op = libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG;
|
|
||||||
+
|
|
||||||
+ #[cfg(not(target_arch = "riscv32"))]
|
|
||||||
let ret = unsafe { libc::syscall(libc::SYS_futex, &FD, op, libc::INT_MAX) };
|
|
||||||
+
|
|
||||||
+ #[cfg(target_arch = "riscv32")]
|
|
||||||
+ let ret = unsafe { libc::syscall(libc::SYS_futex_time64, &FD, op, libc::INT_MAX) };
|
|
||||||
+
|
|
||||||
debug_assert!(ret >= 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
+25
-40
@@ -1,66 +1,51 @@
|
|||||||
From 78d4c37e9c5b60ea2368627c2fc297dfc46bec2a Mon Sep 17 00:00:00 2001
|
From 7ebddca7070742bbb9cce471a93d699ad70ee371 Mon Sep 17 00:00:00 2001
|
||||||
From: Khem Raj <raj.khem@gmail.com>
|
From: Khem Raj <raj.khem@gmail.com>
|
||||||
Date: Tue, 22 Jul 2025 10:15:06 -0700
|
Date: Tue, 22 Jul 2025 10:15:06 -0700
|
||||||
Subject: [PATCH] Use libc::SYS_futex_time64 on riscv32
|
Subject: [PATCH] Use libc::SYS_futex_time64 on riscv32/musl
|
||||||
|
|
||||||
On RISC-V 32-bit (riscv32), the SYS_futex system call is
|
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
|
often handled indirectly due to the use of a 64-bit time_t
|
||||||
type. Specifically, while SYS_futex is not directly defined,
|
type. Specifically, while SYS_futex is not directly defined,
|
||||||
a related syscall like SYS_futex_time64 can be used,
|
a related syscall like SYS_futex_time64 can be used on target
|
||||||
|
e.g. riscv32
|
||||||
|
|
||||||
Upstream-Status: Submitted [https://github.com/Amanieu/parking_lot/pull/485]
|
Upstream-Status: Submitted [https://github.com/Amanieu/parking_lot/pull/485]
|
||||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||||
---
|
---
|
||||||
src/thread_parker/linux.rs | 19 +++++++++++++++++++
|
src/thread_parker/linux.rs | 13 +++++++++++--
|
||||||
1 file changed, 19 insertions(+)
|
1 file changed, 11 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
diff --git a/src/thread_parker/linux.rs b/src/thread_parker/linux.rs
|
diff --git a/src/thread_parker/linux.rs b/src/thread_parker/linux.rs
|
||||||
index 92601f6..3695624 100644
|
index 92601f6..0952db4 100644
|
||||||
--- a/src/thread_parker/linux.rs
|
--- a/src/thread_parker/linux.rs
|
||||||
+++ b/src/thread_parker/linux.rs
|
+++ b/src/thread_parker/linux.rs
|
||||||
@@ -108,6 +108,7 @@ impl ThreadParker {
|
@@ -108,9 +108,13 @@ impl ThreadParker {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|ts_ref| ts_ref as *const _)
|
.map(|ts_ref| ts_ref as *const _)
|
||||||
.unwrap_or(ptr::null());
|
.unwrap_or(ptr::null());
|
||||||
+ #[cfg(not(target_arch = "riscv32"))]
|
+ #[cfg(not(all(target_arch = "riscv32", target_env = "musl")))]
|
||||||
|
+ let futex_num = libc::SYS_futex;
|
||||||
|
+ #[cfg(all(target_arch = "riscv32", target_env = "musl",))]
|
||||||
|
+ let futex_num = libc::SYS_futex_time64;
|
||||||
let r = unsafe {
|
let r = unsafe {
|
||||||
libc::syscall(
|
libc::syscall(
|
||||||
libc::SYS_futex,
|
- libc::SYS_futex,
|
||||||
@@ -117,6 +118,16 @@ impl ThreadParker {
|
+ futex_num,
|
||||||
ts_ptr,
|
&self.futex,
|
||||||
)
|
libc::FUTEX_WAIT | libc::FUTEX_PRIVATE_FLAG,
|
||||||
};
|
1,
|
||||||
+ #[cfg(target_arch = "riscv32")]
|
@@ -137,8 +141,13 @@ impl super::UnparkHandleT for UnparkHandle {
|
||||||
+ let r = unsafe {
|
|
||||||
+ libc::syscall(
|
|
||||||
+ libc::SYS_futex_time64,
|
|
||||||
+ &self.futex,
|
|
||||||
+ libc::FUTEX_WAIT | libc::FUTEX_PRIVATE_FLAG,
|
|
||||||
+ 1,
|
|
||||||
+ ts_ptr,
|
|
||||||
+ )
|
|
||||||
+ };
|
|
||||||
debug_assert!(r == 0 || r == -1);
|
|
||||||
if r == -1 {
|
|
||||||
debug_assert!(
|
|
||||||
@@ -137,12 +148,20 @@ impl super::UnparkHandleT for UnparkHandle {
|
|
||||||
unsafe fn unpark(self) {
|
unsafe fn unpark(self) {
|
||||||
// The thread data may have been freed at this point, but it doesn't
|
// The thread data may have been freed at this point, but it doesn't
|
||||||
// matter since the syscall will just return EFAULT in that case.
|
// matter since the syscall will just return EFAULT in that case.
|
||||||
+ #[cfg(not(target_arch = "riscv32"))]
|
+ #[cfg(not(all(target_arch = "riscv32", target_env = "musl",)))]
|
||||||
|
+ let futex_num = libc::SYS_futex;
|
||||||
|
+ #[cfg(all(target_arch = "riscv32", target_env = "musl",))]
|
||||||
|
+ let futex_num = libc::SYS_futex_time64;
|
||||||
|
+
|
||||||
let r = libc::syscall(
|
let r = libc::syscall(
|
||||||
libc::SYS_futex,
|
- libc::SYS_futex,
|
||||||
|
+ futex_num,
|
||||||
self.futex,
|
self.futex,
|
||||||
libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG,
|
libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG,
|
||||||
1,
|
1,
|
||||||
);
|
|
||||||
+ #[cfg(target_arch = "riscv32")]
|
|
||||||
+ let r = libc::syscall(
|
|
||||||
+ libc::SYS_futex_time64,
|
|
||||||
+ self.futex,
|
|
||||||
+ libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG,
|
|
||||||
+ 1,
|
|
||||||
+ );
|
|
||||||
debug_assert!(r == 0 || r == 1 || r == -1);
|
|
||||||
if r == -1 {
|
|
||||||
debug_assert_eq!(errno(), libc::EFAULT);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user