Skip to content

Commit 38c37ca

Browse files
committed
Updated code to support mimalloc v2.
Basic stuff used from this PR purpleprotocol#66
1 parent 697f23f commit 38c37ca

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

.gitmodules

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
[submodule "libmimalloc-sys/c_src/mimalloc"]
22
path = libmimalloc-sys/c_src/mimalloc
33
url = https://github.com/microsoft/mimalloc
4+
[submodule "libmimalloc-sys/c_src/mimalloc_dev_slice"]
5+
path = libmimalloc-sys/c_src/mimalloc_dev_slice
6+
url = https://github.com/microsoft/mimalloc.git
7+
branch = dev-slice
8+
[submodule "libmimalloc-sys/c_src/mimalloc_dev"]
9+
path = libmimalloc-sys/c_src/mimalloc_dev
10+
url = https://github.com/microsoft/mimalloc.git
11+
branch = dev

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ travis-ci = { repository = "purpleprotocol/mimalloc_rust" }
2424
libmimalloc-sys = { path = "libmimalloc-sys", version = "0.1.23", default-features = false }
2525

2626
[features]
27-
default = ["secure"]
27+
default = ["secure","v1_stable"]
2828
secure = ["libmimalloc-sys/secure"]
2929
override = ["libmimalloc-sys/override"]
3030
debug = ["libmimalloc-sys/debug"]
3131
local_dynamic_tls = ["libmimalloc-sys/local_dynamic_tls"]
32+
v1_stable = ["libmimalloc-sys/v1_stable"]
33+
v1_dev = ["libmimalloc-sys/v1_dev"]
34+
v2_dev = ["libmimalloc-sys/v2_dev"]

libmimalloc-sys/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ debug = []
2222
override = []
2323
extended = ["cty"]
2424
local_dynamic_tls = []
25+
v1_stable = []
26+
v1_dev = []
27+
v2_dev = []
2528

2629
# Show `extended` on docs.rs since it's the full API surface.
2730
[package.metadata.docs.rs]

libmimalloc-sys/build.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@ use std::env;
33
fn main() {
44
let mut build = cc::Build::new();
55

6-
build.include("c_src/mimalloc/include");
7-
build.include("c_src/mimalloc/src");
8-
build.file("c_src/mimalloc/src/static.c");
6+
if cfg!(feature = "v1_dev") {
7+
build.include("c_src/mimalloc_dev/include");
8+
build.include("c_src/mimalloc_dev/src");
9+
build.file("c_src/mimalloc_dev/src/static.c");
10+
} else if cfg!(feature = "v2_dev") {
11+
build.include("c_src/mimalloc_dev_slice/include");
12+
build.include("c_src/mimalloc_dev_slice/src");
13+
build.file("c_src/mimalloc_dev_slice/src/static.c");
14+
} else {
15+
build.include("c_src/mimalloc/include");
16+
build.include("c_src/mimalloc/src");
17+
build.file("c_src/mimalloc/src/static.c");
18+
}
919

1020
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("target_os not defined!");
1121
let target_family = env::var("CARGO_CFG_TARGET_FAMILY").expect("target_family not defined!");

libmimalloc-sys/c_src/mimalloc_dev

Submodule mimalloc_dev added at 36edfbc
Submodule mimalloc_dev_slice added at 775c10d

0 commit comments

Comments
 (0)