diff options
| author | Sean Cross <sean@xobs.io> | 2023-12-29 17:54:26 +0800 |
|---|---|---|
| committer | Sean Cross <sean@xobs.io> | 2024-01-13 09:13:56 -0800 |
| commit | ef4f722835ccf11dd002606e3ad4adb342ea4435 (patch) | |
| tree | 897625c897c3c0284fe56bd9a64982df158b0d1a /library/std/src/sys/pal/xous/alloc.rs | |
| parent | 007bf7a05a834ace889589e3e73ab6bc91f6f491 (diff) | |
| download | rust-ef4f722835ccf11dd002606e3ad4adb342ea4435.tar.gz rust-ef4f722835ccf11dd002606e3ad4adb342ea4435.zip | |
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>
Diffstat (limited to 'library/std/src/sys/pal/xous/alloc.rs')
| -rw-r--r-- | library/std/src/sys/pal/xous/alloc.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/library/std/src/sys/pal/xous/alloc.rs b/library/std/src/sys/pal/xous/alloc.rs index b3a3e691e0d..0d540e95520 100644 --- a/library/std/src/sys/pal/xous/alloc.rs +++ b/library/std/src/sys/pal/xous/alloc.rs @@ -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] |
