Skip to content

Commit 1aea601

Browse files
committed
Merge branch 'develop'
2 parents 465b2fb + c7fe6fd commit 1aea601

File tree

21 files changed

+362
-120
lines changed

21 files changed

+362
-120
lines changed

.clang-tidy

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
Checks: "*,
3+
-abseil-*,
4+
-altera-*,
5+
-android-*,
6+
-fuchsia-*,
7+
-google-*,
8+
-llvm*,
9+
-modernize-use-trailing-return-type,
10+
-zircon-*,
11+
-readability-else-after-return,
12+
-readability-static-accessed-through-instance,
13+
-readability-avoid-const-params-in-decls,
14+
-cppcoreguidelines-non-private-member-variables-in-classes,
15+
-misc-non-private-member-variables-in-classes,
16+
"
17+
WarningsAsErrors: ''
18+
HeaderFilterRegex: ''
19+
FormatStyle: none

.readthedocs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
build:
3+
os: ubuntu-22.04
4+
tools:
5+
python: "3.11"
6+
7+
# Build documentation in the docs/ directory with Sphinx
8+
sphinx:
9+
configuration: docs/conf.py
10+
11+
# Python configuration
12+
python:
13+
install:
14+
- requirements: docs/requirements.txt
15+
16+
formats:
17+
- pdf
18+
- epub

AUTHORS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Tilen Majerle <[email protected]>
2+
Tilen Majerle <[email protected]>
3+
Jaedeok Kim <[email protected]>
4+
Thomas Devoogdt <[email protected]>
5+
LinJieqiang <[email protected]>
6+
7+
Junde Yhi <[email protected]>
8+
Jackistang <[email protected]>
9+
Tofik Sonono <[email protected]>

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22

33
## Develop
44

5+
## v3.1.0
6+
7+
- Preparation for `v3.1`
8+
- Replace `size_t` with custom defined type `lwrb_sz_t` which matches atomicity requirements
9+
- `lwrb_sz_t` is by default typedef-ed as `unsigned long`
10+
- Prepare `lwrb_write_ex` and `lwrb_read_ex` functions
11+
- Implement `lwrb_write_ex` and `lwrb_read_ex` functions
12+
- Fix `_ex` module throwing an error for Platform.IO
13+
514
## v3.0.0
615

716
- Added macros for optional STDATOMIC. Global `-DLWRB_DISABLE_ATOMIC` macro will disable C11 `<stdatomic.h>` functionality.
817
- Add `lwrb_move` and `lwrb_overwrite`
918
- Fix `lwrb_find` which failed to properly search for tokens at corner cases
1019

11-
## v3.0.0-RC1
20+
## v3.1.0-RC1
1221

1322
- Split CMakeLists.txt files between library and executable
1423
- Change license year to 2022

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ else()
2424
WIN32
2525
_DEBUG
2626
CONSOLE
27-
LWRB_DEV
2827
)
2928

3029
# Compiler options
@@ -35,6 +34,7 @@ else()
3534
)
3635

3736
# Add subdir with lwrb and link to project
37+
set(LWRB_COMPILE_DEFINITIONS LWRB_DEV)
3838
add_subdirectory(lwrb)
3939
target_link_libraries(${PROJECT_NAME} lwrb)
4040
target_link_libraries(${PROJECT_NAME} lwrb_ex)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ Library provides generic FIFO ring buffer implementation.
1313
* Uses optimized memory copy instead of loops to read/write data from/to memory
1414
* Thread safe when used as pipe with single write and single read entries - when CPU read/write operation for `size_t` are single instruction (ARM Cortex-M for instance)
1515
* Interrupt safe when used as pipe with single write and single read entries - when CPU read/write operation for `size_t` are single instruction (ARM Cortex-M for instance)
16-
* For CPU systems with smaller achitecture than `sizeof(size_t)` (AVR for instance), atomic protection is required for read-write operation of buffer writes
16+
* For CPU systems with smaller architecture than `sizeof(size_t)` (AVR for instance), atomic protection is required for read-write operation of buffer writes
1717
* Suitable for DMA transfers from and to memory with zero-copy overhead between buffer and application memory
1818
* Supports data peek, skip for read and advance for write
1919
* Implements support for event notifications
2020
* User friendly MIT license
2121

2222
## Contribute
2323

24-
Fresh contributions are always welcome. Simple instructions to proceed::
24+
Fresh contributions are always welcome. Simple instructions to proceed:
2525

2626
1. Fork Github repository
2727
2. Follow [C style & coding rules](https://github.com/MaJerle/c-code-style) already used in the project
@@ -30,4 +30,4 @@ Fresh contributions are always welcome. Simple instructions to proceed::
3030
Alternatively you may:
3131

3232
1. Report a bug
33-
2. Ask for a feature request
33+
2. Ask for a feature request

dev/main.c

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lwrb_t buff;
1212
uint8_t tmp[8];
1313

1414
void
15-
my_buff_evt_fn(lwrb_t* buff, lwrb_evt_type_t type, size_t len) {
15+
my_buff_evt_fn(lwrb_t* buff, lwrb_evt_type_t type, lwrb_sz_t len) {
1616
(void)buff;
1717
(void)len;
1818
switch (type) {
@@ -25,7 +25,7 @@ my_buff_evt_fn(lwrb_t* buff, lwrb_evt_type_t type, size_t len) {
2525

2626
int
2727
main() {
28-
size_t len;
28+
lwrb_sz_t len;
2929

3030
/* Init buffer */
3131
lwrb_init(&buff, lwrb_data, sizeof(lwrb_data));
@@ -54,6 +54,42 @@ main() {
5454
len = lwrb_write(&buff, "abc", 3); /* Write 3 bytes -> buffer should go over */
5555
RW_TEST(0, 6, len, 3);
5656

57+
#undef RW_TEST
58+
}
59+
60+
printf("Read/Write extended test\r\n");
61+
{
62+
uint8_t rw_buff[8];
63+
lwrb_sz_t written, read;
64+
uint8_t success;
65+
66+
#define RW_TEST(_w_exp_, _r_exp_, _success_, _rw_len_, _rw_exp_len_) \
67+
do { \
68+
printf("W ptr: %u, R ptr: %u, R/W success: %u, R/W len: %u, as_expected: %u\r\n", (unsigned)buff.w, \
69+
(unsigned)buff.r, (unsigned)(_success_), (unsigned)(_rw_len_), \
70+
(unsigned)(buff.w == (_w_exp_) && buff.r == (_r_exp_) && (_rw_len_) == (_rw_exp_len_))); \
71+
} while (0)
72+
73+
lwrb_reset(&buff);
74+
written = 0;
75+
success = lwrb_write_ex(&buff, "abcdefg", 7, &written, LWRB_FLAG_WRITE_ALL); /* Write all bytes */
76+
RW_TEST(7, 0, success, written, 7);
77+
success = lwrb_read_ex(&buff, rw_buff, 3, &read, LWRB_FLAG_READ_ALL); /* Read 3 bytes only */
78+
printf("RW FULL READ: %u, as_expected: %u\r\n", (unsigned)success, (unsigned)(success == 1));
79+
RW_TEST(7, 3, success, written, 7);
80+
81+
/* This one shall failed, not enough memory available */
82+
success = lwrb_write_ex(&buff, "abcdefg", 7, &written, LWRB_FLAG_WRITE_ALL); /* Write all bytes */
83+
printf("RW FULL WRITE: %u, as_expected: %u\r\n", (unsigned)success, (unsigned)(success == 0));
84+
85+
/* Read few more bytes to allow full write */
86+
success = lwrb_read_ex(&buff, rw_buff, 3, &read, LWRB_FLAG_READ_ALL); /* Read 3 bytes only */
87+
printf("RW FULL READ: %u, as_expected: %u\r\n", (unsigned)success, (unsigned)(success == 1));
88+
89+
/* Now it should go through */
90+
success = lwrb_write_ex(&buff, "abcdefg", 7, &written, LWRB_FLAG_WRITE_ALL); /* Write all bytes */
91+
printf("RW FULL WRITE: %u, as_expected: %u\r\n", (unsigned)success, (unsigned)(success == 1));
92+
5793
#undef RW_TEST
5894
}
5995

@@ -99,7 +135,7 @@ main() {
99135
{
100136
#define MOVE_TEST(_exp_content_, _exp_move_len_, _exp_buff_len_) \
101137
do { \
102-
size_t move_len; \
138+
lwrb_sz_t move_len; \
103139
move_len = lwrb_move(&dst, &src); \
104140
len = lwrb_peek(&dst, 0, tmp, dst.size); \
105141
printf("move data: len: %d, dest data: %.*s, as_expected: %u\r\n", (int)len, (int)len, tmp, \
@@ -137,7 +173,7 @@ main() {
137173
{
138174
#define FIND_TEST(_bts_, _bts_len_, _start_offset_, _exp_result_) \
139175
do { \
140-
size_t found_idx; \
176+
lwrb_sz_t found_idx; \
141177
uint8_t found; \
142178
found = lwrb_find(&buff, (_bts_), (_bts_len_), (_start_offset_), &found_idx); \
143179
printf("Find \"%s\" (len %d), start_offset: %d, found_index: %d; Found: %d; As expected: %d\r\n", (_bts_), \

docs/authors/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. _authors:
2+
3+
Authors
4+
=======
5+
6+
List of authors and contributors to the library
7+
8+
.. literalinclude:: ../../AUTHORS

docs/get-started/index.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ Add library to project
5858
^^^^^^^^^^^^^^^^^^^^^^
5959

6060
At this point it is assumed that you have successfully download library, either cloned it or from releases page.
61-
Next step is to add the library to the project, by means of source files to compiler inputs and header files in search path
61+
Next step is to add the library to the project, by means of source files to compiler inputs and header files in search path.
62+
63+
*CMake* is the main supported build system. Package comes with the ``CMakeLists.txt`` and ``library.cmake`` files, both located in the ``lwrb`` directory:
64+
65+
* ``CMakeLists.txt``: Is a wrapper and only includes ``library.cmake`` file. It is used if target application uses ``add_subdirectory`` and then uses ``target_link_libraries`` to include the library in the project
66+
* ``library.cmake``: It is a fully configured set of variables. User must use ``include(path/to/library.cmake)`` to include the library and must manually add files/includes to the final target
67+
68+
.. tip::
69+
Open ``library.cmake`` file and manually analyze all the possible variables you can set for full functionality.
70+
71+
If you do not use the *CMake*, you can do the following:
6272

6373
* Copy ``lwrb`` folder to your project, it contains library files
6474
* Add ``lwrb/src/include`` folder to `include path` of your toolchain. This is where `C/C++` compiler can find the files during compilation process. Usually using ``-I`` flag

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Table of contents
7676
tips-tricks/index
7777
api-reference/index
7878
changelog/index
79+
authors/index
7980

8081
.. toctree::
8182
:maxdepth: 2

0 commit comments

Comments
 (0)