From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/7] malloc_simple: Add Kconfig option for using only malloc_simple in the SPL
Date: Tue, 22 Sep 2015 11:38:46 +0200 [thread overview]
Message-ID: <560121A6.5070409@redhat.com> (raw)
In-Reply-To: <CAPnjgZ1cv-h3LSTDwmUVQXQh6a5SH0fsbivdv84sZfiP+ieTFg@mail.gmail.com>
Hi,
On 22-09-15 06:00, Simon Glass wrote:
> Hi Hans,
>
> On 13 September 2015 at 09:42, Hans de Goede <hdegoede@redhat.com> wrote:
>> 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:
>>
>
> Was there a '#' at the start of this missing line?
Yep, I keep falling over git commit eating up any lines starting with
a # when quoting code snippets in commit messages...
I will fix this and send a v2.
>> This commit introduces a SPL_MALLOC_SIMPLE Kconfig bool which allows
>> selecting this functionality through Kconfig instead.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> Kconfig | 10 ++++++++++
>> common/malloc_simple.c | 3 ++-
>> include/_exports.h | 3 ++-
>> include/exports.h | 3 ++-
>> include/malloc.h | 3 ++-
>> 5 files changed, 18 insertions(+), 4 deletions(-)
>>
>> diff --git a/Kconfig b/Kconfig
>> index 05a34f7..0ae4fab 100644
>> --- a/Kconfig
>> +++ b/Kconfig
>> @@ -114,6 +114,16 @@ config SPL
>> help
>> If you want to build SPL as well as the normal image, say Y.
>>
>> +config SPL_MALLOC_SIMPLE
>
> If you made it 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
>> depends on SPL
>> bool "Enable SDRAM location for SPL stack"
>> diff --git a/common/malloc_simple.c b/common/malloc_simple.c
>> index c745863..e9c1eaa 100644
>> --- a/common/malloc_simple.c
>> +++ b/common/malloc_simple.c
>> @@ -40,7 +40,8 @@ void *memalign_simple(size_t align, size_t bytes)
>> return ptr;
>> }
>>
>> -#ifdef CONFIG_SYS_MALLOC_SIMPLE
>> +#if (defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) || \
>> + (defined CONFIG_SYS_MALLOC_SIMPLE)
>
> then I think this could become:
>
> #if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
I think you're right, good one. I'll give this a spin and
if it works include the change in V2.
>> void *calloc(size_t nmemb, size_t elem_size)
>> {
>> size_t size = nmemb * elem_size;
>> diff --git a/include/_exports.h b/include/_exports.h
>> index 74a882a..f811c5d 100644
>> --- a/include/_exports.h
>> +++ b/include/_exports.h
>> @@ -23,7 +23,8 @@
>> EXPORT_FUNC(dummy, void, free_hdlr, void)
>> #endif
>> EXPORT_FUNC(malloc, void *, malloc, size_t)
>> -#ifndef CONFIG_SYS_MALLOC_SIMPLE
>> +#if !(defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) && \
>> + !(defined CONFIG_SYS_MALLOC_SIMPLE)
>> EXPORT_FUNC(free, void, free, void *)
>> #endif
>> EXPORT_FUNC(udelay, void, udelay, unsigned long)
>> diff --git a/include/exports.h b/include/exports.h
>> index a3e0469..8171b31 100644
>> --- a/include/exports.h
>> +++ b/include/exports.h
>> @@ -19,7 +19,8 @@ int printf(const char* fmt, ...);
>> void install_hdlr(int, interrupt_handler_t, void*);
>> void free_hdlr(int);
>> void *malloc(size_t);
>> -#ifndef CONFIG_SYS_MALLOC_SIMPLE
>> +#if !(defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) && \
>> + !(defined CONFIG_SYS_MALLOC_SIMPLE)
>> void free(void*);
>> #endif
>> void __udelay(unsigned long);
>> diff --git a/include/malloc.h b/include/malloc.h
>> index f4da9e6..e5592fc 100644
>> --- a/include/malloc.h
>> +++ b/include/malloc.h
>> @@ -872,7 +872,8 @@ extern Void_t* sbrk();
>>
>> #else
>>
>> -#ifdef CONFIG_SYS_MALLOC_SIMPLE
>> +#if (defined CONFIG_SPL_BUILD && defined CONFIG_SPL_MALLOC_SIMPLE) || \
>> + (defined CONFIG_SYS_MALLOC_SIMPLE)
>> #define malloc malloc_simple
>> #define realloc realloc_simple
>> #define memalign memalign_simple
>> --
>> 2.4.3
>>
>
> Regards,
> Simon
>
Regards,
Hans
next prev parent reply other threads:[~2015-09-22 9:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-13 15:42 [U-Boot] [PATCH 0/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
2015-09-13 15:42 ` [U-Boot] [PATCH 1/7] spl: spl_relocate_stack_gd: Do not unnecessarily clear bss Hans de Goede
2015-09-22 4:00 ` Simon Glass
2015-09-13 15:42 ` [U-Boot] [PATCH 2/7] malloc_simple: Fix malloc_ptr calculation Hans de Goede
2015-09-22 4:00 ` Simon Glass
2015-09-13 15:42 ` [U-Boot] [PATCH 3/7] malloc_simple: Add Kconfig option for using only malloc_simple in the SPL Hans de Goede
2015-09-22 4:00 ` Simon Glass
2015-09-22 9:38 ` Hans de Goede [this message]
2015-09-13 15:42 ` [U-Boot] [PATCH 4/7] malloc_simple: Add support for switching to DRAM heap Hans de Goede
2015-09-22 4:00 ` Simon Glass
2015-09-22 9:52 ` Hans de Goede
2015-09-13 15:42 ` [U-Boot] [PATCH 5/7] sunxi: Simplify spl board_init_f function Hans de Goede
2015-09-13 16:27 ` Ian Campbell
2015-09-13 15:42 ` [U-Boot] [PATCH 6/7] sunxi: Enable CONFIG_SPL_STACK_R Hans de Goede
2015-09-13 16:33 ` Ian Campbell
2015-09-13 16:38 ` Hans de Goede
2015-09-13 18:50 ` Ian Campbell
2015-09-13 18:51 ` Hans de Goede
2015-09-14 6:00 ` Ian Campbell
2015-09-13 15:42 ` [U-Boot] [PATCH 7/7] sunxi: Switch to using malloc_simple for the spl Hans de Goede
2015-09-13 16:33 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=560121A6.5070409@redhat.com \
--to=hdegoede@redhat.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox