|
|
| version 1.4.4.1, 2026/02/10 15:49:08 | version 1.6, 2026/02/11 13:36:09 |
|---|---|
| Line 58 typedef struct { | Line 58 typedef struct { |
| typedef struct { | typedef struct { |
| E_ATOMIC_ALIGN unsigned int lrb_head; | E_ATOMIC_ALIGN unsigned int lrb_head; |
| E_ATOMIC_ALIGN unsigned int lrb_tail; | E_ATOMIC_ALIGN unsigned int lrb_tail; |
| E_ATOMIC_ALIGN unsigned int lrb_full; | |
| int lrb_size; | int lrb_size; |
| unsigned char *lrb_data; | unsigned char *lrb_data; |
| } lrbuf_t; | } lrbuf_t; |
| Line 65 typedef struct { | Line 66 typedef struct { |
| u_int _h, _t; \ | u_int _h, _t; \ |
| _t = atomic_load_explicit((atomic_int*) &(x)->lrb_tail, memory_order_acquire); \ | _t = atomic_load_explicit((atomic_int*) &(x)->lrb_tail, memory_order_acquire); \ |
| _h = atomic_load_explicit((atomic_int*) &(x)->lrb_head, memory_order_relaxed); \ | _h = atomic_load_explicit((atomic_int*) &(x)->lrb_head, memory_order_relaxed); \ |
| (r) = (_h + (x)->lrb_size - _t) % (x)->lrb_size; \ | if (_h == _t) \ |
| (r) = atomic_load_explicit((atomic_int*) &(x)->lrb_full, memory_order_acquire) ? \ | |
| (x)->lrb_size : 0; \ | |
| else \ | |
| (r) = (_h + (x)->lrb_size - _t) % (x)->lrb_size; \ | |
| } while (0) | } while (0) |
| #define lrb_unused(x, r) do { \ | #define lrb_unused(x, r) do { \ |
| u_int _r; \ | u_int _r; \ |
| Line 185 int lrb_enqueue(lrbuf_t *lrb, void *data, size_t len, | Line 190 int lrb_enqueue(lrbuf_t *lrb, void *data, size_t len, |
| * return: -1 error, 0 buffer is empty or >0 stored data bytes | * return: -1 error, 0 buffer is empty or >0 stored data bytes |
| */ | */ |
| int lrb_dequeue(lrbuf_t *lrb, void *data, size_t len); | int lrb_dequeue(lrbuf_t *lrb, void *data, size_t len); |
| /* | |
| * lrb_getw() - Get address for write | |
| * | |
| * @lrb = Linear ring buffer | |
| * @len = Return available buffer length for write | |
| * return: NULL error or !=NULL pointer for write | |
| * remark: After use of lrb_getw() and write to pointer. | |
| * You should update ring buffer with lrb_enqueue(,NULL,wrote_len,) | |
| */ | |
| void *lrb_getw(lrbuf_t *lrb, size_t *len); | |
| /* | |
| * lrb_getr() - Get address for read | |
| * | |
| * @lrb = Linear ring buffer | |
| * @len = Return available data length for read | |
| * return: NULL error or !=NULL pointer for read | |
| * remark: After use of lrb_getr() and read from pointer. | |
| * You could update ring buffer with lrb_dequeue(,NULL,read_len) | |
| */ | |
| void *lrb_getr(lrbuf_t *lrb, size_t *len); | |
| #endif | #endif |