aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Larsen <perlarsen@google.com>2024-04-02 01:26:31 +0000
committerPer Larsen <perlarsen@google.com>2024-04-02 01:55:48 +0000
commitc40c0e386f568b367b3159c2489c3d1cf7d9036e (patch)
tree1d26f766cffde76aecf39ba11b637a805d67d1d3
parent1ec3401a7d40d62b215d99172b1d07fae0f35f58 (diff)
downloadcommon-c40c0e386f568b367b3159c2489c3d1cf7d9036e.tar.gz
lib: rust_support: remove incorrect try_lock function and uses
It appears that try_lock is only used to support formatting of the Trusty mutex wrapper so we remove formatting for now since it is faster than fixing the implementation and adding tests for it. Test: build.py generic-x86_64-test Bug: 298705967 Change-Id: Ia0f1ab7269080f8ae9543875942067ff3c375950
-rw-r--r--lib/rust_support/rules.mk1
-rw-r--r--lib/rust_support/sync.rs31
2 files changed, 0 insertions, 32 deletions
diff --git a/lib/rust_support/rules.mk b/lib/rust_support/rules.mk
index 3840b782..fdf652ee 100644
--- a/lib/rust_support/rules.mk
+++ b/lib/rust_support/rules.mk
@@ -36,7 +36,6 @@ MODULE_DEPS := \
MODULE_BINDGEN_ALLOW_FUNCTIONS := \
_panic \
- extern_is_mutex_held \
mutex_acquire_timeout \
mutex_destroy \
mutex_init \
diff --git a/lib/rust_support/sync.rs b/lib/rust_support/sync.rs
index eac9eaa2..0bfc3fe1 100644
--- a/lib/rust_support/sync.rs
+++ b/lib/rust_support/sync.rs
@@ -22,9 +22,6 @@
*/
use core::cell::UnsafeCell;
-use core::fmt;
-use core::fmt::Debug;
-use core::fmt::Formatter;
use core::mem;
use core::ops::Deref;
use core::ops::DerefMut;
@@ -32,7 +29,6 @@ use core::ops::DerefMut;
use alloc::boxed::Box;
use crate::err::NO_ERROR;
-use crate::sys::extern_is_mutex_held;
use crate::sys::mutex_acquire_timeout;
use crate::sys::mutex_destroy;
use crate::sys::mutex_init;
@@ -146,16 +142,6 @@ impl<T: ?Sized> Mutex<T> {
assert_eq!(status, NO_ERROR);
MutexGuard { lock: &self }
}
-
- pub fn try_lock(&self) -> Option<MutexGuard<'_, T>> {
- // SAFETY: `extern_is_mutex_held` is thread safe and it was `mutex_init`ialized.
- let locked = unsafe { extern_is_mutex_held(self.mutex.get_raw()) };
- if locked {
- None
- } else {
- Some(self.lock())
- }
- }
}
impl<T: ?Sized> Drop for MutexGuard<'_, T> {
@@ -197,20 +183,3 @@ impl<T> From<T> for Mutex<T> {
Self::new(value)
}
}
-
-/// Copied from [`std::sync::Mutex`],
-/// with minor changes as [`Mutex`] has no poisoning.
-impl<T: ?Sized + Debug> Debug for Mutex<T> {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- let mut d = f.debug_struct("Mutex");
- match self.try_lock() {
- Some(guard) => {
- d.field("data", &&*guard);
- }
- None => {
- d.field("data", &format_args!("<locked>"));
- }
- }
- d.finish_non_exhaustive()
- }
-}