diff --git a/changelog/2505.fixed.md b/changelog/2505.fixed.md new file mode 100644 index 0000000000..2dc6f19169 --- /dev/null +++ b/changelog/2505.fixed.md @@ -0,0 +1 @@ +The `ns` argument of `sys::prctl::set_timerslack()` should be of type `c_ulong` diff --git a/src/sys/prctl.rs b/src/sys/prctl.rs index 35b1ce170f..d183e105ef 100644 --- a/src/sys/prctl.rs +++ b/src/sys/prctl.rs @@ -166,7 +166,7 @@ pub fn get_name() -> Result { /// Sets the timer slack value for the calling thread. Timer slack is used by the kernel to group /// timer expirations and make them the supplied amount of nanoseconds late. -pub fn set_timerslack(ns: u64) -> Result<()> { +pub fn set_timerslack(ns: c_ulong) -> Result<()> { let res = unsafe { libc::prctl(libc::PR_SET_TIMERSLACK, ns, 0, 0, 0) }; Errno::result(res).map(drop) diff --git a/test/sys/test_prctl.rs b/test/sys/test_prctl.rs index b409735af6..85327034d2 100644 --- a/test/sys/test_prctl.rs +++ b/test/sys/test_prctl.rs @@ -89,14 +89,14 @@ mod test_prctl { #[cfg_attr(qemu, ignore)] #[test] fn test_get_set_timerslack() { - let original = prctl::get_timerslack().unwrap(); + let original = prctl::get_timerslack().unwrap() as libc::c_ulong; let slack = 60_000; prctl::set_timerslack(slack).unwrap(); - let res = prctl::get_timerslack().unwrap(); - assert_eq!(slack, res as u64); + let res = prctl::get_timerslack().unwrap() as libc::c_ulong; + assert_eq!(slack, res); - prctl::set_timerslack(original as u64).unwrap(); + prctl::set_timerslack(original).unwrap(); } #[test]