Re: [PATCH v3 4/4] rust: sync: update integer types in CondVar

From: Boqun Feng
Date: Thu Jan 04 2024 - 17:48:24 EST


On Thu, Jan 04, 2024 at 02:02:44PM +0000, Alice Ryhl wrote:
[...]
> -use core::ffi::c_long;
> +use core::ffi::{c_int, c_long, c_uint};

core::ffi::c_uint is not needed here. And

use core::ptr;

is missing (for the `ptr::mut_null()` below)

> use core::marker::PhantomPinned;
> use macros::pin_data;
>
[...]
> @@ -174,23 +179,16 @@ pub fn wait_interruptible_timeout<T: ?Sized, B: Backend>(
> }
> }
>
> - /// Calls the kernel function to notify the appropriate number of threads with the given flags.
> - fn notify(&self, count: i32, flags: u32) {
> + /// Calls the kernel function to notify the appropriate number of threads.
> + fn notify(&self, count: c_int) {
> // SAFETY: `wait_list` points to valid memory.
> - unsafe {
> - bindings::__wake_up(
> - self.wait_list.get(),
> - bindings::TASK_NORMAL,
> - count,
> - flags as _,
> - )
> - };
> + unsafe { bindings::__wake_up(self.wait_list.get(), TASK_NORMAL, count, ptr::null_mut()) };
> }
>
[...]
> diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs
> index ffb4a51eb898..37468613ac0d 100644
> --- a/rust/kernel/task.rs
> +++ b/rust/kernel/task.rs
> @@ -10,6 +10,14 @@

Missing:

use core::ffi::{c_long, c_int, c_uint};

here.

Regards,
Boqun

> /// A sentinal value used for infinite timeouts.
> pub const MAX_SCHEDULE_TIMEOUT: c_long = c_long::MAX;
>
> +/// Bitmask for tasks that are sleeping in an interruptible state.
> +pub const TASK_INTERRUPTIBLE: c_int = bindings::TASK_INTERRUPTIBLE as c_int;
> +/// Bitmask for tasks that are sleeping in an uninterruptible state.
> +pub const TASK_UNINTERRUPTIBLE: c_int = bindings::TASK_UNINTERRUPTIBLE as c_int;
> +/// Convenience constant for waking up tasks regardless of whether they are in interruptible or
> +/// uninterruptible sleep.
> +pub const TASK_NORMAL: c_uint = bindings::TASK_NORMAL as c_uint;
> +
> /// Returns the currently running task.
> #[macro_export]
> macro_rules! current {
>
> --
> 2.43.0.472.g3155946c3a-goog
>