Skip to content

Commit

Permalink
lib: libc: newlib: Initialise libc heap during POST_KERNEL phase
Browse files Browse the repository at this point in the history
This commit changes the invocation of the newlib malloc heap
initialisation function such that it is executed during the POST_KERNEL
phase instead of the APPLICATION phase.

This is necessary in order to ensure that the application
initialisation functions (i.e. the functions called during the
APPLICATIION phase) can make use of the libc heap.

Signed-off-by: Stephanos Ioannidis <[email protected]>
  • Loading branch information
stephanosio authored and carlescufi committed Jul 6, 2022
1 parent db0748c commit 43e1c28
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libc/newlib/libc-hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static int malloc_prepare(const struct device *unused)
return 0;
}

SYS_INIT(malloc_prepare, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
SYS_INIT(malloc_prepare, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

/* Current offset from HEAP_BASE of unused memory */
LIBC_BSS static size_t heap_sz;
Expand Down

0 comments on commit 43e1c28

Please sign in to comment.