diff mbox series

[1/3] malloc: Don't use ifdefs for SYS_MALLOC_DEFAULT_TO_INIT

Message ID 20230731223327.109865-2-sean.anderson@seco.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series malloc: Reduce size by initializing data at runtime | expand

Commit Message

Sean Anderson July 31, 2023, 10:33 p.m. UTC
With CONFIG_IS_ENABLED we can eliminate some ifdefs.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 common/dlmalloc.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Heinrich Schuchardt Aug. 1, 2023, 5:25 a.m. UTC | #1
On 8/1/23 00:33, Sean Anderson wrote:
> With CONFIG_IS_ENABLED we can eliminate some ifdefs.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> ---
>
>   common/dlmalloc.c | 9 ++-------
>   1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/common/dlmalloc.c b/common/dlmalloc.c
> index 0f9b7262d5..30c78ae976 100644
> --- a/common/dlmalloc.c
> +++ b/common/dlmalloc.c
> @@ -588,9 +588,7 @@ static void malloc_bin_reloc(void)
>   static inline void malloc_bin_reloc(void) {}
>   #endif
>
> -#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
>   static void malloc_init(void);
> -#endif
>
>   ulong mem_malloc_start = 0;
>   ulong mem_malloc_end = 0;
> @@ -625,9 +623,8 @@ void mem_malloc_init(ulong start, ulong size)
>   	mem_malloc_end = start + size;
>   	mem_malloc_brk = start;
>
> -#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
> -	malloc_init();
> -#endif
> +	if (CONFIG_IS_ENABLED(SYS_MALLOC_DEFAULT_TO_INIT))
> +		malloc_init();
>
>   	debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start,
>   	      mem_malloc_end);
> @@ -733,7 +730,6 @@ static unsigned int max_n_mmaps = 0;
>   static unsigned long max_mmapped_mem = 0;
>   #endif
>
> -#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
>   static void malloc_init(void)
>   {
>   	int i, j;
> @@ -762,7 +758,6 @@ static void malloc_init(void)
>   	memset((void *)&current_mallinfo, 0, sizeof(struct mallinfo));
>   #endif
>   }
> -#endif
>
>   /*
>     Debugging support
Simon Glass Aug. 9, 2023, 2:03 a.m. UTC | #2
On Mon, 31 Jul 2023 at 23:24, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 8/1/23 00:33, Sean Anderson wrote:
> > With CONFIG_IS_ENABLED we can eliminate some ifdefs.
> >
> > Signed-off-by: Sean Anderson <sean.anderson@seco.com>
>
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 0f9b7262d5..30c78ae976 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -588,9 +588,7 @@  static void malloc_bin_reloc(void)
 static inline void malloc_bin_reloc(void) {}
 #endif
 
-#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
 static void malloc_init(void);
-#endif
 
 ulong mem_malloc_start = 0;
 ulong mem_malloc_end = 0;
@@ -625,9 +623,8 @@  void mem_malloc_init(ulong start, ulong size)
 	mem_malloc_end = start + size;
 	mem_malloc_brk = start;
 
-#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
-	malloc_init();
-#endif
+	if (CONFIG_IS_ENABLED(SYS_MALLOC_DEFAULT_TO_INIT))
+		malloc_init();
 
 	debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start,
 	      mem_malloc_end);
@@ -733,7 +730,6 @@  static unsigned int max_n_mmaps = 0;
 static unsigned long max_mmapped_mem = 0;
 #endif
 
-#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
 static void malloc_init(void)
 {
 	int i, j;
@@ -762,7 +758,6 @@  static void malloc_init(void)
 	memset((void *)&current_mallinfo, 0, sizeof(struct mallinfo));
 #endif
 }
-#endif
 
 /*
   Debugging support