Skip to content

Commit 0b999c0

Browse files
nashifcarlescufi
authored andcommitted
lib: move utilities into own folder
Move various utilities out of lib into own folder for better assignement and management in the maintainer file. lib/os has become another dumping ground for everything and it the Kconfig and contents in that folder became difficult to manage, configure and test. Signed-off-by: Anas Nashif <[email protected]>
1 parent e710c9c commit 0b999c0

File tree

24 files changed

+112
-78
lines changed

24 files changed

+112
-78
lines changed

MAINTAINERS.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ JSON Web Token:
20662066
files:
20672067
- subsys/jwt/
20682068
- include/zephyr/data/
2069-
- lib/os/json.c
2069+
- lib/utils/json.c
20702070
- tests/subsys/jwt/
20712071
- tests/lib/json/
20722072
labels:
@@ -2125,8 +2125,15 @@ Kernel:
21252125

21262126
Utilities:
21272127
status: maintained
2128+
maintainers:
2129+
- andyross
2130+
- nashif
2131+
collaborators:
2132+
- dcpleung
2133+
- peter-mitsis
21282134
files:
21292135
- lib/crc/
2136+
- lib/utils/
21302137
- tests/unit/timeutil/
21312138
- tests/unit/time_units/
21322139
- tests/unit/rbtree/
@@ -2136,7 +2143,6 @@ Utilities:
21362143
- tests/unit/math_extras/
21372144
- tests/unit/list/
21382145
- tests/unit/intmath/
2139-
- tests/misc/print_format/
21402146
- tests/unit/pot/
21412147
- tests/lib/time/
21422148
- tests/lib/onoff/
@@ -2147,6 +2153,10 @@ Utilities:
21472153
- tests/lib/linear_range/
21482154
labels:
21492155
- "area: Utilities"
2156+
tests:
2157+
- utilities
2158+
- libraries.ring_buffer
2159+
- libraries.linear_range
21502160

21512161
Base OS:
21522162
status: maintained
@@ -2159,6 +2169,9 @@ Base OS:
21592169
files:
21602170
- include/zephyr/sys/
21612171
- lib/os/
2172+
- tests/misc/print_format/
2173+
- tests/lib/p4workq/
2174+
- tests/lib/fdtable/
21622175
files-exclude:
21632176
- include/zephyr/sys/cbprintf*
21642177
- tests/unit/cbprintf/
@@ -2171,6 +2184,8 @@ Base OS:
21712184
- lib/os/mpsc_pbuf.c
21722185
labels:
21732186
- "area: Base OS"
2187+
tests:
2188+
- printk
21742189

21752190
Heap Management:
21762191
status: maintained

lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ add_subdirectory(hash)
1313
add_subdirectory(heap)
1414
add_subdirectory(mem_blocks)
1515
add_subdirectory(os)
16+
add_subdirectory(utils)
1617
add_subdirectory_ifdef(CONFIG_SMF smf)
1718
add_subdirectory_ifdef(CONFIG_OPENAMP open-amp)
1819
add_subdirectory_ifdef(CONFIG_ACPI acpi)

lib/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ source "lib/smf/Kconfig"
2626
source "lib/acpi/Kconfig"
2727

2828
source "lib/runtime/Kconfig"
29+
30+
source "lib/utils/Kconfig"
2931
endmenu

lib/os/CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,14 @@ zephyr_syscall_header(
44
${ZEPHYR_BASE}/include/zephyr/sys/mutex.h
55
)
66

7-
zephyr_sources_ifdef(CONFIG_BASE64 base64.c)
8-
97
zephyr_sources(
108
cbprintf_packaged.c
11-
dec.c
12-
hex.c
139
printk.c
14-
rb.c
1510
sem.c
1611
thread_entry.c
17-
timeutil.c
18-
bitarray.c
1912
)
2013

2114
zephyr_sources_ifdef(CONFIG_FDTABLE fdtable.c)
22-
zephyr_sources_ifdef(CONFIG_ONOFF onoff.c)
23-
zephyr_sources_ifdef(CONFIG_NOTIFY notify.c)
2415

2516
zephyr_sources_ifdef(CONFIG_CBPRINTF_COMPLETE cbprintf_complete.c)
2617
zephyr_sources_ifdef(CONFIG_CBPRINTF_NANO cbprintf_nano.c)
@@ -29,10 +20,6 @@ if(NOT CONFIG_PICOLIBC)
2920
zephyr_sources(cbprintf.c)
3021
endif()
3122

32-
zephyr_sources_ifdef(CONFIG_JSON_LIBRARY json.c)
33-
34-
zephyr_sources_ifdef(CONFIG_RING_BUFFER ring_buffer.c)
35-
3623
if (CONFIG_ASSERT OR CONFIG_ASSERT_VERBOSE)
3724
zephyr_sources(assert.c)
3825
endif()
@@ -47,10 +34,6 @@ zephyr_sources_ifdef(CONFIG_SCHED_DEADLINE p4wq.c)
4734

4835
zephyr_sources_ifdef(CONFIG_REBOOT reboot.c)
4936

50-
zephyr_sources_ifdef(CONFIG_UTF8 utf8.c)
51-
52-
zephyr_sources_ifdef(CONFIG_WINSTREAM winstream.c)
53-
5437
zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c)
5538

5639
zephyr_library_include_directories(

lib/os/Kconfig

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,6 @@ config FDTABLE
1010
for any I/O object implementing POSIX I/O semantics (i.e. read/write +
1111
aux operations).
1212

13-
config JSON_LIBRARY
14-
bool "Build JSON library"
15-
help
16-
Build a minimal JSON parsing/encoding library. Used by sample
17-
applications such as the NATS client.
18-
19-
config RING_BUFFER
20-
bool "Ring buffers"
21-
help
22-
Enable usage of ring buffers. This is similar to kernel FIFOs but ring
23-
buffers manage their own buffer memory and can store arbitrary data.
24-
For optimal performance, use buffer sizes that are a power of 2.
25-
26-
config NOTIFY
27-
bool "Asynchronous Notifications"
28-
help
29-
Use this API to support async transactions.
30-
31-
config BASE64
32-
bool "Base64 encoding and decoding"
33-
help
34-
Enable base64 encoding and decoding functionality
35-
3613
config PRINTK_SYNC
3714
bool "Serialize printk() calls"
3815
default y if SMP && MP_MAX_NUM_CPUS > 1 && !(EFI_CONSOLE && LOG)
@@ -50,14 +27,6 @@ config MPSC_PBUF
5027
storing variable length packets in a circular way and operate directly
5128
on the buffer memory.
5229

53-
config ONOFF
54-
bool "On-Off Manager"
55-
select NOTIFY
56-
help
57-
An on-off manager supports an arbitrary number of clients of a
58-
service which has a binary state. Example applications are power
59-
rails, clocks, and binary device power management.
60-
6130
config SPSC_PBUF
6231
bool "Single producer, single consumer packet buffer"
6332
help
@@ -119,23 +88,6 @@ config SPSC_PBUF_UTILIZATION
11988

12089
endif # SPSC_PBUF
12190

122-
config WINSTREAM
123-
bool "Lockless shared memory window byte stream"
124-
help
125-
Winstream is a byte stream IPC for use in shared memory
126-
"windows", generally for transmit to non-Zephyr contexts that
127-
can't share Zephyr APIs or data structures.
128-
129-
if WINSTREAM
130-
config WINSTREAM_STDLIB_MEMCOPY
131-
bool "Use standard memcpy() in winstream"
132-
help
133-
The sys_winstream utility is sometimes used in early boot
134-
environments before the standard library is usable. By
135-
default it uses a simple internal bytewise memcpy(). Set
136-
this to use the one from the standard library.
137-
endif
138-
13991
if MPSC_PBUF
14092
config MPSC_CLEAR_ALLOCATED
14193
bool "Clear allocated packet"
@@ -161,12 +113,6 @@ config POWEROFF
161113
help
162114
Enable support for system power off.
163115

164-
config UTF8
165-
bool "UTF-8 string operation supported"
166-
help
167-
Enable the utf8 API. The API implements functions to specifically
168-
handle UTF-8 encoded strings.
169-
170116
rsource "Kconfig.cbprintf"
171117

172118
endmenu

lib/utils/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_sources_ifdef(CONFIG_BASE64 base64.c)
4+
5+
zephyr_sources(
6+
dec.c
7+
hex.c
8+
rb.c
9+
timeutil.c
10+
bitarray.c
11+
)
12+
13+
zephyr_sources_ifdef(CONFIG_ONOFF onoff.c)
14+
zephyr_sources_ifdef(CONFIG_NOTIFY notify.c)
15+
16+
zephyr_sources_ifdef(CONFIG_JSON_LIBRARY json.c)
17+
18+
zephyr_sources_ifdef(CONFIG_RING_BUFFER ring_buffer.c)
19+
20+
zephyr_sources_ifdef(CONFIG_UTF8 utf8.c)
21+
22+
zephyr_sources_ifdef(CONFIG_WINSTREAM winstream.c)
23+
24+
zephyr_library_include_directories(
25+
${ZEPHYR_BASE}/kernel/include
26+
${ZEPHYR_BASE}/arch/${ARCH}/include
27+
)

lib/utils/Kconfig

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (c) 2016 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
menu "Utility Library"
5+
6+
config JSON_LIBRARY
7+
bool "Build JSON library"
8+
help
9+
Build a minimal JSON parsing/encoding library. Used by sample
10+
applications such as the NATS client.
11+
12+
config RING_BUFFER
13+
bool "Ring buffers"
14+
help
15+
Enable usage of ring buffers. This is similar to kernel FIFOs but ring
16+
buffers manage their own buffer memory and can store arbitrary data.
17+
For optimal performance, use buffer sizes that are a power of 2.
18+
19+
config NOTIFY
20+
bool "Asynchronous Notifications"
21+
help
22+
Use this API to support async transactions.
23+
24+
config BASE64
25+
bool "Base64 encoding and decoding"
26+
help
27+
Enable base64 encoding and decoding functionality
28+
29+
config ONOFF
30+
bool "On-Off Manager"
31+
select NOTIFY
32+
help
33+
An on-off manager supports an arbitrary number of clients of a
34+
service which has a binary state. Example applications are power
35+
rails, clocks, and binary device power management.
36+
37+
config WINSTREAM
38+
bool "Lockless shared memory window byte stream"
39+
help
40+
Winstream is a byte stream IPC for use in shared memory
41+
"windows", generally for transmit to non-Zephyr contexts that
42+
can't share Zephyr APIs or data structures.
43+
44+
if WINSTREAM
45+
config WINSTREAM_STDLIB_MEMCOPY
46+
bool "Use standard memcpy() in winstream"
47+
help
48+
The sys_winstream utility is sometimes used in early boot
49+
environments before the standard library is usable. By
50+
default it uses a simple internal bytewise memcpy(). Set
51+
this to use the one from the standard library.
52+
endif
53+
54+
config UTF8
55+
bool "UTF-8 string operation supported"
56+
help
57+
Enable the utf8 API. The API implements functions to specifically
58+
handle UTF-8 encoded strings.
59+
60+
endmenu
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)