Skip to content

Commit 52c8878

Browse files
committed
[klibc] adjust rt_vsnprintf_std.c macros
1 parent 0856706 commit 52c8878

File tree

2 files changed

+176
-91
lines changed

2 files changed

+176
-91
lines changed

src/Kconfig

Lines changed: 106 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ config RT_USING_CPU_USAGE_TRACER
189189
default y if RT_USING_SMART
190190
default n
191191

192-
menu "kservice optimization"
192+
menu "kservice options"
193193
config RT_USING_TINY_FFS
194194
bool "Enable kservice to use tiny finding first bit set method"
195195
default n
196196
endmenu
197197

198-
menu "klibc optimization"
198+
menu "klibc options"
199199

200200
config RT_KLIBC_USING_STDLIB
201201
bool "Enable klibc to use standard C library"
@@ -213,28 +213,113 @@ menu "klibc optimization"
213213
bool "Enable tiny size of klibc"
214214
default n
215215

216-
choice
217-
prompt "rt_vsnprintf version"
218-
default RT_KLIBC_USING_VSNPRINTF_TINY if RT_KLIBC_USING_TINY_SIZE
219-
default RT_KLIBC_USING_VSNPRINTF_STANDARD
220-
221-
config RT_KLIBC_USING_VSNPRINTF_STANDARD
222-
bool "standard"
223-
help
224-
Standard version of rt_vsnprintf, which is full function but higher stack usage.
216+
menu "rt_vsnprintf options"
217+
choice
218+
prompt "rt_vsnprintf version"
219+
default RT_KLIBC_USING_VSNPRINTF_STANDARD if ARCH_CPU_64BIT
220+
default RT_KLIBC_USING_VSNPRINTF_TINY
221+
222+
config RT_KLIBC_USING_VSNPRINTF_STANDARD
223+
bool "standard"
224+
help
225+
Standard version of rt_vsnprintf, which is full function but higher stack usage.
226+
227+
config RT_KLIBC_USING_VSNPRINTF_TINY
228+
bool "tiny"
229+
help
230+
Tiny version of rt_vsnprintf, which is faster but lower stack usage.
231+
endchoice
225232

226-
config RT_KLIBC_USING_VSNPRINTF_TINY
227-
bool "tiny"
228-
help
229-
Tiny version of rt_vsnprintf, which is faster but lower stack usage.
230-
endchoice
233+
config RT_KLIBC_USING_VSNPRINTF_LONGLONG
234+
bool "Enable rt_vsnprintf function to support long-long format"
235+
default y if ARCH_CPU_64BIT || RT_KLIBC_USING_VSNPRINTF_STANDARD
236+
default n
237+
help
238+
Support for the long long integral types (with the ll, z and t length modifiers for specifiers
239+
%d,%i,%o,%x,%X,%u, and with the %p specifier). Note: 'L' (long double) is not supported.
240+
241+
if RT_KLIBC_USING_VSNPRINTF_STANDARD
242+
243+
config RT_KLIBC_USING_VSNPRINTF_DECIMAL_SPECIFIERS
244+
bool "Support decimal notation floating point conversion specifiers (%f, %F)"
245+
default y
246+
help
247+
Support for the decimal notation floating point conversion specifiers (%f, %F)
248+
249+
config RT_KLIBC_USING_VSNPRINTF_EXPONENTIAL_SPECIFIERS
250+
bool "Support exponential notation floating point conversion specifiers (%e, %g, %E, %G)"
251+
default y
252+
help
253+
Support for the exponential notation floating point conversion specifiers (%e, %g, %E, %G)
254+
255+
config RT_KLIBC_USING_VSNPRINTF_WRITEBACK_SPECIFIER
256+
bool "Support length write-back specifier (%n)"
257+
default y
258+
help
259+
Support for the length write-back specifier (%n)
260+
261+
config RT_KLIBC_USING_VSNPRINTF_CHECK_NUL_IN_FORMAT_SPECIFIER
262+
bool "safety check: no NULL end string"
263+
default y if RT_USING_DEBUG
264+
default n
265+
help
266+
Be extra-safe, and don't assume format specifiers are completed correctly
267+
before the format string end.
268+
269+
config RT_KLIBC_USING_VSNPRINTF_MSVC_STYLE_INTEGER_SPECIFIERS
270+
bool "Support MSVC style integer specifiers"
271+
default n
272+
help
273+
the integer format specifiers used in Microsoft's Visual C++ (MSVC) compiler.
274+
These specifiers, like %I64d for 64-bit integers, deviate slightly from the standard
275+
C format specifiers and are specific to MSVC. They allow for controlled formatting of
276+
integers in printf()-like functions, accommodating different integer sizes and ensuring
277+
compatibility with MSVC's environment. It's important to note that these specifiers might
278+
not be recognized or function in other compilers due to their MSVC-specific nature.
279+
280+
config RT_KLIBC_USING_VSNPRINTF_INTEGER_BUFFER_SIZE
281+
int "'ntoa' conversion buffer size"
282+
default 32
283+
help
284+
'ntoa' conversion buffer size, this must be big enough to hold one converted
285+
numeric number including padded zeros (dynamically created on stack)
286+
287+
config RT_KLIBC_USING_VSNPRINTF_DECIMAL_BUFFER_SIZE
288+
int "printing individual decimal numbers buffer size"
289+
default 32
290+
help
291+
size of the fixed (on-stack) buffer for printing individual decimal numbers.
292+
this must be big enough to hold one converted floating-point value including
293+
padded zeros.
294+
295+
config RT_KLIBC_USING_VSNPRINTF_FLOAT_PRECISION
296+
int "floating point conversion specifiers"
297+
default 6
298+
help
299+
Default precision for the floating point conversion specifiers (the C standard sets this at 6)
300+
301+
config RT_KLIBC_USING_VSNPRINTF_MAX_INTEGRAL_DIGITS_FOR_DECIMAL
302+
int "integral nums printed as float in rt_vsnprint"
303+
default 9
304+
help
305+
According to the C languages standard, printf() and related functions must be able to print any
306+
integral number in floating-point notation, regardless of length, when using the %f specifier -
307+
possibly hundreds of characters, potentially overflowing your buffers. In this implementation,
308+
all values beyond this threshold are switched to exponential notation.
309+
310+
config RT_KLIBC_USING_VSNPRINTF_LOG10_TAYLOR_TERMS
311+
int "the number of terms in a Taylor series expansion of log_10(x)"
312+
default 4
313+
range 2 99
314+
help
315+
The number of terms in a Taylor series expansion of log_10(x) to
316+
use for approximation - including the power-zero term (i.e. the
317+
value at the point of expansion).
231318

232-
config RT_KLIBC_USING_VSNPRINTF_LONGLONG
233-
bool "Enable rt_vsnprintf function to support long-long format"
234-
default y if ARCH_CPU_64BIT
235-
default n
319+
endif
320+
endmenu # rt_vsnprintf options
236321

237-
endmenu
322+
endmenu # klibc options
238323

239324
menuconfig RT_USING_DEBUG
240325
bool "Enable debugging features"

0 commit comments

Comments
 (0)