summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAlice Ryhl <aliceryhl@google.com>2023-05-17 22:08:13 +0200
committerMiguel Ojeda <ojeda@kernel.org>2023-05-31 18:53:10 +0200
commitbd780aea671eda9660837c05d9ba58de22ceecad (patch)
tree19532e18be30bf6eb4cde2866e17d911b7f4868b /kernel
parentrust: error: add missing error codes (diff)
downloadlinux-bd780aea671eda9660837c05d9ba58de22ceecad.tar.xz
linux-bd780aea671eda9660837c05d9ba58de22ceecad.zip
rust: sync: add `Arc::ptr_eq`
Add a method for comparing whether two `Arc` pointers reference the same underlying object. This comparison can already be done by getting a reference to the inner values and comparing whether the references have the same address. However, writing `Arc::ptr_eq(a, b)` is generally less error-prone than doing the same check on the references, since you might otherwise accidentally compare the two `&Arc<T>` references instead, which wont work because those are pointers to pointers to the inner value, when you just want to compare the pointers to the inner value. Also, this method might optimize better because getting a reference to the inner value involves offsetting the pointer, which this method does not need to do. Co-developed-by: Wedson Almeida Filho <walmeida@microsoft.com> Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Link: https://lore.kernel.org/r/20230517200814.3157916-1-aliceryhl@google.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'kernel')
0 files changed, 0 insertions, 0 deletions