libc: Control Z_LIBC_PARTITION_EXISTS from Kconfig

Instead of adding every possible subsystem which places variables in the C
library memory partition in libc-hooks.h, place those conditions in the
related Kconfig files and simplify the libc-hooks.h to just looking at
CONFIG_NEED_LIBC_MEM_PARTITION.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2023-10-04 09:17:27 -07:00 committed by Johan Hedberg
commit eb024b655f
3 changed files with 4 additions and 3 deletions

View file

@ -92,9 +92,7 @@ __syscall size_t zephyr_fwrite(const void *ZRESTRICT ptr, size_t size,
extern struct k_mem_partition z_malloc_partition;
#endif
#if defined(CONFIG_NEWLIB_LIBC) || (defined(CONFIG_STACK_CANARIES) && \
!defined(CONFIG_STACK_CANARIES_TLS)) || \
defined(CONFIG_PICOLIBC) || defined(CONFIG_NEED_LIBC_MEM_PARTITION)
#ifdef CONFIG_NEED_LIBC_MEM_PARTITION
/* - All newlib globals will be placed into z_libc_partition.
* - Minimal C library globals, if any, will be placed into
* z_libc_partition.

View file

@ -975,6 +975,7 @@ menu "Security Options"
config STACK_CANARIES
bool "Compiler stack canaries"
depends on ENTROPY_GENERATOR || TEST_RANDOM_GENERATOR
select NEED_LIBC_MEM_PARTITION if !STACK_CANARIES_TLS
help
This option enables compiler stack canaries.

View file

@ -74,6 +74,7 @@ config PICOLIBC
select COMMON_LIBC_ABORT
select THREAD_LOCAL_STORAGE if ARCH_HAS_THREAD_LOCAL_STORAGE && TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE
select LIBC_ERRNO if THREAD_LOCAL_STORAGE
select NEED_LIBC_MEM_PARTITION
imply COMMON_LIBC_MALLOC
depends on !NATIVE_APPLICATION
depends on PICOLIBC_SUPPORTED
@ -87,6 +88,7 @@ config NEWLIB_LIBC
select COMMON_LIBC_ABORT
depends on !NATIVE_APPLICATION
depends on NEWLIB_LIBC_SUPPORTED
select NEED_LIBC_MEM_PARTITION
help
Build with newlib library. The newlib library is expected to be
part of the SDK in this case.