Skip to content

Commit

Permalink
lib: libc: newlib: define USED_RAM_END_ADDR only where it is needed
Browse files Browse the repository at this point in the history
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 26, 2019
1 parent 8226aa1 commit 53ec19c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/libc/newlib/libc-hooks.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 53ec19c

Please sign in to comment.