-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
574 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
[package] | ||
name = "mimalloc-rs" | ||
version = "0.1.0" | ||
name = "mimalloc-rust" | ||
version = "0.1.1" | ||
edition = "2018" | ||
repository = "https://github.com/lemonhx/mimalloc-rust" | ||
description = "the best binding for mimalloc in rust" | ||
license = "MIT" | ||
|
||
[workspace] | ||
members = ["mimalloc-rust-sys"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[dev-dependencies] | ||
lazy_static = "1.4.0" | ||
|
||
[dependencies] | ||
mimalloc-sys = { path = "./mimalloc-sys" } | ||
mimalloc-rust-sys = "1.7.2" | ||
cty = "0.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# MIT License | ||
|
||
> Copyright (c) 2021 LemonHX | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
|
||
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE.** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
mimalloc 1.7.2 | ||
# The Best and Highest-Leveled and Newest bingding for MiMalloc Ever Existed in Rust | ||
> mimalloc 1.7.2 stable | ||
![ci](https://github.com/LemonHX/mimalloc-rust/actions/workflows/rust.yml/badge.svg) | ||
|
||
## Why create this | ||
|
||
in repo `https://github.com/purpleprotocol/mimalloc_rust` i didn't see any data types and it neither has all the functionalities which mimalloc has provided, in other words it's garbage. | ||
|
||
## Usage | ||
|
||
first add to dependencies | ||
```toml | ||
[dependencies] | ||
mimalloc-rust = "0.1" | ||
``` | ||
then set the global allocator | ||
```rust | ||
use mimalloc_rust::*; | ||
|
||
#[global_allocator] | ||
static GLOBAL_MIMALLOC: GlobalMiMalloc = GlobalMiMalloc; | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
use std::env; | ||
extern crate bindgen; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
let mut build = cc::Build::new(); | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 24 additions & 24 deletions
48
mimalloc-sys/src/aligned_allocation.rs → mimalloc-rust-sys/src/aligned_allocation.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
use cty::c_void; | ||
|
||
//Doc: https://microsoft.github.io/mimalloc/group__aligned.html | ||
|
||
extern "C" { | ||
pub fn mi_malloc_aligned(size: usize, alignment: usize) -> *mut c_void; | ||
pub fn mi_malloc_aligned_at(size: usize, alignment: usize, offset: usize) -> *mut c_void; | ||
pub fn mi_zalloc_aligned(size: usize, alignment: usize) -> *mut c_void; | ||
pub fn mi_zalloc_aligned_at(size: usize, alignment: usize, offset: usize) -> *mut c_void; | ||
pub fn mi_calloc_aligned(count: usize, size: usize, alignment: usize) -> *mut c_void; | ||
pub fn mi_calloc_aligned_at( | ||
count: usize, | ||
size: usize, | ||
alignment: usize, | ||
offset: usize, | ||
) -> *mut c_void; | ||
pub fn mi_realloc_aligned(p: *mut c_void, newsize: usize, alignment: usize) -> *mut c_void; | ||
pub fn mi_realloc_aligned_at( | ||
p: *mut c_void, | ||
newsize: usize, | ||
alignment: usize, | ||
offset: usize, | ||
) -> *mut c_void; | ||
} | ||
use cty::c_void; | ||
|
||
//Doc: https://microsoft.github.io/mimalloc/group__aligned.html | ||
|
||
extern "C" { | ||
pub fn mi_malloc_aligned(size: usize, alignment: usize) -> *mut c_void; | ||
pub fn mi_malloc_aligned_at(size: usize, alignment: usize, offset: usize) -> *mut c_void; | ||
pub fn mi_zalloc_aligned(size: usize, alignment: usize) -> *mut c_void; | ||
pub fn mi_zalloc_aligned_at(size: usize, alignment: usize, offset: usize) -> *mut c_void; | ||
pub fn mi_calloc_aligned(count: usize, size: usize, alignment: usize) -> *mut c_void; | ||
pub fn mi_calloc_aligned_at( | ||
count: usize, | ||
size: usize, | ||
alignment: usize, | ||
offset: usize, | ||
) -> *mut c_void; | ||
pub fn mi_realloc_aligned(p: *mut c_void, newsize: usize, alignment: usize) -> *mut c_void; | ||
pub fn mi_realloc_aligned_at( | ||
p: *mut c_void, | ||
newsize: usize, | ||
alignment: usize, | ||
offset: usize, | ||
) -> *mut c_void; | ||
} |
34 changes: 17 additions & 17 deletions
34
mimalloc-sys/src/basic_allocation.rs → mimalloc-rust-sys/src/basic_allocation.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
use cty::{c_char, c_void}; | ||
// Doc: https://microsoft.github.io/mimalloc/group__malloc.html | ||
extern "C" { | ||
pub fn mi_calloc(count: usize, size: usize) -> *mut c_void; | ||
pub fn mi_expand(p: *mut c_void, size: usize) -> *mut c_void; | ||
pub fn mi_free(p: *mut c_void); | ||
pub fn mi_malloc(size: usize) -> *mut c_void; | ||
pub fn mi_mallocn(count: usize, size: usize) -> *mut c_void; | ||
pub fn mi_realloc(p: *mut c_void, newsize: usize) -> *mut c_void; | ||
pub fn mi_reallocf(p: *mut c_void, newsize: usize) -> *mut c_void; | ||
pub fn mi_reallocn(p: *mut c_void, count: usize, size: usize) -> *mut c_void; | ||
pub fn mi_realpath(fname: *const c_char, resolved_name: *mut c_char) -> *mut c_char; | ||
pub fn mi_recalloc(p: *mut c_void, newcount: usize, size: usize) -> *mut c_void; | ||
pub fn mi_strdup(s: *const c_char) -> *mut c_char; | ||
pub fn mi_strndup(s: *const c_char, n: usize) -> *mut c_char; | ||
pub fn mi_zalloc(size: usize) -> *mut c_void; | ||
} | ||
use cty::{c_char, c_void}; | ||
// Doc: https://microsoft.github.io/mimalloc/group__malloc.html | ||
extern "C" { | ||
pub fn mi_calloc(count: usize, size: usize) -> *mut c_void; | ||
pub fn mi_expand(p: *mut c_void, size: usize) -> *mut c_void; | ||
pub fn mi_free(p: *mut c_void); | ||
pub fn mi_malloc(size: usize) -> *mut c_void; | ||
pub fn mi_mallocn(count: usize, size: usize) -> *mut c_void; | ||
pub fn mi_realloc(p: *mut c_void, newsize: usize) -> *mut c_void; | ||
pub fn mi_reallocf(p: *mut c_void, newsize: usize) -> *mut c_void; | ||
pub fn mi_reallocn(p: *mut c_void, count: usize, size: usize) -> *mut c_void; | ||
pub fn mi_realpath(fname: *const c_char, resolved_name: *mut c_char) -> *mut c_char; | ||
pub fn mi_recalloc(p: *mut c_void, newcount: usize, size: usize) -> *mut c_void; | ||
pub fn mi_strdup(s: *const c_char) -> *mut c_char; | ||
pub fn mi_strndup(s: *const c_char, n: usize) -> *mut c_char; | ||
pub fn mi_zalloc(size: usize) -> *mut c_void; | ||
} |
90 changes: 45 additions & 45 deletions
90
mimalloc-sys/src/extended_functions.rs → mimalloc-rust-sys/src/extended_functions.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
use cty::{c_char, c_int, c_ulonglong, c_void}; | ||
// Doc: https://microsoft.github.io/mimalloc/group__malloc.html | ||
pub const MI_SMALL_SIZE_MAX: usize = 128 * core::mem::size_of::<*mut c_void>(); | ||
pub type mi_deferred_free_fun = | ||
Option<unsafe extern "C" fn(force: bool, heartbeat: c_ulonglong, arg: *mut c_void)>; | ||
pub type mi_output_fun = Option<unsafe extern "C" fn(msg: *const c_char, arg: *mut c_void)>; | ||
pub type mi_error_fun = Option<unsafe extern "C" fn(code: c_int, arg: *mut c_void)>; | ||
extern "C" { | ||
pub fn mi_collect(force: bool); | ||
pub fn mi_good_size(size: usize) -> usize; | ||
pub fn mi_is_in_heap_region(p: *const c_void) -> bool; | ||
pub fn mi_malloc_small(size: usize) -> *mut c_void; | ||
pub fn mi_process_info( | ||
elapsed_msecs: *mut usize, | ||
user_msecs: *mut usize, | ||
system_msecs: *mut usize, | ||
current_rss: *mut usize, | ||
peak_rss: *mut usize, | ||
current_commit: *mut usize, | ||
peak_commit: *mut usize, | ||
page_faults: *mut usize, | ||
); | ||
pub fn mi_register_deferred_free(out: mi_deferred_free_fun, arg: *mut c_void); | ||
pub fn mi_register_error(out: mi_error_fun, arg: *mut c_void); | ||
pub fn mi_register_output(out: mi_output_fun, arg: *mut c_void); | ||
pub fn mi_reserve_huge_os_pages_at( | ||
pages: usize, | ||
numa_node: c_int, | ||
timeout_msecs: usize, | ||
) -> c_int; | ||
pub fn mi_reserve_huge_os_pages_interleave( | ||
pages: usize, | ||
numa_node: c_int, | ||
timeout_msecs: usize, | ||
) -> c_int; | ||
pub fn mi_stats_print(_: *mut c_void); | ||
pub fn mi_stats_print_out(out: mi_output_fun, arg: *mut c_void); | ||
pub fn mi_stats_reset(); | ||
pub fn mi_stats_merge(); | ||
pub fn mi_thread_init(); | ||
pub fn mi_thread_done(); | ||
pub fn mi_thread_stats_print_out(out: mi_output_fun, arg: *mut c_void); | ||
pub fn mi_usable_size(p: *const c_void) -> usize; | ||
pub fn mi_zalloc_small(size: usize) -> *mut c_void; | ||
} | ||
use cty::{c_char, c_int, c_ulonglong, c_void}; | ||
// Doc: https://microsoft.github.io/mimalloc/group__malloc.html | ||
pub const MI_SMALL_SIZE_MAX: usize = 128 * core::mem::size_of::<*mut c_void>(); | ||
pub type mi_deferred_free_fun = | ||
Option<unsafe extern "C" fn(force: bool, heartbeat: c_ulonglong, arg: *mut c_void)>; | ||
pub type mi_output_fun = Option<unsafe extern "C" fn(msg: *const c_char, arg: *mut c_void)>; | ||
pub type mi_error_fun = Option<unsafe extern "C" fn(code: c_int, arg: *mut c_void)>; | ||
extern "C" { | ||
pub fn mi_collect(force: bool); | ||
pub fn mi_good_size(size: usize) -> usize; | ||
pub fn mi_is_in_heap_region(p: *const c_void) -> bool; | ||
pub fn mi_malloc_small(size: usize) -> *mut c_void; | ||
pub fn mi_process_info( | ||
elapsed_msecs: *mut usize, | ||
user_msecs: *mut usize, | ||
system_msecs: *mut usize, | ||
current_rss: *mut usize, | ||
peak_rss: *mut usize, | ||
current_commit: *mut usize, | ||
peak_commit: *mut usize, | ||
page_faults: *mut usize, | ||
); | ||
pub fn mi_register_deferred_free(out: mi_deferred_free_fun, arg: *mut c_void); | ||
pub fn mi_register_error(out: mi_error_fun, arg: *mut c_void); | ||
pub fn mi_register_output(out: mi_output_fun, arg: *mut c_void); | ||
pub fn mi_reserve_huge_os_pages_at( | ||
pages: usize, | ||
numa_node: c_int, | ||
timeout_msecs: usize, | ||
) -> c_int; | ||
pub fn mi_reserve_huge_os_pages_interleave( | ||
pages: usize, | ||
numa_node: c_int, | ||
timeout_msecs: usize, | ||
) -> c_int; | ||
pub fn mi_stats_print(_: *mut c_void); | ||
pub fn mi_stats_print_out(out: mi_output_fun, arg: *mut c_void); | ||
pub fn mi_stats_reset(); | ||
pub fn mi_stats_merge(); | ||
pub fn mi_thread_init(); | ||
pub fn mi_thread_done(); | ||
pub fn mi_thread_stats_print_out(out: mi_output_fun, arg: *mut c_void); | ||
pub fn mi_usable_size(p: *const c_void) -> usize; | ||
pub fn mi_zalloc_small(size: usize) -> *mut c_void; | ||
} |
Oops, something went wrong.