|
version 1.6.2.1, 2026/02/13 17:09:32
|
version 1.8.2.1, 2026/02/18 11:39:03
|
|
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; |
| |
#define rbuf_head(x) atomic_load_explicit((atomic_int*) &(x)->rb_head, memory_order_relaxed) |
| |
#define rbuf_tail(x) atomic_load_explicit((atomic_int*) &(x)->rb_tail, memory_order_relaxed) |
| |
#define rbuf_hptr(x) ((x)->rb_buffer + rbuf_head((x))) |
| |
#define rbuf_tptr(x) ((x)->rb_buffer + rbuf_tail((x))) |
| |
#define rbuf_ptr(x, n) ((x)->rb_buffer + ((rbuf_tail((x)) + (n)) % (x)->rb_bufnum)) |
| |
#define rbuf_num(x) ((x)->rb_bufnum) |
| |
#define rbuf_getb(x) ((x)->rb_buffer) |
| |
#define rbuf_get(x, n) *rbuf_ptr((x), (n)) |
| |
#define rbuf_isrewind(x) (rbuf_head((x)) < rbuf_tail((x))) |
| |
#define rbuf_queued(x, r) do { \ |
| |
u_int _h, _t; \ |
| |
_t = atomic_load_explicit((atomic_int*) &(x)->rb_tail, memory_order_acquire); \ |
| |
_h = atomic_load_explicit((atomic_int*) &(x)->rb_head, memory_order_relaxed); \ |
| |
if (_h == _t) \ |
| |
(r) = atomic_load_explicit((atomic_int*) &(x)->rb_full, memory_order_acquire) ? \ |
| |
(x)->rb_bufnum : 0; \ |
| |
else \ |
| |
(r) = (_h + (x)->rb_bufnum - _t) % (x)->rb_bufnum; \ |
| |
} while (0) |
| |
#define rbuf_unused(x, r) do { \ |
| |
u_int _r; \ |
| |
rbuf_queued((x), _r); \ |
| |
(r) = (x)->rb_bufnum - _r; \ |
| |
} while (0) |
| |
|
| |
|
| 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; |
|
Line 64 typedef struct {
|
Line 90 typedef struct {
|
| } lrbuf_t; |
} lrbuf_t; |
| #define lrb_head(x) atomic_load_explicit((atomic_int*) &(x)->lrb_head, memory_order_relaxed) |
#define lrb_head(x) atomic_load_explicit((atomic_int*) &(x)->lrb_head, memory_order_relaxed) |
| #define lrb_tail(x) atomic_load_explicit((atomic_int*) &(x)->lrb_tail, memory_order_relaxed) |
#define lrb_tail(x) atomic_load_explicit((atomic_int*) &(x)->lrb_tail, memory_order_relaxed) |
| #define lrb_size(x) ((x)->lrb_size) |
|
| #define lrb_getb(x) ((x)->lrb_data) |
|
| #define lrb_hptr(x) ((x)->lrb_data + lrb_head((x))) |
#define lrb_hptr(x) ((x)->lrb_data + lrb_head((x))) |
| #define lrb_tptr(x) ((x)->lrb_data + lrb_tail((x))) |
#define lrb_tptr(x) ((x)->lrb_data + lrb_tail((x))) |
| |
#define lrb_ptr(x, n) ((x)->lrb_data + ((lrb_tail((x)) + (n)) % (x)->lrb_size)) |
| |
#define lrb_size(x) ((x)->lrb_size) |
| |
#define lrb_getb(x) ((x)->lrb_data) |
| |
#define lrb_getc(x, n) *lrb_ptr((x), (n)) |
| #define lrb_isrewind(x) (lrb_head((x)) < lrb_tail((x))) |
#define lrb_isrewind(x) (lrb_head((x)) < lrb_tail((x))) |
| #define lrb_queued(x, r) do { \ |
#define lrb_queued(x, r) do { \ |
| u_int _h, _t; \ |
u_int _h, _t; \ |
|
Line 129 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 |
| * |
* |