1# Copyright (c) 2020 Nordic Semiconductor ASA 2# SPDX-License-Identifier: Apache-2.0 3 4choice CBPRINTF_IMPLEMENTATION 5 prompt "Capabilities of cbprintf implementation" 6 default CBPRINTF_COMPLETE 7 8config CBPRINTF_COMPLETE 9 bool "All selected features" 10 help 11 Select this for an implementation that supports all potential 12 conversions, with Kconfig options to control availability at build 13 time. 14 15# 80: -53% / 982 B (80 / 00) 16config CBPRINTF_NANO 17 bool "Space-optimized but feature-limited" 18 # nano needs to count characters if it's the formatter for libc 19 imply CBPRINTF_LIBC_SUBSTS if MINIMAL_LIBC 20 help 21 If selected a completely different implementation of the core 22 formatting capability is substituted. This has a much smaller code 23 footprint, but provides fewer capabilities. 24 25endchoice # CBPRINTF_IMPLEMENTATION 26 27choice CBPRINTF_INTEGRAL_CONV 28 prompt "Control range of convertible integer values" 29 default CBPRINTF_FULL_INTEGRAL 30 31# 01: 0% / 0 B (01 / 00) 32config CBPRINTF_FULL_INTEGRAL 33 bool "Convert the full range of integer values" 34 select PICOLIBC_IO_LONG_LONG if PICOLIBC 35 help 36 Build cbprintf with buffers sized to support converting the full 37 range of all integral and pointer values. 38 39 Selecting this may increase code size on 32-bit systems as 40 GCC's __udivdi3 helper could end up being pulled into the 41 final binary. In any case, this will increase call stack size 42 by a few words. 43 44# 00: 45config CBPRINTF_REDUCED_INTEGRAL 46 bool "Convert only integer values that fit in 32 bits" 47 help 48 Build cbprintf with buffers sized to support converting integer 49 values with no more than 32 bits. 50 51 This will decrease stack space, but affects conversion of any type 52 with more than 32 bits. This includes not only intmax_t but any 53 type that can be converted to an integral representation including 54 size_t and pointers. 55 56 With CBPRINTF_COMPLETE conversions that may result in value-specific 57 truncation are not supported, and the generated text will be the 58 specification (e.g. %jd). 59 60 With CBPRINTF_NANO all conversions will be attempted but values that 61 cannot fit will be silently truncated. 62 63endchoice 64 65# 02: 82% / 1530 B (02 / 00) 66config CBPRINTF_FP_SUPPORT 67 bool "Floating point formatting in cbprintf" 68 default y if FPU 69 depends on CBPRINTF_COMPLETE 70 select PICOLIBC_IO_FLOAT if PICOLIBC 71 help 72 Build the cbprintf utility function with support for floating 73 point format specifiers. Selecting this increases stack size 74 requirements slightly, but increases code size significantly. 75 76# 04: 13% / 456 B (07 / 03) 77config CBPRINTF_FP_A_SUPPORT 78 bool "Floating point %a conversions" 79 depends on CBPRINTF_FULL_INTEGRAL 80 select CBPRINTF_FP_SUPPORT 81 help 82 The %a hexadecimal format for floating point value conversion was 83 added in C99, but the output is not easily understood so it rarely 84 appears in application code. 85 86 Selecting this adds support for the conversion, but increases the 87 overall code size related to FP support. 88 89# 40: -15% / -508 B (46 / 06) 90config CBPRINTF_FP_ALWAYS_A 91 bool "Select %a format for all floating point specifications" 92 select CBPRINTF_FP_A_SUPPORT 93 help 94 The %a format for floats requires significantly less code than the 95 standard decimal representations (%f, %e, %g). Selecting this 96 option implicitly uses %a (or %A) for all decimal floating 97 conversions. The precision of the original specification is 98 ignored. 99 100 Selecting this decreases code size when FP_SUPPORT is enabled. 101 102# 08: 3% / 60 B (08 / 00) 103config CBPRINTF_N_SPECIFIER 104 bool "Support %n specifications" 105 depends on CBPRINTF_COMPLETE 106 default y 107 help 108 If selected %n can be used to determine the number of characters 109 emitted. If enabled there is a small increase in code size. 110 111# 180: 18% / 138 B (180 / 80) [NANO] 112config CBPRINTF_LIBC_SUBSTS 113 bool "Generate C-library compatible functions using cbprintf" 114 help 115 If selected wrappers are generated for various C library functions 116 using the cbprintf formatter underneath. The wrappers use the C 117 library function name with a cb suffix; e.g. printfcb() or 118 vsnprintfcb(). 119 120 When used with CBPRINTF_NANO this increases the implementation code 121 size by a small amount. 122 123module = CBPRINTF_PACKAGE 124module-str = cbprintf_package 125source "subsys/logging/Kconfig.template.log_config" 126 127config CBPRINTF_PACKAGE_LONGDOUBLE 128 bool "Support packaging of long doubles" 129 help 130 Option impact required alignment for buffers used for packaging 131 (CBPRINTF_PACKAGE_ALIGNMENT). On most platforms long doubles 132 requires buffer to be 16 bytes aligned. Long doubles are rarely used 133 so such alignment is an unnecessary waste. If option is disabled, 134 then compilation fails if long double is used. 135 136config CBPRINTF_STATIC_PACKAGE_CHECK_ALIGNMENT 137 bool "Validate alignment of a static package buffer" 138 # To avoid self referential macro when printk is redirected to logging 139 depends on !LOG_PRINTK 140 help 141 When enabled, CBPRINTF_STATIC_PACKAGE asserts when buffer is not 142 properly aligned. If macro is widely used then assert may impact 143 memory footprint. 144 145config CBPRINTF_PACKAGE_HEADER_STORE_CREATION_FLAGS 146 bool 147 help 148 Enable this option to store the flags used to create the package 149 into the package itself. 150 151config CBPRINTF_PACKAGE_SUPPORT_TAGGED_ARGUMENTS 152 bool 153 depends on !PICOLIBC 154 select CBPRINTF_PACKAGE_HEADER_STORE_CREATION_FLAGS 155 help 156 Hidden option to support tagged arguments in cbvprint_package(). 157 If enabled and cbvprint_package() is called with the corresponding 158 flag, the packaging function no longer looks at the format strings 159 to determine the types of arguments, but instead, each argument is 160 tagged with a type by preceding it with another argument as type 161 (integer). 162