1# Copyright © 2021 Amazon.com, Inc. or its affiliates.
2# SPDX-License-Identifier: Apache-2.0
3
4if PICOLIBC
5
6config PICOLIBC_USE_MODULE
7	bool "Picolibc as module"
8	default y if "$(ZEPHYR_TOOLCHAIN_VARIANT)" != "zephyr"
9	depends on ZEPHYR_PICOLIBC_MODULE
10	depends on !GLIBCXX_LIBCPP
11	help
12	  Use picolibc module instead of picolibc included with toolchain.
13	  This is enabled by default for toolchains other than the Zephyr
14	  SDK.
15
16config PICOLIBC_HEAP_SIZE
17	int "[DEPRECATED] Picolibc heap size (bytes)"
18	default -2
19	help
20	  [DEPRECATED] Use COMMON_LIBC_MALLOC_ARENA_SIZE
21
22	  Indicate the size in bytes of the memory arena used for common C
23	  library malloc() implementation when using Picolibc.
24
25	  If set to -2, then the value of COMMON_LIBC_MALLOC_ARENA_SIZE
26	  will be used.
27
28config PICOLIBC_IO_LONG_LONG
29	bool "support for long long in integer-only printf/scanf"
30	help
31	  Includes support for long long in integer-only printf/scanf. long long
32	  types are always supported in the floating-point versions.
33
34config PICOLIBC_IO_FLOAT
35	bool "support for floating point values in printf/scanf"
36	help
37	  Include floating point support in printf/scanf functions.
38
39if PICOLIBC_USE_MODULE
40
41choice PICOLIBC_OPTIMIZATIONS
42	prompt "Optimization level"
43	default PICOLIBC_SIZE_OPTIMIZATIONS if SIZE_OPTIMIZATIONS
44	default PICOLIBC_SPEED_OPTIMIZATIONS if SPEED_OPTIMIZATIONS
45	default PICOLIBC_DEBUG_OPTIMIZATIONS if DEBUG_OPTIMIZATIONS
46	default PICOLIBC_NO_OPTIMIZATIONS if NO_OPTIMIZATIONS
47	help
48	  Note that these flags shall only control the compiler
49	  optimization level for picolibc, not the level for the
50	  rest of Zephyr
51
52config PICOLIBC_SIZE_OPTIMIZATIONS
53	bool "Optimize for size"
54	help
55	  Compiler optimizations will be set to -Os independently of other
56	  options.
57
58config PICOLIBC_SPEED_OPTIMIZATIONS
59	bool "Optimize for speed"
60	help
61	  Compiler optimizations will be set to -O2 independently of other
62	  options.
63
64config PICOLIBC_DEBUG_OPTIMIZATIONS
65	bool "Optimize debugging experience"
66	help
67	  Compiler optimizations will be set to -Og independently of other
68	  options.
69
70config PICOLIBC_NO_OPTIMIZATIONS
71	bool "Optimize nothing"
72	help
73	  Compiler optimizations will be set to -O0 independently of other
74	  options.
75
76endchoice
77
78config PICOLIBC_FAST_STRCMP
79	bool "always use fast strcmp paths"
80	default y
81	help
82	  This provides a faster strcmp version even when libc is
83	  built in space-optimized mode
84
85config PICOLIBC_IO_C99_FORMATS
86	bool "support C99 format additions in printf/scanf"
87	default y
88	help
89	  Includes support for hex floats (in floating-point version) and j, z,
90	  t size modifiers.
91
92config PICOLIBC_IO_POS_ARGS
93	bool "Support POSIX positional args (e.g. %$1d) in printf/scanf"
94	default y
95	depends on !PICOLIBC_IO_FLOAT
96	help
97	  Includes support for positional args (e.g. $1) in integer-only printf
98	  and scanf. Positional args are always supported in the floating-point
99	  versions.
100
101config PICOLIBC_IO_FLOAT_EXACT
102	bool "support for exact float/string conversion"
103	default y
104	help
105	  Uses Ryu algorithm for exact binary/decimal float conversions.
106	  This ensures that printf values with enough digits can be
107	  fed to scanf and generate exactly the same binary value.
108
109config PICOLIBC_LOCALE_INFO
110	bool "support locales in libc functions"
111	help
112	  Includes code for basic locale support
113
114config PICOLIBC_LOCALE_EXTENDED_INFO
115	bool "support extended locales in libc functions"
116	help
117	  Includes code for extended locale support
118
119config PICOLIBC_MULTIBYTE
120	bool "support multibyte functions in libc"
121	help
122	  Includes code for multi-byte characters
123
124config PICOLIBC_PICOEXIT
125	bool "use smaller atexit/onexit implementation"
126	default y
127	help
128	  Provides a simpler atexit/onexit implementation that doesn't use
129	  malloc, but only supports a small number (32) of exit handlers.
130
131config PICOLIBC_MULTITHREAD
132	bool "support multiple threads using retargetable locking API"
133	default y
134	help
135	  Protects shared data structures in libc with mutexes that use
136	  an API which can be retargeted to OS provided routines.
137
138config PICOLIBC_GLOBAL_ERRNO
139	bool "use a single global variable for errno"
140	help
141	  Picolibc usually uses a TLS variable for errno, ensuring that
142	  multiple threads have a reliable mechanism for detecting libc
143	  exceptions. This option switches to a single global errno variable,
144	  which can be used to avoid TLS variable usage by the library if
145	  necessary.
146
147endif # PICOLIBC_USE_MODULE
148
149endif # PICOLIBC
150