Skip to content
Snippets Groups Projects
Commit 1eb0c03c authored by Hans de Goede's avatar Hans de Goede
Browse files

malloc_simple: Add Kconfig option for using only malloc_simple in the SPL


common/dlmalloc.c is quite big, both in .text and .data usage, therefor
on some boards the SPL is build to use only malloc_simple.c and not the
dlmalloc.c code. This is done in various include/configs/foo.h with the
following construct:

 #ifdef CONFIG_SPL_BUILD
 #define CONFIG_SYS_MALLOC_SIMPLE
 #endif

This commit introduces a SPL_MALLOC_SIMPLE Kconfig bool which allows
selecting this functionality through Kconfig instead.

Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarSimon Glass <sjg@chromium.org>
parent 8656c4f7
No related branches found
No related tags found
No related merge requests found
...@@ -114,6 +114,16 @@ config SPL ...@@ -114,6 +114,16 @@ config SPL
help help
If you want to build SPL as well as the normal image, say Y. If you want to build SPL as well as the normal image, say Y.
config SPL_SYS_MALLOC_SIMPLE
bool
depends on SPL
prompt "Only use malloc_simple functions in the spl"
help
Say Y here to only use the *_simple malloc functions from
malloc_simple.c, rather then using the versions from dlmalloc.c
this will make the SPL binary smaller at the cost of more heap
usage as the *_simple malloc functions do not re-use free-ed mem.
config SPL_STACK_R config SPL_STACK_R
depends on SPL depends on SPL
bool "Enable SDRAM location for SPL stack" bool "Enable SDRAM location for SPL stack"
......
...@@ -40,7 +40,7 @@ void *memalign_simple(size_t align, size_t bytes) ...@@ -40,7 +40,7 @@ void *memalign_simple(size_t align, size_t bytes)
return ptr; return ptr;
} }
#ifdef CONFIG_SYS_MALLOC_SIMPLE #if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
void *calloc(size_t nmemb, size_t elem_size) void *calloc(size_t nmemb, size_t elem_size)
{ {
size_t size = nmemb * elem_size; size_t size = nmemb * elem_size;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
EXPORT_FUNC(dummy, void, free_hdlr, void) EXPORT_FUNC(dummy, void, free_hdlr, void)
#endif #endif
EXPORT_FUNC(malloc, void *, malloc, size_t) EXPORT_FUNC(malloc, void *, malloc, size_t)
#ifndef CONFIG_SYS_MALLOC_SIMPLE #if !CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
EXPORT_FUNC(free, void, free, void *) EXPORT_FUNC(free, void, free, void *)
#endif #endif
EXPORT_FUNC(udelay, void, udelay, unsigned long) EXPORT_FUNC(udelay, void, udelay, unsigned long)
......
...@@ -19,7 +19,7 @@ int printf(const char* fmt, ...); ...@@ -19,7 +19,7 @@ int printf(const char* fmt, ...);
void install_hdlr(int, interrupt_handler_t, void*); void install_hdlr(int, interrupt_handler_t, void*);
void free_hdlr(int); void free_hdlr(int);
void *malloc(size_t); void *malloc(size_t);
#ifndef CONFIG_SYS_MALLOC_SIMPLE #if !CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
void free(void*); void free(void*);
#endif #endif
void __udelay(unsigned long); void __udelay(unsigned long);
......
...@@ -872,7 +872,7 @@ extern Void_t* sbrk(); ...@@ -872,7 +872,7 @@ extern Void_t* sbrk();
#else #else
#ifdef CONFIG_SYS_MALLOC_SIMPLE #if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
#define malloc malloc_simple #define malloc malloc_simple
#define realloc realloc_simple #define realloc realloc_simple
#define memalign memalign_simple #define memalign memalign_simple
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment