summaryrefslogtreecommitdiff
path: root/rust/pin-init/examples/pthread_mutex.rs
diff options
context:
space:
mode:
authorBenno Lossin <benno.lossin@proton.me>2025-05-23 14:54:11 +0200
committerBenno Lossin <lossin@kernel.org>2025-06-11 21:13:56 +0200
commit58cebd68882edd407c7f65ebb4a42034bc1ffc6d (patch)
tree45091b6a2622f9130b7aa0830d1c5dc3bf44be15 /rust/pin-init/examples/pthread_mutex.rs
parente832374ccadf4d1ce7bd40a85b9320bd7fbb3628 (diff)
rust: pin-init: examples, tests: add conditional compilation in order to compile under any feature combination
In the CI, all examples & tests should be run under all feature combinations. Currently several examples & tests use `std` without conditionally enabling it. Thus make them all compile under any feature combination by conditionally disabling the code that uses e.g. `std`. Link: https://github.com/Rust-for-Linux/pin-init/pull/50/commits/fdfb70efddbc711b4543c850ee38a2f5a8d17cb6 Link: https://lore.kernel.org/all/20250523125424.192843-2-lossin@kernel.org Signed-off-by: Benno Lossin <lossin@kernel.org>
Diffstat (limited to 'rust/pin-init/examples/pthread_mutex.rs')
-rw-r--r--rust/pin-init/examples/pthread_mutex.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/rust/pin-init/examples/pthread_mutex.rs b/rust/pin-init/examples/pthread_mutex.rs
index 5acc5108b954..c709dabba7eb 100644
--- a/rust/pin-init/examples/pthread_mutex.rs
+++ b/rust/pin-init/examples/pthread_mutex.rs
@@ -44,6 +44,7 @@ mod pthread_mtx {
pub enum Error {
#[allow(dead_code)]
IO(std::io::Error),
+ #[allow(dead_code)]
Alloc,
}
@@ -61,6 +62,7 @@ mod pthread_mtx {
}
impl<T> PThreadMutex<T> {
+ #[allow(dead_code)]
pub fn new(data: T) -> impl PinInit<Self, Error> {
fn init_raw() -> impl PinInit<UnsafeCell<libc::pthread_mutex_t>, Error> {
let init = |slot: *mut UnsafeCell<libc::pthread_mutex_t>| {
@@ -103,6 +105,7 @@ mod pthread_mtx {
}? Error)
}
+ #[allow(dead_code)]
pub fn lock(&self) -> PThreadMutexGuard<'_, T> {
// SAFETY: raw is always initialized
unsafe { libc::pthread_mutex_lock(self.raw.get()) };