Skip to content

Commit

Permalink
Apple lies about page size on macOS, don't let them get away with it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Sep 10, 2023
1 parent f9ad8b5 commit f1acdf8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src-rust/src/utilities/cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,19 @@ impl Cached {
*max_address = 0x7FFFFFFFFFFF; // no max-address API, so restricted to Linux level
}

*allocation_granularity = MmapOptions::allocation_granularity() as i32;
*page_size = MmapOptions::page_size() as i32;
#[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]
{
*page_size = MmapOptions::page_size() as i32;
}

#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
{
// Apple lies about page size in libc on M1 says it's 4096 instead of 16384
*page_size = MmapOptions::page_size() as i32;
}

*allocation_granularity =
std::cmp::max(MmapOptions::allocation_granularity() as i32, *page_size);
}

pub fn get_allocation_granularity(&self) -> i32 {
Expand Down

0 comments on commit f1acdf8

Please sign in to comment.