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 <sean@xobs.io>
This commit is contained in:
parent
007bf7a05a
commit
ef4f722835
1 changed files with 8 additions and 0 deletions
|
@ -1,7 +1,15 @@
|
|||
use crate::alloc::{GlobalAlloc, Layout, System};
|
||||
|
||||
#[cfg(not(test))]
|
||||
#[export_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE"]
|
||||
static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::Dlmalloc::new();
|
||||
|
||||
#[cfg(test)]
|
||||
extern "Rust" {
|
||||
#[link_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE"]
|
||||
static mut DLMALLOC: dlmalloc::Dlmalloc;
|
||||
}
|
||||
|
||||
#[stable(feature = "alloc_system_type", since = "1.28.0")]
|
||||
unsafe impl GlobalAlloc for System {
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Reference in a new issue