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_MINIMAL_LONG_LONG if PICOLIBC_IO_MINIMAL && PICOLIBC_USE_MODULE 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 help 71 Build the cbprintf utility function with support for floating 72 point format specifiers. Selecting this increases stack size 73 requirements slightly, but increases code size significantly. 74 75# 04: 13% / 456 B (07 / 03) 76config CBPRINTF_FP_A_SUPPORT 77 bool "Floating point %a conversions" 78 depends on CBPRINTF_FULL_INTEGRAL 79 select CBPRINTF_FP_SUPPORT 80 help 81 The %a hexadecimal format for floating point value conversion was 82 added in C99, but the output is not easily understood so it rarely 83 appears in application code. 84 85 Selecting this adds support for the conversion, but increases the 86 overall code size related to FP support. 87 88# 40: -15% / -508 B (46 / 06) 89config CBPRINTF_FP_ALWAYS_A 90 bool "Select %a format for all floating point specifications" 91 select CBPRINTF_FP_A_SUPPORT 92 depends on !PICOLIBC 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 depends on !PICOLIBC 107 default y 108 help 109 If selected %n can be used to determine the number of characters 110 emitted. If enabled there is a small increase in code size. 111 Picolibc does not support this feature for security reasons. 112 113# 180: 18% / 138 B (180 / 80) [NANO] 114config CBPRINTF_LIBC_SUBSTS 115 bool "Generate C-library compatible functions using cbprintf" 116 help 117 If selected wrappers are generated for various C library functions 118 using the cbprintf formatter underneath. The wrappers use the C 119 library function name with a cb suffix; e.g. printfcb() or 120 vsnprintfcb(). 121 122 When used with CBPRINTF_NANO this increases the implementation code 123 size by a small amount. 124 125 When used with picolibc, this option generates cbprintf-compatible 126 functions using stdio, effectively inverting the sense above. 127 128module = CBPRINTF_PACKAGE 129module-str = cbprintf_package 130source "subsys/logging/Kconfig.template.log_config" 131 132config CBPRINTF_PACKAGE_LONGDOUBLE 133 bool "Support packaging of long doubles" 134 help 135 Option impact required alignment for buffers used for packaging 136 (CBPRINTF_PACKAGE_ALIGNMENT). On most platforms long doubles 137 requires buffer to be 16 bytes aligned. Long doubles are rarely used 138 so such alignment is an unnecessary waste. If option is disabled, 139 then compilation fails if long double is used. 140 141config CBPRINTF_STATIC_PACKAGE_CHECK_ALIGNMENT 142 bool "Validate alignment of a static package buffer" 143 # To avoid self referential macro when printk is redirected to logging 144 depends on !LOG_PRINTK 145 help 146 When enabled, CBPRINTF_STATIC_PACKAGE asserts when buffer is not 147 properly aligned. If macro is widely used then assert may impact 148 memory footprint. 149 150config CBPRINTF_PACKAGE_HEADER_STORE_CREATION_FLAGS 151 bool 152 help 153 Enable this option to store the flags used to create the package 154 into the package itself. 155 156config CBPRINTF_PACKAGE_SUPPORT_TAGGED_ARGUMENTS 157 bool 158 depends on !PICOLIBC 159 select CBPRINTF_PACKAGE_HEADER_STORE_CREATION_FLAGS 160 help 161 Hidden option to support tagged arguments in cbvprint_package(). 162 If enabled and cbvprint_package() is called with the corresponding 163 flag, the packaging function no longer looks at the format strings 164 to determine the types of arguments, but instead, each argument is 165 tagged with a type by preceding it with another argument as type 166 (integer). 167 168config CBPRINTF_CONVERT_CHECK_PTR 169 bool 170 default y if !LOG_FMT_SECTION_STRIP 171 help 172 If enabled, cbprintf_package_convert() supports checking if string 173 candidate is used for %p format specifier. Check cannot be performed 174 if string is not present in the memory. 175