#[cfg(feature = "malloc_jemalloc")]
pub use self::jemalloc::*;
#[cfg(not(any(feature = "malloc_jemalloc", feature = "malloc_mimalloc",)))]
pub use self::libc_malloc::*;
#[cfg(feature = "malloc_mimalloc")]
pub use self::mimalloc::*;
pub const BYTES_IN_MALLOC_PAGE: usize = 1 << LOG_BYTES_IN_MALLOC_PAGE;
#[cfg(feature = "malloc_jemalloc")]
mod jemalloc {
pub const LOG_BYTES_IN_MALLOC_PAGE: u8 = crate::util::constants::LOG_BYTES_IN_PAGE;
pub use jemalloc_sys::{calloc, free, malloc, realloc};
pub use jemalloc_sys::posix_memalign;
pub use jemalloc_sys::malloc_usable_size;
}
#[cfg(feature = "malloc_mimalloc")]
mod mimalloc {
pub const LOG_BYTES_IN_MALLOC_PAGE: u8 = crate::util::constants::LOG_BYTES_IN_PAGE;
pub use mimalloc_sys::{
mi_calloc as calloc, mi_free as free, mi_malloc as malloc, mi_realloc as realloc,
};
pub use mimalloc_sys::mi_posix_memalign as posix_memalign;
pub use mimalloc_sys::mi_malloc_usable_size as malloc_usable_size;
}
#[cfg(not(any(feature = "malloc_jemalloc", feature = "malloc_mimalloc",)))]
mod libc_malloc {
pub const LOG_BYTES_IN_MALLOC_PAGE: u8 = crate::util::constants::LOG_BYTES_IN_PAGE;
pub use libc::{calloc, free, malloc, realloc};
pub use libc::posix_memalign;
#[cfg(target_os = "linux")]
pub use libc::malloc_usable_size;
#[cfg(target_os = "macos")]
extern "C" {
pub fn malloc_size(ptr: *const libc::c_void) -> usize;
}
#[cfg(target_os = "macos")]
pub use self::malloc_size as malloc_usable_size;
}