Skip to content
Permalink
Browse files

lib: libc: newlib: define USED_RAM_END_ADDR only where it is needed

USED_RAM_END_ADDR is not used when Kconfig option
CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE is defined,
therefore, we do not need to define the macro in
that specific case.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
  • Loading branch information...
ioannisg authored and nashif committed Jun 19, 2019
1 parent 8226aa1 commit 53ec19c3cc7a5b2472d0a1a705074b187c59e54a
Showing with 5 additions and 6 deletions.
  1. +5 −6 lib/libc/newlib/libc-hooks.c
@@ -23,16 +23,15 @@
#if CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE
K_APPMEM_PARTITION_DEFINE(z_malloc_partition);
#define MALLOC_BSS K_APP_BMEM(z_malloc_partition)
#endif /* CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE */

#define USED_RAM_END_ADDR POINTER_TO_UINT(&_end)

#if CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE
/* Compiler will throw an error if the provided value isn't a power of two */
MALLOC_BSS static unsigned char __aligned(CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE)
heap_base[CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE];
#define MAX_HEAP_SIZE CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE
#else

#else /* CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE */

#define USED_RAM_END_ADDR POINTER_TO_UINT(&_end)

#if CONFIG_X86
#define USED_RAM_SIZE (USED_RAM_END_ADDR - DT_PHYS_RAM_ADDR)
@@ -75,7 +74,7 @@ static int malloc_prepare(struct device *unused)
}

SYS_INIT(malloc_prepare, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
#endif
#endif /* CONFIG_USERSPACE */
#endif /* CONFIG_NEWLIB_LIBC_ALIGNED_HEAP_SIZE */

LIBC_BSS static unsigned int heap_sz;

0 comments on commit 53ec19c

Please sign in to comment.
You can’t perform that action at this time.