[U-Boot] [PATCH v2] DLMALLOC:!X86: add av_ initialization

Graeme Russ graeme.russ at gmail.com
Wed Oct 7 04:52:04 CEST 2009


On Wed, Oct 7, 2009 at 1:13 PM, Nishanth Menon <nm at ti.com> wrote:
> Remove the predefined static initialization
> and generate the map dynamically to reduce
> code size.
>
> This patch benefits were pointed out by Peter:
> http://www.nabble.com/forum/Permalink.jtp?root=25518020&post=25523748&page=y
>
> Signed-off-by: Nishanth Menon <nm at ti.com>
> Cc: Peter Tyser <ptyser at xes-inc.com>
> Cc: Sandeep Paulraj <s-paulraj at ti.com>
> Cc: Tom Rix <tom.rix at windriver.com>
> ---
>  common/dlmalloc.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/common/dlmalloc.c b/common/dlmalloc.c
> index 241db8c..25e5314 100644
> --- a/common/dlmalloc.c
> +++ b/common/dlmalloc.c
> @@ -1474,6 +1474,7 @@ typedef struct malloc_chunk* mbinptr;
>
>  #define IAV(i)  bin_at(i), bin_at(i)
>
> +#ifdef CONFIG_X86
>  static mbinptr av_[NAV * 2 + 2] = {
>  0, 0,
>  IAV(0),   IAV(1),   IAV(2),   IAV(3),   IAV(4),   IAV(5),   IAV(6),   IAV(7),
> @@ -1493,6 +1494,9 @@ static mbinptr av_[NAV * 2 + 2] = {
>  IAV(112), IAV(113), IAV(114), IAV(115), IAV(116), IAV(117), IAV(118), IAV(119),
>  IAV(120), IAV(121), IAV(122), IAV(123), IAV(124), IAV(125), IAV(126), IAV(127)
>  };
> +#else
> +static mbinptr av_[NAV * 2 + 2];
> +#endif

Is there any reason why X86 is treated differently? I know the previous
patch to dlmalloc.c did, but in the end it really didn't need to and ended
up breaking the x86 build anyway (my fault for not getting time to test it
before it went mainline)

Feel free to remove this #ifdef unless you are 100% sure it IS needed.
Mainline x86 is broken anyway - if this change introduces another break, I
will submit a consolidated fix soon

>
>  void malloc_bin_reloc (void)
>  {
> @@ -1527,6 +1531,11 @@ void *sbrk(ptrdiff_t increment)
>  */
>  void mem_malloc_init(ulong start, ulong size)
>  {
> +       u8 i;
> +       av_[0] = av_[1] = 0;
> +       for (i = 0; i < 128; i++)
> +               av_[2 + i * 2] = av_[2 + i * 2 + 1] = bin_at(i);
> +
>        mem_malloc_start = start;
>        mem_malloc_end = start + size;
>        mem_malloc_brk = start;
> --
> 1.6.0.4

Regards,

Graeme


More information about the U-Boot mailing list