]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rust: task: implement == operator for Task
authorAlice Ryhl <aliceryhl@google.com>
Tue, 24 Mar 2026 20:02:36 +0000 (20:02 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Apr 2026 10:18:21 +0000 (12:18 +0200)
It's useful to compare if two tasks are the same task or not. Rust
Binder wants this to check if a certain task is equal to the group
leader of current.

Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260324-close-fd-check-current-v3-2-b94274bedac7@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
rust/kernel/task.rs

index cc907fb531bceea6e8dc1175d9350bd24780a3d5..deb948d99921cb1174c86428e32bf4b258202a5d 100644 (file)
@@ -362,6 +362,15 @@ unsafe impl crate::sync::aref::AlwaysRefCounted for Task {
     }
 }
 
+impl PartialEq for Task {
+    #[inline]
+    fn eq(&self, other: &Self) -> bool {
+        ptr::eq(self.as_ptr(), other.as_ptr())
+    }
+}
+
+impl Eq for Task {}
+
 impl Kuid {
     /// Get the current euid.
     #[inline]