Skip to content

Commit d8ab51d

Browse files
committed
std: xous: share allocator symbol in tests
When using the testing framework, a second copy of libstd is built and linked. Use a global symbol for the `DLMALLOC` variable and mark it as `extern` when building as a test. This ensures we only have a single allocator even when running tests. Signed-off-by: Sean Cross <[email protected]>
1 parent 252ac51 commit d8ab51d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/std/src/sys/xous/alloc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use crate::alloc::{GlobalAlloc, Layout, System};
22

3+
#[cfg_attr(test, linkage = "available_externally")]
4+
#[export_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE"]
35
static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::Dlmalloc::new();
46

57
#[stable(feature = "alloc_system_type", since = "1.28.0")]

0 commit comments

Comments
 (0)