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:
parent
0c166b1e2a
commit
0d4dae9c38
@ -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);
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user