Skip to content

Commit ed8f683

Browse files
committed
libs/libc/time: Add configuration options for the strftime
This adds 3 configuration options for the lib_strftime, which can be used to save flash memory when all the formatters are not needed by an embedded application. There is always a minimal set of formatters supported: "%a, %b/%h, %d, %H, %m, %M, %S, %Y, %%". To add on top of that one can specify: - LIBC_STRFTIME_C_STANDARD_FORMATS : All ISO-C conversion specifiers - LIBC_STRFTIME_POSIX_FORMATS : Additional posix formats - LIBC_STRFTIME_NONSTANDARD_FORMATS : Additional GNU nonstandard formats All of these are enabled by default unless building for CONFIG_DEFAULT_SMALL. Disabling these options can save over 3KB of flash on an 32-bit ARM system, when all the format specifiers are not needed. Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
1 parent efaebbb commit ed8f683

2 files changed

Lines changed: 261 additions & 196 deletions

File tree

libs/libc/time/Kconfig

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,44 @@
55

66
menu "Time/Time Zone Support"
77

8+
config LIBC_STRFTIME_C_STANDARD_FORMATS
9+
bool "strftime ISO C conversion specifiers"
10+
default n if DEFAULT_SMALL
11+
default y
12+
---help---
13+
Enable ISO C strftime conversion specifiers that are not part of
14+
the small always-enabled subset. Disabling this option
15+
removes support for %A, %B, %I, %j, %p, %U, %w, %W, %x, %X, and
16+
%y. The always-enabled subset is %a, %b/%h, %d, %H, %m, %M,
17+
%S, %Y, and %%.
18+
19+
Disabling this option makes strftime smaller, but the implementation
20+
no longer supports all conversion specifiers required by ISO C.
21+
22+
config LIBC_STRFTIME_POSIX_FORMATS
23+
bool "strftime POSIX conversion specifiers"
24+
default n if DEFAULT_SMALL
25+
default y
26+
select LIBC_STRFTIME_C_STANDARD_FORMATS
27+
---help---
28+
Enable POSIX strftime conversion specifiers beyond ISO C that are
29+
implemented by NuttX. Disabling this option removes support for
30+
%C, %e, %F, %g, %G, %n, %r, %R, %t, %T, %u, %V, and %z.
31+
Enabling this option also enables the ISO C conversion specifiers.
32+
33+
Note that %h is kept in the always-enabled subset as an alias for
34+
%b because it shares the same implementation. Some POSIX
35+
specifiers may be controlled by other options.
36+
37+
config LIBC_STRFTIME_NONSTANDARD_FORMATS
38+
bool "strftime non-standard conversion specifiers"
39+
default n if DEFAULT_SMALL
40+
default y
41+
---help---
42+
Enable NuttX/GNU-style strftime conversion specifiers that are not
43+
required by ISO C or POSIX. Disabling this option removes support
44+
for %k, %l, %P, and %s.
45+
846
config LIBC_LOCALTIME
947
bool "localtime API call support"
1048
default "n"

0 commit comments

Comments
 (0)