1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#[macro_use]
extern crate cfg_if;
cfg_if! {
if #[cfg(any(
feature = "force_global_jemalloc",
target_os = "linux",
target_os = "macos",
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd"
))] {
#[global_allocator]
pub static JEMALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
}
}
#[cfg(test)]
mod tests {
macro_rules! check {
() => {
#[test]
fn foo() {
let _ = super::JEMALLOC;
}
};
($os_name:tt) => {
#[cfg(target_os = $os_name)]
check!();
};
($($os_name:tt),*) => {
$(check!($os_name);)*
}
}
#[cfg(feature = "force_global_jemalloc")]
check!();
#[cfg(not(feature = "force_global_jemalloc"))]
check!("linux", "android", "macos", "ios", "freebsd", "netbsd", "openbsd");
}