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 <anas.nashif@intel.com>
This commit is contained in:
parent
e710c9ce9e
commit
0b999c0943
|
@ -2066,7 +2066,7 @@ JSON Web Token:
|
|||
files:
|
||||
- subsys/jwt/
|
||||
- include/zephyr/data/
|
||||
- lib/os/json.c
|
||||
- lib/utils/json.c
|
||||
- tests/subsys/jwt/
|
||||
- tests/lib/json/
|
||||
labels:
|
||||
|
@ -2125,8 +2125,15 @@ Kernel:
|
|||
|
||||
Utilities:
|
||||
status: maintained
|
||||
maintainers:
|
||||
- andyross
|
||||
- nashif
|
||||
collaborators:
|
||||
- dcpleung
|
||||
- peter-mitsis
|
||||
files:
|
||||
- lib/crc/
|
||||
- lib/utils/
|
||||
- tests/unit/timeutil/
|
||||
- tests/unit/time_units/
|
||||
- tests/unit/rbtree/
|
||||
|
@ -2136,7 +2143,6 @@ Utilities:
|
|||
- tests/unit/math_extras/
|
||||
- tests/unit/list/
|
||||
- tests/unit/intmath/
|
||||
- tests/misc/print_format/
|
||||
- tests/unit/pot/
|
||||
- tests/lib/time/
|
||||
- tests/lib/onoff/
|
||||
|
@ -2147,6 +2153,10 @@ Utilities:
|
|||
- tests/lib/linear_range/
|
||||
labels:
|
||||
- "area: Utilities"
|
||||
tests:
|
||||
- utilities
|
||||
- libraries.ring_buffer
|
||||
- libraries.linear_range
|
||||
|
||||
Base OS:
|
||||
status: maintained
|
||||
|
@ -2159,6 +2169,9 @@ Base OS:
|
|||
files:
|
||||
- include/zephyr/sys/
|
||||
- lib/os/
|
||||
- tests/misc/print_format/
|
||||
- tests/lib/p4workq/
|
||||
- tests/lib/fdtable/
|
||||
files-exclude:
|
||||
- include/zephyr/sys/cbprintf*
|
||||
- tests/unit/cbprintf/
|
||||
|
@ -2171,6 +2184,8 @@ Base OS:
|
|||
- lib/os/mpsc_pbuf.c
|
||||
labels:
|
||||
- "area: Base OS"
|
||||
tests:
|
||||
- printk
|
||||
|
||||
Heap Management:
|
||||
status: maintained
|
||||
|
|
|
@ -13,6 +13,7 @@ add_subdirectory(hash)
|
|||
add_subdirectory(heap)
|
||||
add_subdirectory(mem_blocks)
|
||||
add_subdirectory(os)
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory_ifdef(CONFIG_SMF smf)
|
||||
add_subdirectory_ifdef(CONFIG_OPENAMP open-amp)
|
||||
add_subdirectory_ifdef(CONFIG_ACPI acpi)
|
||||
|
|
|
@ -26,4 +26,6 @@ source "lib/smf/Kconfig"
|
|||
source "lib/acpi/Kconfig"
|
||||
|
||||
source "lib/runtime/Kconfig"
|
||||
|
||||
source "lib/utils/Kconfig"
|
||||
endmenu
|
||||
|
|
|
@ -4,23 +4,14 @@ zephyr_syscall_header(
|
|||
${ZEPHYR_BASE}/include/zephyr/sys/mutex.h
|
||||
)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_BASE64 base64.c)
|
||||
|
||||
zephyr_sources(
|
||||
cbprintf_packaged.c
|
||||
dec.c
|
||||
hex.c
|
||||
printk.c
|
||||
rb.c
|
||||
sem.c
|
||||
thread_entry.c
|
||||
timeutil.c
|
||||
bitarray.c
|
||||
)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_FDTABLE fdtable.c)
|
||||
zephyr_sources_ifdef(CONFIG_ONOFF onoff.c)
|
||||
zephyr_sources_ifdef(CONFIG_NOTIFY notify.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_CBPRINTF_COMPLETE cbprintf_complete.c)
|
||||
zephyr_sources_ifdef(CONFIG_CBPRINTF_NANO cbprintf_nano.c)
|
||||
|
@ -29,10 +20,6 @@ if(NOT CONFIG_PICOLIBC)
|
|||
zephyr_sources(cbprintf.c)
|
||||
endif()
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_JSON_LIBRARY json.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_RING_BUFFER ring_buffer.c)
|
||||
|
||||
if (CONFIG_ASSERT OR CONFIG_ASSERT_VERBOSE)
|
||||
zephyr_sources(assert.c)
|
||||
endif()
|
||||
|
@ -47,10 +34,6 @@ zephyr_sources_ifdef(CONFIG_SCHED_DEADLINE p4wq.c)
|
|||
|
||||
zephyr_sources_ifdef(CONFIG_REBOOT reboot.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_UTF8 utf8.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_WINSTREAM winstream.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c)
|
||||
|
||||
zephyr_library_include_directories(
|
||||
|
|
|
@ -10,29 +10,6 @@ config FDTABLE
|
|||
for any I/O object implementing POSIX I/O semantics (i.e. read/write +
|
||||
aux operations).
|
||||
|
||||
config JSON_LIBRARY
|
||||
bool "Build JSON library"
|
||||
help
|
||||
Build a minimal JSON parsing/encoding library. Used by sample
|
||||
applications such as the NATS client.
|
||||
|
||||
config RING_BUFFER
|
||||
bool "Ring buffers"
|
||||
help
|
||||
Enable usage of ring buffers. This is similar to kernel FIFOs but ring
|
||||
buffers manage their own buffer memory and can store arbitrary data.
|
||||
For optimal performance, use buffer sizes that are a power of 2.
|
||||
|
||||
config NOTIFY
|
||||
bool "Asynchronous Notifications"
|
||||
help
|
||||
Use this API to support async transactions.
|
||||
|
||||
config BASE64
|
||||
bool "Base64 encoding and decoding"
|
||||
help
|
||||
Enable base64 encoding and decoding functionality
|
||||
|
||||
config PRINTK_SYNC
|
||||
bool "Serialize printk() calls"
|
||||
default y if SMP && MP_MAX_NUM_CPUS > 1 && !(EFI_CONSOLE && LOG)
|
||||
|
@ -50,14 +27,6 @@ config MPSC_PBUF
|
|||
storing variable length packets in a circular way and operate directly
|
||||
on the buffer memory.
|
||||
|
||||
config ONOFF
|
||||
bool "On-Off Manager"
|
||||
select NOTIFY
|
||||
help
|
||||
An on-off manager supports an arbitrary number of clients of a
|
||||
service which has a binary state. Example applications are power
|
||||
rails, clocks, and binary device power management.
|
||||
|
||||
config SPSC_PBUF
|
||||
bool "Single producer, single consumer packet buffer"
|
||||
help
|
||||
|
@ -119,23 +88,6 @@ config SPSC_PBUF_UTILIZATION
|
|||
|
||||
endif # SPSC_PBUF
|
||||
|
||||
config WINSTREAM
|
||||
bool "Lockless shared memory window byte stream"
|
||||
help
|
||||
Winstream is a byte stream IPC for use in shared memory
|
||||
"windows", generally for transmit to non-Zephyr contexts that
|
||||
can't share Zephyr APIs or data structures.
|
||||
|
||||
if WINSTREAM
|
||||
config WINSTREAM_STDLIB_MEMCOPY
|
||||
bool "Use standard memcpy() in winstream"
|
||||
help
|
||||
The sys_winstream utility is sometimes used in early boot
|
||||
environments before the standard library is usable. By
|
||||
default it uses a simple internal bytewise memcpy(). Set
|
||||
this to use the one from the standard library.
|
||||
endif
|
||||
|
||||
if MPSC_PBUF
|
||||
config MPSC_CLEAR_ALLOCATED
|
||||
bool "Clear allocated packet"
|
||||
|
@ -161,12 +113,6 @@ config POWEROFF
|
|||
help
|
||||
Enable support for system power off.
|
||||
|
||||
config UTF8
|
||||
bool "UTF-8 string operation supported"
|
||||
help
|
||||
Enable the utf8 API. The API implements functions to specifically
|
||||
handle UTF-8 encoded strings.
|
||||
|
||||
rsource "Kconfig.cbprintf"
|
||||
|
||||
endmenu
|
||||
|
|
27
lib/utils/CMakeLists.txt
Normal file
27
lib/utils/CMakeLists.txt
Normal file
|
@ -0,0 +1,27 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_BASE64 base64.c)
|
||||
|
||||
zephyr_sources(
|
||||
dec.c
|
||||
hex.c
|
||||
rb.c
|
||||
timeutil.c
|
||||
bitarray.c
|
||||
)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_ONOFF onoff.c)
|
||||
zephyr_sources_ifdef(CONFIG_NOTIFY notify.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_JSON_LIBRARY json.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_RING_BUFFER ring_buffer.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_UTF8 utf8.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_WINSTREAM winstream.c)
|
||||
|
||||
zephyr_library_include_directories(
|
||||
${ZEPHYR_BASE}/kernel/include
|
||||
${ZEPHYR_BASE}/arch/${ARCH}/include
|
||||
)
|
60
lib/utils/Kconfig
Normal file
60
lib/utils/Kconfig
Normal file
|
@ -0,0 +1,60 @@
|
|||
# Copyright (c) 2016 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menu "Utility Library"
|
||||
|
||||
config JSON_LIBRARY
|
||||
bool "Build JSON library"
|
||||
help
|
||||
Build a minimal JSON parsing/encoding library. Used by sample
|
||||
applications such as the NATS client.
|
||||
|
||||
config RING_BUFFER
|
||||
bool "Ring buffers"
|
||||
help
|
||||
Enable usage of ring buffers. This is similar to kernel FIFOs but ring
|
||||
buffers manage their own buffer memory and can store arbitrary data.
|
||||
For optimal performance, use buffer sizes that are a power of 2.
|
||||
|
||||
config NOTIFY
|
||||
bool "Asynchronous Notifications"
|
||||
help
|
||||
Use this API to support async transactions.
|
||||
|
||||
config BASE64
|
||||
bool "Base64 encoding and decoding"
|
||||
help
|
||||
Enable base64 encoding and decoding functionality
|
||||
|
||||
config ONOFF
|
||||
bool "On-Off Manager"
|
||||
select NOTIFY
|
||||
help
|
||||
An on-off manager supports an arbitrary number of clients of a
|
||||
service which has a binary state. Example applications are power
|
||||
rails, clocks, and binary device power management.
|
||||
|
||||
config WINSTREAM
|
||||
bool "Lockless shared memory window byte stream"
|
||||
help
|
||||
Winstream is a byte stream IPC for use in shared memory
|
||||
"windows", generally for transmit to non-Zephyr contexts that
|
||||
can't share Zephyr APIs or data structures.
|
||||
|
||||
if WINSTREAM
|
||||
config WINSTREAM_STDLIB_MEMCOPY
|
||||
bool "Use standard memcpy() in winstream"
|
||||
help
|
||||
The sys_winstream utility is sometimes used in early boot
|
||||
environments before the standard library is usable. By
|
||||
default it uses a simple internal bytewise memcpy(). Set
|
||||
this to use the one from the standard library.
|
||||
endif
|
||||
|
||||
config UTF8
|
||||
bool "UTF-8 string operation supported"
|
||||
help
|
||||
Enable the utf8 API. The API implements functions to specifically
|
||||
handle UTF-8 encoded strings.
|
||||
|
||||
endmenu
|
|
@ -27,7 +27,7 @@
|
|||
#include <zephyr/sys/base64.h>
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
#include "../../../lib/os/base64.c"
|
||||
#include "../../../lib/utils/base64.c"
|
||||
|
||||
static const unsigned char base64_test_dec[64] = {
|
||||
0x24, 0x48, 0x6E, 0x56, 0x87, 0x62, 0x5A, 0xBD,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <zephyr/ztest.h>
|
||||
#include <zephyr/sys/rb.h>
|
||||
|
||||
#include "../../../lib/os/rb.c"
|
||||
#include "../../../lib/utils/rb.c"
|
||||
|
||||
#define _CHECK(n) \
|
||||
zassert_true(!!(n), "Tree check failed: [ " #n " ] @%d", __LINE__)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <zephyr/ztest.h>
|
||||
#include "timeutil_test.h"
|
||||
#include "../../../lib/os/timeutil.c"
|
||||
#include "../../../lib/utils/timeutil.c"
|
||||
|
||||
void timeutil_check(const struct timeutil_test_data *tp,
|
||||
size_t count)
|
||||
|
|
|
@ -4,4 +4,4 @@ cmake_minimum_required(VERSION 3.20.0)
|
|||
|
||||
project(util)
|
||||
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
target_sources(testbinary PRIVATE main.c maincxx.cxx ${ZEPHYR_BASE}/lib/os/dec.c)
|
||||
target_sources(testbinary PRIVATE main.c maincxx.cxx ${ZEPHYR_BASE}/lib/utils/dec.c)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
/* This, uh, seems to be the standard way to unit test library code.
|
||||
* Or so I gather from tests/unit/rbtree ...
|
||||
*/
|
||||
#include "../../../lib/os/winstream.c"
|
||||
#include "../../../lib/utils/winstream.c"
|
||||
|
||||
#define BUFLEN 64
|
||||
|
||||
|
|
Loading…
Reference in a new issue