diff --git a/lib/libc/Kconfig b/lib/libc/Kconfig index ef547c2a680..7f2b3a59fb6 100644 --- a/lib/libc/Kconfig +++ b/lib/libc/Kconfig @@ -142,93 +142,7 @@ config NEWLIB_LIBC_HEAP_LISTENER endif # NEWLIB_LIBC -if MINIMAL_LIBC - -config MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS - bool "Non-reentrant functions" - default y if !USERSPACE - select NEED_LIBC_MEM_PARTITION - help - Enable non-reentrant functions that make use of the globals; e.g. - rand() and gmtime(). The globals must be put into a dedicated C - library memory partition when CONFIG_USERSPACE=y, and enabling this - option may require an additional memory protection region. - -config MINIMAL_LIBC_MALLOC - bool "Minimal libc malloc implementation" - default y - help - Enable the minimal libc's implementation of malloc, free, and realloc. - Disable if you wish to provide your own implementations of these functions. - -config MINIMAL_LIBC_MALLOC_ARENA_SIZE - int "Size of the minimal libc malloc arena" - default 0 - depends on MINIMAL_LIBC_MALLOC - help - Indicate the size in bytes of the memory arena used for - minimal libc's malloc() implementation. - -config MINIMAL_LIBC_CALLOC - bool "Minimal libc trivial calloc implementation" - default y - help - Enable the minimal libc's trivial implementation of calloc, which - forwards to malloc and memset. - -config MINIMAL_LIBC_REALLOCARRAY - bool "Minimal libc trivial reallocarray implementation" - default y - help - Enable the minimal libc's trivial implementation of reallocarray, which - forwards to realloc. - -config MINIMAL_LIBC_LL_PRINTF - bool "Build with minimal libc long long printf" if !64BIT - default y if 64BIT - help - Build with long long printf enabled. This will increase the size of - the image. - -config MINIMAL_LIBC_OPTIMIZE_STRING_FOR_SIZE - bool "Use size optimized string functions" - default y if SIZE_OPTIMIZATIONS - help - Enable smaller but potentially slower implementations of memcpy and - memset. On the Cortex-M0+ this reduces the total code size by 120 bytes. - -config MINIMAL_LIBC_RAND - bool "Rand and srand functions" - help - Enable rand_r() for the minimal libc. - - In order to make use of the non-reentrant rand() and srand(), it is - necessary to set CONFIG_MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS=y. - -config MINIMAL_LIBC_TIME - bool "Time functions" - default y - help - Enable time() and gmtime_r() for the minimal libc. - - time() requires CONFIG_POSIX_CLOCK=y because it relies on the POSIX - clock_gettime() function. - - In order to make use of the non-reentrant gmtime(), it is necessary - to set CONFIG_MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS=y. - -config MINIMAL_LIBC_STRING_ERROR_TABLE - bool "String error table for strerror() and strerror_r()" - help - Select this option to ensure that streror(), strerror_r() - produce strings corresponding to the descriptions in errno.h. - - The string error table can add ~2kiB to ROM. As such, it is - disabled by default. In this case, strerror() and strerror_r() - symbols are still present, but the functions produce an empty - string. - -endif # MINIMAL_LIBC +rsource "minimal/Kconfig" config STDOUT_CONSOLE bool "Send stdout to console" diff --git a/lib/libc/minimal/Kconfig b/lib/libc/minimal/Kconfig new file mode 100644 index 00000000000..30e0f0385fe --- /dev/null +++ b/lib/libc/minimal/Kconfig @@ -0,0 +1,90 @@ +# Copyright (c) 2016 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +if MINIMAL_LIBC + +config MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS + bool "Non-reentrant functions" + default y if !USERSPACE + select NEED_LIBC_MEM_PARTITION + help + Enable non-reentrant functions that make use of the globals; e.g. + rand() and gmtime(). The globals must be put into a dedicated C + library memory partition when CONFIG_USERSPACE=y, and enabling this + option may require an additional memory protection region. + +config MINIMAL_LIBC_MALLOC + bool "Minimal libc malloc implementation" + default y + help + Enable the minimal libc's implementation of malloc, free, and realloc. + Disable if you wish to provide your own implementations of these functions. + +config MINIMAL_LIBC_MALLOC_ARENA_SIZE + int "Size of the minimal libc malloc arena" + default 0 + depends on MINIMAL_LIBC_MALLOC + help + Indicate the size in bytes of the memory arena used for + minimal libc's malloc() implementation. + +config MINIMAL_LIBC_CALLOC + bool "Minimal libc trivial calloc implementation" + default y + help + Enable the minimal libc's trivial implementation of calloc, which + forwards to malloc and memset. + +config MINIMAL_LIBC_REALLOCARRAY + bool "Minimal libc trivial reallocarray implementation" + default y + help + Enable the minimal libc's trivial implementation of reallocarray, which + forwards to realloc. + +config MINIMAL_LIBC_LL_PRINTF + bool "Build with minimal libc long long printf" if !64BIT + default y if 64BIT + help + Build with long long printf enabled. This will increase the size of + the image. + +config MINIMAL_LIBC_OPTIMIZE_STRING_FOR_SIZE + bool "Use size optimized string functions" + default y if SIZE_OPTIMIZATIONS + help + Enable smaller but potentially slower implementations of memcpy and + memset. On the Cortex-M0+ this reduces the total code size by 120 bytes. + +config MINIMAL_LIBC_RAND + bool "Rand and srand functions" + help + Enable rand_r() for the minimal libc. + + In order to make use of the non-reentrant rand() and srand(), it is + necessary to set CONFIG_MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS=y. + +config MINIMAL_LIBC_TIME + bool "Time functions" + default y + help + Enable time() and gmtime_r() for the minimal libc. + + time() requires CONFIG_POSIX_CLOCK=y because it relies on the POSIX + clock_gettime() function. + + In order to make use of the non-reentrant gmtime(), it is necessary + to set CONFIG_MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS=y. + +config MINIMAL_LIBC_STRING_ERROR_TABLE + bool "String error table for strerror() and strerror_r()" + help + Select this option to ensure that streror(), strerror_r() + produce strings corresponding to the descriptions in errno.h. + + The string error table can add ~2kiB to ROM. As such, it is + disabled by default. In this case, strerror() and strerror_r() + symbols are still present, but the functions produce an empty + string. + +endif # MINIMAL_LIBC