Skip to content

Commit 333dc6e

Browse files
andreeaflorescujiangliu
authored andcommitted
mark is_hugetlbfs as Linux only
On Windows this function would always return None. There is no need to make it OS-agnostic since it is only available on Linux. Signed-off-by: Andreea Florescu <[email protected]>
1 parent 4e6ce9c commit 333dc6e

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

src/guest_memory.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ pub trait GuestMemoryRegion: Bytes<MemoryRegionAddress, E = Error> {
306306
/// assert_eq!(r.is_hugetlbfs(), None);
307307
/// # }
308308
/// ```
309+
#[cfg(target_os = "linux")]
309310
fn is_hugetlbfs(&self) -> Option<bool> {
310311
None
311312
}
@@ -1221,6 +1222,7 @@ mod tests {
12211222
}
12221223

12231224
#[cfg(feature = "backend-mmap")]
1225+
#[cfg(target_os = "linux")]
12241226
#[test]
12251227
fn test_guest_memory_mmap_is_hugetlbfs() {
12261228
let addr = GuestAddress(0x1000);

src/mmap.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ impl GuestMemoryRegion for GuestRegionMmap {
457457
Ok(slice)
458458
}
459459

460+
#[cfg(target_os = "linux")]
460461
fn is_hugetlbfs(&self) -> Option<bool> {
461462
self.mapping.is_hugetlbfs()
462463
}

src/mmap_windows.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ impl MmapRegion {
175175
pub fn file_offset(&self) -> Option<&FileOffset> {
176176
self.file_offset.as_ref()
177177
}
178-
179-
/// This information is not available on Windows platforms.
180-
pub fn is_hugetlbfs(&self) -> Option<bool> {
181-
None
182-
}
183178
}
184179

185180
impl AsSlice for MmapRegion {

0 commit comments

Comments
 (0)