about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIan Douglas Scott <ian@iandouglasscott.com>2024-05-04 11:11:46 -0700
committerIan Douglas Scott <ian@iandouglasscott.com>2024-05-04 11:27:21 -0700
commit7dc27d596b36d81d1aff4d917cfef0771acef0b9 (patch)
tree5195a338aaefe669900cdb2cbe1a24805e7ee487
parentd7ea27808deb5e10a0f7384e339e4e6165e33398 (diff)
downloadrust-7dc27d596b36d81d1aff4d917cfef0771acef0b9.tar.gz
rust-7dc27d596b36d81d1aff4d917cfef0771acef0b9.zip
library/std: Fix build for NetBSD targets with 32-bit `c_long`
This fixes building `std` for targets like `mipsel-unknown-netbsd`.

If `c_long` is an `i64`, this conversion works with `Into`. But if it's
an `i32`, this failed to convert a `u32` to an `i32`.
-rw-r--r--library/std/src/sys/pal/unix/thread_parking.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/sys/pal/unix/thread_parking.rs b/library/std/src/sys/pal/unix/thread_parking.rs
index 66ffc006057..1366410b71e 100644
--- a/library/std/src/sys/pal/unix/thread_parking.rs
+++ b/library/std/src/sys/pal/unix/thread_parking.rs
@@ -5,7 +5,7 @@
 use crate::ffi::{c_int, c_void};
 use crate::ptr;
 use crate::time::Duration;
-use libc::{_lwp_self, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC};
+use libc::{_lwp_self, c_long, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC};
 
 extern "C" {
     fn ___lwp_park60(
@@ -38,7 +38,7 @@ pub fn park_timeout(dur: Duration, hint: usize) {
         // Saturate so that the operation will definitely time out
         // (even if it is after the heat death of the universe).
         tv_sec: dur.as_secs().try_into().ok().unwrap_or(time_t::MAX),
-        tv_nsec: dur.subsec_nanos().into(),
+        tv_nsec: dur.subsec_nanos() as c_long,
     };
 
     // Timeout needs to be mutable since it is modified on NetBSD 9.0 and