diff --git a/src-rust/Cargo.toml b/src-rust/Cargo.toml index 27c05bd..e38a1b6 100644 --- a/src-rust/Cargo.toml +++ b/src-rust/Cargo.toml @@ -19,7 +19,7 @@ no_format = [] # Removes string formatting (less detailed errors) for binary siz all_private = [] # No memory mapped files, memory is not shared. size_opt = ["nightly"] nightly = [] # Optimizations for nightly builds. -mmap-rs = [] # Uses mmap-rs for memory mapping. This is auto activated during build. +direct-mmap = [] # If set, uses built-in code for memory mapping. This is auto activated in build.rs for supported platforms. [dependencies] concat-string = "1.0.1" diff --git a/src-rust/build.rs b/src-rust/build.rs index 09908c0..a5dbfa4 100644 --- a/src-rust/build.rs +++ b/src-rust/build.rs @@ -1,11 +1,11 @@ fn main() { // This defines a fallback to mmap-rs if one of the explicit memory mapped file implementations // is not available. - if !cfg!(any( + if cfg!(any( target_os = "macos", target_os = "windows", target_os = "linux" )) { - println!("cargo:rustc-cfg=feature=\"mmap-rs\""); + println!("cargo:rustc-cfg=feature=\"direct-mmap\""); } } diff --git a/src-rust/src/internal/buffer_allocator.rs b/src-rust/src/internal/buffer_allocator.rs index 4c34a04..802bca2 100644 --- a/src-rust/src/internal/buffer_allocator.rs +++ b/src-rust/src/internal/buffer_allocator.rs @@ -22,7 +22,7 @@ pub fn allocate( return crate::internal::buffer_allocator_osx::allocate_osx(settings); // Fallback for non-hot-path OSes. - #[cfg(feature = "mmap-rs")] + #[cfg(not(feature = "direct-mmap"))] crate::internal::buffer_allocator_mmap_rs::allocate_mmap_rs(settings) } diff --git a/src-rust/src/lib.rs b/src-rust/src/lib.rs index dbb844f..ab79807 100644 --- a/src-rust/src/lib.rs +++ b/src-rust/src/lib.rs @@ -133,7 +133,7 @@ pub(crate) mod utilities { pub mod cached; pub mod icache_clear; - #[cfg(any(target_os = "linux", feature = "mmap-rs"))] + #[cfg(any(target_os = "linux", not(feature = "direct-mmap")))] pub mod map_parser_utilities; pub mod mathematics; diff --git a/src-rust/src/structs/private_allocation.rs b/src-rust/src/structs/private_allocation.rs index 26fcb5a..9ccd8d1 100644 --- a/src-rust/src/structs/private_allocation.rs +++ b/src-rust/src/structs/private_allocation.rs @@ -168,7 +168,7 @@ impl PrivateAllocation { } /// Frees the allocated memory when the `PrivateAllocation` instance is dropped. - #[cfg(feature = "mmap-rs")] + #[cfg(not(feature = "direct-mmap"))] pub(crate) fn drop_mmap_rs(&mut self) { use mmap_rs_with_map_from_existing::MmapOptions; let _map = unsafe { @@ -196,7 +196,7 @@ impl Drop for PrivateAllocation { return PrivateAllocation::drop_macos(self); // non-hot-path-os - #[cfg(feature = "mmap-rs")] + #[cfg(not(feature = "direct-mmap"))] return PrivateAllocation::drop_mmap_rs(self); } }