|
version 1.8, 2026/02/18 01:34:17
|
version 1.9, 2026/02/18 11:41:47
|
|
Line 51 SUCH DAMAGE.
|
Line 51 SUCH DAMAGE.
|
| typedef struct { |
typedef struct { |
| E_ATOMIC_ALIGN int rb_head; |
E_ATOMIC_ALIGN int rb_head; |
| E_ATOMIC_ALIGN int rb_tail; |
E_ATOMIC_ALIGN int rb_tail; |
| |
E_ATOMIC_ALIGN unsigned int rb_full; |
| int rb_bufnum; |
int rb_bufnum; |
| struct iovec *rb_buffer; |
struct iovec *rb_buffer; |
| } ringbuf_t; |
} ringbuf_t; |
|
Line 68 typedef struct {
|
Line 69 typedef struct {
|
| _t = atomic_load_explicit((atomic_int*) &(x)->rb_tail, memory_order_acquire); \ |
_t = atomic_load_explicit((atomic_int*) &(x)->rb_tail, memory_order_acquire); \ |
| _h = atomic_load_explicit((atomic_int*) &(x)->rb_head, memory_order_relaxed); \ |
_h = atomic_load_explicit((atomic_int*) &(x)->rb_head, memory_order_relaxed); \ |
| if (_h == _t) \ |
if (_h == _t) \ |
| (r) = 0; \ | (r) = atomic_load_explicit((atomic_int*) &(x)->rb_full, memory_order_acquire) ? \ |
| | (x)->rb_bufnum : 0; \ |
| else \ |
else \ |
| (r) = (_h + (x)->rb_bufnum - _t) % (x)->rb_bufnum; \ |
(r) = (_h + (x)->rb_bufnum - _t) % (x)->rb_bufnum; \ |
| } while (0) |
} while (0) |
|
Line 155 int rbuf_isfull(ringbuf_t *rbuf);
|
Line 157 int rbuf_isfull(ringbuf_t *rbuf);
|
| * @rbuf = Ring buffer |
* @rbuf = Ring buffer |
| * @data = Data |
* @data = Data |
| * @len = Length |
* @len = Length |
| |
* @lost = Permit to lost data |
| * return: -1 error, 1 can't add data, buffer is full or 0 ok |
* return: -1 error, 1 can't add data, buffer is full or 0 ok |
| */ |
*/ |
| int rbuf_enqueue(ringbuf_t *rbuf, void *data, size_t len); | int rbuf_enqueue(ringbuf_t *rbuf, void *data, size_t len, int lost); |
| /* |
/* |
| * rbuf_dequeue() - Dequeue data from buffer |
* rbuf_dequeue() - Dequeue data from buffer |
| * |
* |