Skip to content

Commit de8f917

Browse files
Merge pull request #138 from ryancinsight/master
addition of windows 7 and 8 compatibility, small changes
2 parents 157ef80 + 8a59e64 commit de8f917

File tree

5 files changed

+49
-14
lines changed

5 files changed

+49
-14
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Changelog
22

3+
### 0.2.27
4+
5+
- Reduction of libc dependency
6+
- **upstream** Windows 7 and windows 8 compatibility added
7+
- **upstream** Option to use C++20 standards if available
8+
39
### 0.2.26
410

511
- **upstream** Building adjustment

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ android-lld = ["snmalloc-sys/android-lld"]
3131
android-shared-stl = ["snmalloc-sys/android-shared-stl"]
3232
native-cpu = ["snmalloc-sys/native-cpu"]
3333
local_dynamic_tls = ["snmalloc-sys/local_dynamic_tls"]
34-
34+
win8compat = ["snmalloc-sys/win8compat"]
35+
usecxx20 = ["snmalloc-sys/usecxx20"]

snmalloc-sys/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ android-lld = []
3030
android-shared-stl = []
3131
native-cpu = []
3232
local_dynamic_tls = []
33+
win8compat = []
34+
usecxx20 = []

snmalloc-sys/build.rs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ fn main() {
1414
build.flag_if_supported("/Ob2");
1515
build.flag_if_supported("/DNDEBUG");
1616
build.flag_if_supported("/EHsc");
17-
build.flag_if_supported("/std:c++17");
1817
build.flag_if_supported("/Gd");
1918
build.flag_if_supported("/TP");
2019
build.flag_if_supported("/Gm-");
@@ -24,9 +23,6 @@ fn main() {
2423
build.flag_if_supported("/Zc:forScope");
2524
build.flag_if_supported("/Zc:inline");
2625
build.flag_if_supported("-O3");
27-
build.flag_if_supported("-Wc++17-extensions");
28-
build.flag_if_supported("-std=c++1z");
29-
build.flag_if_supported("-std=gnu++1z");
3026
build.flag_if_supported("-mcx16");
3127
build.flag_if_supported("-fno-exceptions");
3228
build.flag_if_supported("-fno-rtti");
@@ -36,6 +32,21 @@ fn main() {
3632
build.static_crt(true);
3733
build.cpp(true);
3834
build.debug(false);
35+
if cfg!(feature = "usecxx20") {
36+
build.flag_if_supported("-std=c++17"); //original required if cxx20 not supported
37+
build.flag_if_supported("/std:c++17");
38+
build.flag_if_supported("-Wc++17-extensions");
39+
build.flag_if_supported("/Wc++17-extensions");
40+
build.flag_if_supported("-std=c++20");
41+
build.flag_if_supported("/std:c++20");
42+
build.flag_if_supported("-Wc++20-extensions");
43+
build.flag_if_supported("/Wc++20-extensions");
44+
} else {
45+
build.flag_if_supported("-std=c++17");
46+
build.flag_if_supported("/std:c++17");
47+
build.flag_if_supported("-Wc++17-extensions");
48+
build.flag_if_supported("/Wc++17-extensions");
49+
}
3950

4051
let triple = std::env::var("TARGET").unwrap();
4152
let target_os = std::env::var("CARGO_CFG_TARGET_OS").expect("target_os not defined!");
@@ -57,7 +68,7 @@ fn main() {
5768
} else if triple.contains("x86_64") {
5869
build.define("ANDROID_ABI", "x86_64");
5970
} else if triple.contains("i686") {
60-
build.define("ANDROID_ABI", "x86_64");
71+
build.define("ANDROID_ABI", "x86");
6172
} else if triple.contains("neon") {
6273
build.define("ANDROID_ABI", "armeabi-v7a with NEON");
6374
} else if triple.contains("arm") {
@@ -73,6 +84,10 @@ fn main() {
7384
}
7485
}
7586

87+
if cfg!(feature = "win8compat") {
88+
build.flag_if_supported("-DWINVER=0x0603");
89+
}
90+
7691
let target = if cfg!(feature = "1mib") {
7792
"snmallocshim-1mib-rust"
7893
} else if cfg!(feature = "16mib") {
@@ -105,7 +120,9 @@ fn main() {
105120
}
106121

107122
if target_env == "msvc" {
108-
println!("cargo:rustc-link-lib=dylib=mincore");
123+
if cfg!(not(feature = "win8compat")) {
124+
println!("cargo:rustc-link-lib=dylib=mincore");
125+
}
109126
}
110127

111128
if target_os == "windows" && target_env == "gnu" {
@@ -179,7 +196,7 @@ fn main() {
179196
} else if triple.contains("x86_64") {
180197
cfg = cfg.define("ANDROID_ABI", "x86_64");
181198
} else if triple.contains("i686") {
182-
cfg = cfg.define("ANDROID_ABI", "x86_64");
199+
cfg = cfg.define("ANDROID_ABI", "x86");
183200
} else if triple.contains("neon") {
184201
cfg = cfg.define("ANDROID_ABI", "armeabi-v7a with NEON")
185202
} else if triple.contains("arm") {
@@ -190,6 +207,9 @@ fn main() {
190207
if cfg!(all(windows, target_env = "msvc")) {
191208
cfg = cfg.define("CMAKE_CXX_FLAGS_RELEASE", "/O2 /Ob2 /DNDEBUG /EHsc");
192209
cfg = cfg.define("CMAKE_C_FLAGS_RELEASE", "/O2 /Ob2 /DNDEBUG /EHsc");
210+
if cfg!(feature = "win8compat") {
211+
cfg = cfg.define("WIN8COMPAT", "ON")
212+
}
193213
}
194214

195215
if cfg!(all(windows, target_env = "gnu")) {
@@ -208,6 +228,10 @@ fn main() {
208228
cfg = cfg.define("SNMALLOC_OPTIMISE_FOR_CURRENT_MACHINE", "ON")
209229
}
210230

231+
if cfg!(feature = "usecxx20") {
232+
cfg = cfg.define("SNMALLOC_USE_CXX20", "ON")
233+
}
234+
211235
if cfg!(feature = "stats") {
212236
cfg = cfg.define("USE_SNMALLOC_STATS", "ON")
213237
}
@@ -229,7 +253,9 @@ fn main() {
229253
println!("cargo:rustc-link-lib={}", target);
230254

231255
if cfg!(all(windows, target_env = "msvc")) {
232-
println!("cargo:rustc-link-lib=dylib=mincore");
256+
if cfg!(not(feature = "win8compat")) {
257+
println!("cargo:rustc-link-lib=dylib=mincore");
258+
}
233259
println!(
234260
"cargo:rustc-link-search=native={}/{}",
235261
dst.display(),
@@ -258,7 +284,7 @@ fn main() {
258284
.lines()
259285
.filter(|line| line.starts_with("libraries: ="))
260286
.map(|line| line.split_at("libraries: =".len()).1)
261-
.flat_map(|line| line.split(";"))
287+
.flat_map(|line| line.split(';'))
262288
.for_each(|path| {
263289
println!("cargo:rustc-link-search=native={}", path);
264290
});

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mod tests {
7979
let layout = Layout::from_size_align(8, 8).unwrap();
8080
let alloc = SnMalloc;
8181

82-
let ptr = alloc.alloc(layout.clone());
82+
let ptr = alloc.alloc(layout);
8383
alloc.dealloc(ptr, layout);
8484
}
8585
}
@@ -90,7 +90,7 @@ mod tests {
9090
let layout = Layout::from_size_align(8, 8).unwrap();
9191
let alloc = SnMalloc;
9292

93-
let ptr = alloc.alloc_zeroed(layout.clone());
93+
let ptr = alloc.alloc_zeroed(layout);
9494
alloc.dealloc(ptr, layout);
9595
}
9696
}
@@ -101,8 +101,8 @@ mod tests {
101101
let layout = Layout::from_size_align(8, 8).unwrap();
102102
let alloc = SnMalloc;
103103

104-
let ptr = alloc.alloc(layout.clone());
105-
let ptr = alloc.realloc(ptr, layout.clone(), 16);
104+
let ptr = alloc.alloc(layout);
105+
let ptr = alloc.realloc(ptr, layout, 16);
106106
alloc.dealloc(ptr, layout);
107107
}
108108
}

0 commit comments

Comments
 (0)