1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 09:33:50 +01:00

sys/chunked_ringbuffer: move config to CONFIG_ namespace

This commit is contained in:
Leandro Lanzieri 2022-03-04 09:35:39 +01:00
parent 0c166b1e2a
commit 0d4dae9c38
No known key found for this signature in database
GPG Key ID: F4E9A721761C7593
2 changed files with 10 additions and 9 deletions

View File

@ -22,13 +22,13 @@
static int _get_free_chunk(chunk_ringbuf_t *rb)
{
int idx = rb->chunk_cur;
for (int i = 0; i < CHUNK_NUM_MAX; ++i) {
for (int i = 0; i < CONFIG_CHUNK_NUM_MAX; ++i) {
uintptr_t _ptr = atomic_load_uintptr((uintptr_t *)&rb->chunk_start[idx]);
if (_ptr == 0) {
return idx;
}
if (++idx == CHUNK_NUM_MAX) {
if (++idx == CONFIG_CHUNK_NUM_MAX) {
idx = 0;
}
}
@ -39,13 +39,13 @@ static int _get_free_chunk(chunk_ringbuf_t *rb)
static int _get_complete_chunk(chunk_ringbuf_t *rb)
{
int idx = rb->chunk_cur;
for (int i = 0; i < CHUNK_NUM_MAX; ++i) {
for (int i = 0; i < CONFIG_CHUNK_NUM_MAX; ++i) {
uintptr_t _ptr = atomic_load_uintptr((uintptr_t *)&rb->chunk_start[idx]);
if (_ptr) {
return idx;
}
if (++idx == CHUNK_NUM_MAX) {
if (++idx == CONFIG_CHUNK_NUM_MAX) {
idx = 0;
}
}
@ -219,7 +219,7 @@ bool crb_consume_chunk(chunk_ringbuf_t *rb, void *dst, size_t len)
}
/* advance first used slot nr */
rb->chunk_cur = (rb->chunk_cur + 1) % CHUNK_NUM_MAX;
rb->chunk_cur = (rb->chunk_cur + 1) % CONFIG_CHUNK_NUM_MAX;
irq_restore(state);

View File

@ -25,6 +25,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
@ -34,8 +35,8 @@ extern "C" {
* @brief The maximum number of chunks that can be stored in a Chunked Ringbuffer
*
*/
#ifndef CHUNK_NUM_MAX
#define CHUNK_NUM_MAX (4)
#ifndef CONFIG_CHUNK_NUM_MAX
#define CONFIG_CHUNK_NUM_MAX (4)
#endif
/**
@ -48,8 +49,8 @@ typedef struct {
uint8_t *cur; /**< current write pointer */
uint8_t *cur_start; /**< start of the currently written chunk */
uint8_t *protect; /**< start of the first valid chunk */
uint8_t *chunk_start[CHUNK_NUM_MAX]; /**< Array to hold start of done chunks */
uint16_t chunk_len[CHUNK_NUM_MAX]; /**< Length of valid chunks */
uint8_t *chunk_start[CONFIG_CHUNK_NUM_MAX]; /**< Array to hold start of done chunks */
uint16_t chunk_len[CONFIG_CHUNK_NUM_MAX]; /**< Length of valid chunks */
uint8_t chunk_cur; /**< Index of the first valid chunk */
} chunk_ringbuf_t;