Skip to content

Commit

Permalink
bolts limit ashmem concept to Linux/Android only. (AFLplusplus#2795)
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen authored and mzfr committed Jan 19, 2025
1 parent 6846f9d commit abd620c
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions libafl_bolts/src/shmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ pub mod unix_shmem {
}

/// Module containing `ashmem` shared memory support, commonly used on Android.
#[cfg(all(unix, feature = "std"))]
#[cfg(all(any(target_os = "linux", target_os = "android"), feature = "std"))]
pub mod ashmem {
use alloc::string::ToString;
use core::{
Expand All @@ -1154,7 +1154,6 @@ pub mod unix_shmem {
};

/// An ashmem based impl for linux/android
#[cfg(unix)]
#[derive(Clone, Debug)]
pub struct AshmemShMem {
id: ShMemId,
Expand Down Expand Up @@ -1273,7 +1272,6 @@ pub mod unix_shmem {
}
}

#[cfg(unix)]
impl ShMem for AshmemShMem {
fn id(&self) -> ShMemId {
self.id
Expand All @@ -1295,7 +1293,6 @@ pub mod unix_shmem {
}

/// [`Drop`] implementation for [`AshmemShMem`], which cleans up the mapping.
#[cfg(unix)]
impl Drop for AshmemShMem {
#[expect(trivial_numeric_casts)]
fn drop(&mut self) {
Expand All @@ -1318,21 +1315,18 @@ pub mod unix_shmem {
}

/// A [`ShMemProvider`] which uses ashmem to provide shared memory mappings.
#[cfg(unix)]
#[derive(Clone, Debug)]
pub struct AshmemShMemProvider {}

unsafe impl Send for AshmemShMemProvider {}

#[cfg(unix)]
impl Default for AshmemShMemProvider {
fn default() -> Self {
Self::new().unwrap()
}
}

/// Implement [`ShMemProvider`] for [`AshmemShMemProvider`], for the Android `ShMem`.
#[cfg(unix)]
impl ShMemProvider for AshmemShMemProvider {
type ShMem = AshmemShMem;

Expand Down

0 comments on commit abd620c

Please sign in to comment.