Skip to contentSkip to conversation

malloc: make malloc_bin_reloc static

PATCH In review Gabor Juhos 2 participants 2 messages Jan 22, 2013 – Feb 20, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 malloc: make malloc_bin_reloc static

On architectures where manual relocation is needed, the 'malloc_bin_reloc' function must be called after 'mem_malloc_init'.

Make the 'malloc_bin_reloc' function static and call it directly from 'mem_malloc_init' instead of calling that from board_init_{r,f} functions of the affected architectures.

Cc Wolfgang Denk <[email protected]>
Cc Andreas Bie?mann <[email protected]>
Cc Jason Jin <[email protected]>
Cc Macpaul Lin <[email protected]>
Cc Daniel Hellstrom <[email protected]>
Cc Daniel Schwierzeck <[email protected]>
---
 arch/avr32/lib/board.c |    1 -
 arch/m68k/lib/board.c  |    1 -
 arch/mips/lib/board.c  |    1 -
 arch/nds32/lib/board.c |    1 -
 arch/sparc/lib/board.c |    1 -
 common/dlmalloc.c      |    6 +++++-
 include/malloc.h       |    1 -
 7 files changed, 5 insertions(+), 7 deletions(-)
arch/avr32/lib/board.c +0 -1
index e3287c4..76cbea5 100644
@@ -286,7 +286,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 	/* The malloc area is right below the monitor image in RAM */
 	mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
 			CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN);
-	malloc_bin_reloc();
 	dma_alloc_init();
 
 	enable_interrupts();
arch/m68k/lib/board.c +0 -1
index e934cb6..64f096a 100644
@@ -449,7 +449,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	/* The Malloc area is immediately below the monitor copy in DRAM */
 	mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
 			TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN);
-	malloc_bin_reloc ();
 
 #if !defined(CONFIG_SYS_NO_FLASH)
 	puts ("Flash: ");
arch/mips/lib/board.c +0 -1
index d79e183..51c08dd 100644
@@ -283,7 +283,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* The Malloc area is immediately below the monitor copy in DRAM */
 	mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
 			TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN);
-	malloc_bin_reloc();
 
 #ifndef CONFIG_SYS_NO_FLASH
 	/* configure available FLASH banks */
arch/nds32/lib/board.c +0 -1
index 91395ca..dbfb468 100644
@@ -331,7 +331,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* The Malloc area is immediately below the monitor copy in DRAM */
 	malloc_start = dest_addr - TOTAL_MALLOC_LEN;
 	mem_malloc_init(malloc_start, TOTAL_MALLOC_LEN);
-	malloc_bin_reloc();
 
 #ifndef CONFIG_SYS_NO_FLASH
 	/* configure available FLASH banks */
arch/sparc/lib/board.c +0 -1
index 1b5e995..79fb4c8 100644
@@ -271,7 +271,6 @@ void board_init_f(ulong bootflag)
 	/* The Malloc area is immediately below the monitor copy in RAM */
 	mem_malloc_init(CONFIG_SYS_MALLOC_BASE,
 			CONFIG_SYS_MALLOC_END - CONFIG_SYS_MALLOC_BASE);
-	malloc_bin_reloc();
 
 #if !defined(CONFIG_SYS_NO_FLASH)
 	puts("Flash: ");
common/dlmalloc.c +5 -1
index b2f0a1a..2a9d169 100644
@@ -1485,7 +1485,7 @@ static mbinptr av_[NAV * 2 + 2] = {
 };
 
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
-void malloc_bin_reloc (void)
+static void malloc_bin_reloc(void)
 {
 	mbinptr *p = &av_[2];
 	size_t i;
@@ -1493,6 +1493,8 @@ void malloc_bin_reloc (void)
 	for (i = 2; i < ARRAY_SIZE(av_); ++i, ++p)
 		*p = (mbinptr)((ulong)*p + gd->reloc_off);
 }
+#else
+static inline void malloc_bin_reloc(void) {}
 #endif
 
 ulong mem_malloc_start = 0;
@@ -1526,6 +1528,8 @@ void mem_malloc_init(ulong start, ulong size)
 	mem_malloc_brk = start;
 
 	memset((void *)mem_malloc_start, 0, size);
+
+	malloc_bin_reloc();
 }
 
 /* field-extraction macros */
include/malloc.h +0 -1
index 84ecf79..6295929 100644
@@ -937,7 +937,6 @@ extern ulong mem_malloc_end;
 extern ulong mem_malloc_brk;
 
 void mem_malloc_init(ulong start, ulong size);
-void malloc_bin_reloc(void);
 
 #ifdef __cplusplus
 };  /* end of extern "C" */
Signature · 1 line
1.7.10
#1 lore raw
Quoted 9 lines · Gabor Juhos

On architectures where manual relocation is needed, the 'malloc_bin_reloc' function must be called after 'mem_malloc_init'.

Make the 'malloc_bin_reloc' function static and call it directly from 'mem_malloc_init' instead of calling that from board_init_{r,f} functions of the affected architectures.

Quoted 7 lines
Cc Wolfgang Denk <[email protected]>
Cc Andreas Bie??mann <[email protected]>
Cc Jason Jin <[email protected]>
Cc Macpaul Lin <[email protected]>
Cc Daniel Hellstrom <[email protected]>
Cc Daniel Schwierzeck <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130220/4f260d05/attachment.pgp>