From 6d135d35799bc028792fd9d94bf904b00e6b8899 Mon Sep 17 00:00:00 2001 From: Oleg Hahm <oleg@hobbykeller.org> Date: Fri, 18 Dec 2015 13:03:12 +0100 Subject: [PATCH] native: make use of TLSF malloc and co In order to make native behave more similar to other platforms, it should also use TLSF's dynamic memory allocation if included. It will still fall back to the system's malloc implementation when building for use with valgrind, to leverage its memory leak detection mechanisms. --- cpu/native/syscalls.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cpu/native/syscalls.c b/cpu/native/syscalls.c index f3a6811c47..d9385b40d6 100644 --- a/cpu/native/syscalls.c +++ b/cpu/native/syscalls.c @@ -134,6 +134,10 @@ void _native_syscall_leave(void) } } +/* make use of TLSF if it is included, except when building with valgrind + * support, where one probably wants to make use of valgrind's memory leak + * detection abilities*/ +#if !(defined MODULE_TLSF) || (defined(HAVE_VALGRIND_H)) int _native_in_malloc = 0; void *malloc(size_t size) { @@ -204,6 +208,7 @@ void *realloc(void *ptr, size_t size) _native_syscall_leave(); return r; } +#endif /* !(defined MODULE_TLSF) || (defined(HAVE_VALGRIND_H)) */ ssize_t _native_read(int fd, void *buf, size_t count) { -- GitLab