diff options
| -rw-r--r-- | meta-oe/recipes-devtools/cbindgen/cbindgen/0001-Use-libc-SYS_futex_time64-on-riscv32.patch | 53 | ||||
| -rw-r--r-- | meta-oe/recipes-devtools/cbindgen/cbindgen_0.29.2.bb | 2 |
2 files changed, 55 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/cbindgen/cbindgen/0001-Use-libc-SYS_futex_time64-on-riscv32.patch b/meta-oe/recipes-devtools/cbindgen/cbindgen/0001-Use-libc-SYS_futex_time64-on-riscv32.patch new file mode 100644 index 0000000000..4bb30a78cf --- /dev/null +++ b/meta-oe/recipes-devtools/cbindgen/cbindgen/0001-Use-libc-SYS_futex_time64-on-riscv32.patch | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | From a552c6891070bf400d4fe1f7c39c50b1a0b17748 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Tue, 22 Jul 2025 09:46:03 -0700 | ||
| 4 | Subject: [PATCH] Use libc::SYS_futex_time64 on riscv32 | ||
| 5 | |||
| 6 | On RISC-V 32-bit (riscv32), the SYS_futex system call is | ||
| 7 | often handled indirectly due to the use of a 64-bit time_t | ||
| 8 | type. Specifically, while SYS_futex is not directly defined, | ||
| 9 | a related syscall like SYS_futex_time64 can be used, | ||
| 10 | |||
| 11 | Upstream-Status: Backport [https://github.com/rust-random/getrandom/pull/698/commits/03d2c9f164099a714c3141c53221ccb68101c460] | ||
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 13 | --- | ||
| 14 | src/backends/use_file.rs | 17 +++++++++++++++++ | ||
| 15 | 1 file changed, 17 insertions(+) | ||
| 16 | |||
| 17 | diff --git a/src/backends/use_file.rs b/src/backends/use_file.rs | ||
| 18 | index 7b48d43..baa0c66 100644 | ||
| 19 | --- a/src/backends/use_file.rs | ||
| 20 | +++ b/src/backends/use_file.rs | ||
| 21 | @@ -158,7 +158,18 @@ mod sync { | ||
| 22 | pub(super) fn wait() { | ||
| 23 | let op = libc::FUTEX_WAIT | libc::FUTEX_PRIVATE_FLAG; | ||
| 24 | let timeout_ptr = core::ptr::null::<libc::timespec>(); | ||
| 25 | + #[cfg(not(target_arch = "riscv32"))] | ||
| 26 | let ret = unsafe { libc::syscall(libc::SYS_futex, &FD, op, FD_ONGOING_INIT, timeout_ptr) }; | ||
| 27 | + #[cfg(target_arch = "riscv32")] | ||
| 28 | + let ret = unsafe { | ||
| 29 | + libc::syscall( | ||
| 30 | + libc::SYS_futex_time64, | ||
| 31 | + &FD, | ||
| 32 | + op, | ||
| 33 | + FD_ONGOING_INIT, | ||
| 34 | + timeout_ptr, | ||
| 35 | + ) | ||
| 36 | + }; | ||
| 37 | // FUTEX_WAIT should return either 0 or EAGAIN error | ||
| 38 | debug_assert!({ | ||
| 39 | match ret { | ||
| 40 | @@ -172,7 +183,13 @@ mod sync { | ||
| 41 | /// Wake up all threads which wait for value of atomic `FD` to change. | ||
| 42 | pub(super) fn wake() { | ||
| 43 | let op = libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG; | ||
| 44 | + | ||
| 45 | + #[cfg(not(target_arch = "riscv32"))] | ||
| 46 | let ret = unsafe { libc::syscall(libc::SYS_futex, &FD, op, libc::INT_MAX) }; | ||
| 47 | + | ||
| 48 | + #[cfg(target_arch = "riscv32")] | ||
| 49 | + let ret = unsafe { libc::syscall(libc::SYS_futex_time64, &FD, op, libc::INT_MAX) }; | ||
| 50 | + | ||
| 51 | debug_assert!(ret >= 0); | ||
| 52 | } | ||
| 53 | |||
diff --git a/meta-oe/recipes-devtools/cbindgen/cbindgen_0.29.2.bb b/meta-oe/recipes-devtools/cbindgen/cbindgen_0.29.2.bb index 0ba5392d6c..6b5fac9d47 100644 --- a/meta-oe/recipes-devtools/cbindgen/cbindgen_0.29.2.bb +++ b/meta-oe/recipes-devtools/cbindgen/cbindgen_0.29.2.bb | |||
| @@ -5,6 +5,8 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=9741c346eef56131163e13b9db1241b3" | |||
| 5 | 5 | ||
| 6 | require cbindgen-crates.inc | 6 | require cbindgen-crates.inc |
| 7 | SRC_URI += "git://github.com/mozilla/cbindgen.git;protocol=https;branch=main;tag=v${PV}" | 7 | SRC_URI += "git://github.com/mozilla/cbindgen.git;protocol=https;branch=main;tag=v${PV}" |
| 8 | SRC_URI += "file://0001-Use-libc-SYS_futex_time64-on-riscv32.patch;patchdir=${UNPACKDIR}/cargo_home/bitbake/getrandom-0.3.3/" | ||
| 9 | |||
| 8 | SRCREV = "76f41c090c0587d940a0ef81a41c8b995f074926" | 10 | SRCREV = "76f41c090c0587d940a0ef81a41c8b995f074926" |
| 9 | 11 | ||
| 10 | inherit cargo pkgconfig | 12 | inherit cargo pkgconfig |
