Skip to content

Commit

Permalink
Code: Change mmap-rs flag to direct-mmap which disables it instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Jun 24, 2024
1 parent ccf1000 commit 97fb34c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src-rust/build.rs
Original file line number Diff line number Diff line change
@@ -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\"");
}
}
2 changes: 1 addition & 1 deletion src-rust/src/internal/buffer_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion src-rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src-rust/src/structs/private_allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 97fb34c

Please sign in to comment.