* [U-Boot] SYS_MALLOC_SIMPLE versus SPL_SYS_MALLOC_SIMPLE?
@ 2016-04-16 8:58 Robert P. J. Day
2016-04-18 8:54 ` Hans de Goede
0 siblings, 1 reply; 2+ messages in thread
From: Robert P. J. Day @ 2016-04-16 8:58 UTC (permalink / raw)
To: u-boot
(WARNING: many potentially dumb questions coming this weekend as i
try to put together a u-boot tutorial for some upcoming presentations.
please be patient ... )
i had a much longer question about the config option
SYS_MALLOC_SIMPLE until i noticed that it doesn't seem to be defined
in a Kconfig file:
$ grep -rw SYS_MALLOC_SIMPLE *
common/malloc_simple.c:#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
include/exports.h:#if !CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
include/_exports.h:#if !CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
include/malloc.h:#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
$
that appears to be the extent of that symbol in the entire u-boot
source tree, which is obviously different from:
$ grep -rw SPL_SYS_MALLOC_SIMPLE *
arch/arm/Kconfig: select SPL_SYS_MALLOC_SIMPLE if SUPPORT_SPL
arch/arm/mach-rockchip/Kconfig:config SPL_SYS_MALLOC_SIMPLE
Kconfig:config SPL_SYS_MALLOC_SIMPLE
Kconfig: depends on SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE
$
the top-level Kconfig file mentions only the latter:
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.
the header file include/malloc.h proceeds to test the *former*:
#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
#define malloc malloc_simple
#define realloc realloc_simple
#define memalign memalign_simple
static inline void free(void *ptr) {}
void *calloc(size_t nmemb, size_t size);
void *memalign_simple(size_t alignment, size_t bytes);
void *realloc_simple(void *ptr, size_t size);
#else
... snip ...
but (oddly?) common/Makefile includes the conditional compilation:
ifdef CONFIG_SYS_MALLOC_F_LEN (?????)
obj-y += malloc_simple.o
endif
and to top things off, the source file common/malloc_simple.c
contains:
void *malloc_simple(size_t bytes)
{
...
}
void *memalign_simple(size_t align, size_t bytes)
{
...
}
#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
void *calloc(size_t nmemb, size_t elem_size)
{
...
}
#endif
at this point, i'm a bit confused as to how all of this malloc_simple
stuff hangs together and what the valid Kconfig configurations are.
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
^ permalink raw reply [flat|nested] 2+ messages in thread
* [U-Boot] SYS_MALLOC_SIMPLE versus SPL_SYS_MALLOC_SIMPLE?
2016-04-16 8:58 [U-Boot] SYS_MALLOC_SIMPLE versus SPL_SYS_MALLOC_SIMPLE? Robert P. J. Day
@ 2016-04-18 8:54 ` Hans de Goede
0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2016-04-18 8:54 UTC (permalink / raw)
To: u-boot
Hi,
On 16-04-16 10:58, Robert P. J. Day wrote:
>
> (WARNING: many potentially dumb questions coming this weekend as i
> try to put together a u-boot tutorial for some upcoming presentations.
> please be patient ... )
>
> i had a much longer question about the config option
> SYS_MALLOC_SIMPLE until i noticed that it doesn't seem to be defined
> in a Kconfig file:
>
> $ grep -rw SYS_MALLOC_SIMPLE *
> common/malloc_simple.c:#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
> include/exports.h:#if !CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
> include/_exports.h:#if !CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
> include/malloc.h:#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
> $
>
> that appears to be the extent of that symbol in the entire u-boot
> source tree, which is obviously different from:
>
> $ grep -rw SPL_SYS_MALLOC_SIMPLE *
> arch/arm/Kconfig: select SPL_SYS_MALLOC_SIMPLE if SUPPORT_SPL
> arch/arm/mach-rockchip/Kconfig:config SPL_SYS_MALLOC_SIMPLE
> Kconfig:config SPL_SYS_MALLOC_SIMPLE
> Kconfig: depends on SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE
> $
There is some magic happening somewhere whereby SPL_FOO_BAR
Kconfig settings only get set when builind the SPL and they
actually get set as FOO_BAR, so the SPL_ prefix is special
and tells the u-boot build scripts to only define FOO_BAR
when building the SPL, this goes for all SPL_ prefixed
Kconfig settings. This all is IIRC.
Regards,
Hans
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-18 8:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-16 8:58 [U-Boot] SYS_MALLOC_SIMPLE versus SPL_SYS_MALLOC_SIMPLE? Robert P. J. Day
2016-04-18 8:54 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox