diff --git a/hal/common/mbed_alloc_wrappers.cpp b/hal/common/mbed_alloc_wrappers.cpp index acd6b620af2..90622fa4644 100644 --- a/hal/common/mbed_alloc_wrappers.cpp +++ b/hal/common/mbed_alloc_wrappers.cpp @@ -67,9 +67,6 @@ void mbed_stats_heap_get(mbed_stats_heap_t *stats) #include "uvisor-lib/uvisor-lib.h" #endif/* FEATURE_UVISOR */ -// TODO: memory tracing doesn't work with uVisor enabled. -#if !defined(FEATURE_UVISOR) - extern "C" { void * __real__malloc_r(struct _reent * r, size_t size); void * __real__realloc_r(struct _reent * r, void * ptr, size_t size); @@ -77,6 +74,9 @@ extern "C" { void* __real__calloc_r(struct _reent * r, size_t nmemb, size_t size); } +// TODO: memory tracing doesn't work with uVisor enabled. +#if !defined(FEATURE_UVISOR) + extern "C" void * __wrap__malloc_r(struct _reent * r, size_t size) { void *ptr = NULL; #ifdef MBED_HEAP_STATS_ENABLED @@ -167,6 +167,8 @@ extern "C" void __wrap__free_r(struct _reent * r, void * ptr) { #endif // #ifdef MBED_MEM_TRACING_ENABLED } +#endif // if !defined(FEATURE_UVISOR) + extern "C" void * __wrap__calloc_r(struct _reent * r, size_t nmemb, size_t size) { void *ptr = NULL; #ifdef MBED_HEAP_STATS_ENABLED @@ -187,7 +189,6 @@ extern "C" void * __wrap__calloc_r(struct _reent * r, size_t nmemb, size_t size) return ptr; } -#endif // if !defined(FEATURE_UVISOR) /******************************************************************************/ /* ARMCC memory allocation wrappers */ diff --git a/hal/common/retarget.cpp b/hal/common/retarget.cpp index 16c4c582210..1dced8548cd 100644 --- a/hal/common/retarget.cpp +++ b/hal/common/retarget.cpp @@ -480,10 +480,9 @@ extern "C" WEAK void __cxa_pure_virtual(void) { #endif #if defined(TOOLCHAIN_GCC) -/* uVisor wraps malloc_r, realloc_r and free_r, but not calloc_r! */ -#ifndef FEATURE_UVISOR - +#ifdef FEATURE_UVISOR +#include "uvisor-lib/uvisor-lib.h" #endif/* FEATURE_UVISOR */