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 aa9b59a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 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
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 aa9b59a

Please sign in to comment.