mmap_allocator/
lib.rs

1// Copyright 2020,2021 Shin Yoshida
2//
3// This is part of rust-mmap-allocator
4//
5// "LGPL-3.0-or-later OR Apache-2.0"
6//
7//  rust-mmap-allocator is free software: you can redistribute it and/or modify
8//  it under the terms of the GNU General Public License as published by
9//  the Free Software Foundation, either version 3 of the License, or
10//  (at your option) any later version.
11//
12//  rust-mmap-allocator is distributed in the hope that it will be useful,
13//  but WITHOUT ANY WARRANTY; without even the implied warranty of
14//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15//  GNU General Public License for more details.
16//
17//  You should have received a copy of the GNU General Public License
18//  along with rust-mmap-allocator.  If not, see <http://www.gnu.org/licenses/>.
19//
20// Licensed under the Apache License, Version 2.0 (the "License");
21// you may not use this file except in compliance with the License.
22// You may obtain a copy of the License at
23//
24//     http://www.apache.org/licenses/LICENSE-2.0
25//
26// Unless required by applicable law or agreed to in writing, software
27// distributed under the License is distributed on an "AS IS" BASIS,
28// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29// See the License for the specific language governing permissions and
30// limitations under the License.
31
32//! `mmap-allocator` declares struct `MmapAllocator` and function 'page\_size' for 'unix' or 'linux' platform.
33//!
34//! `MmapAllocator` implements `std::alloc::GlobalAlloc` whose backend is 'posix mmap'.
35//!
36//! 'page\_size' returns OS page size.
37//! ('unix' and 'linux' os pass memory to a process by multipile of page size; if a process
38//! requires 32 bytes heap memory and if the OS page size is 4096 bytes, OS passes 4096 bytes
39//! memory chunk. Usually 'malloc' deals it to use memory effectively.)
40
41#[cfg(unix)]
42mod mmap_allocator;
43
44#[cfg(unix)]
45pub use crate::mmap_allocator::{page_size, MmapAllocator};