--- libelwix/inc/elwix/aring.h 2026/02/11 13:33:22 1.5.2.1 +++ libelwix/inc/elwix/aring.h 2026/02/16 10:03:37 1.6.2.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aring.h,v 1.5.2.1 2026/02/11 13:33:22 misho Exp $ +* $Id: aring.h,v 1.6.2.2 2026/02/16 10:03:37 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -62,6 +62,15 @@ typedef struct { int lrb_size; unsigned char *lrb_data; } lrbuf_t; +#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_hptr(x) ((x)->lrb_data + lrb_head((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_queued(x, r) do { \ u_int _h, _t; \ _t = atomic_load_explicit((atomic_int*) &(x)->lrb_tail, memory_order_acquire); \