--- libelwix/src/ring.c 2026/02/11 13:36:09 1.6 +++ libelwix/src/ring.c 2026/02/18 01:34:17 1.7 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: ring.c,v 1.6 2026/02/11 13:36:09 misho Exp $ +* $Id: ring.c,v 1.7 2026/02/18 01:34:17 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -138,19 +138,13 @@ rbuf_isempty(ringbuf_t *rbuf) int rbuf_isfull(ringbuf_t *rbuf) { - int h, t; - if (!rbuf) return -1; if (!rbuf->rb_bufnum) return 1; - t = atomic_load_explicit((atomic_int*) &rbuf->rb_tail, memory_order_acquire); - h = atomic_load_explicit((atomic_int*) &rbuf->rb_head, memory_order_relaxed) + 1; - if (h >= rbuf->rb_bufnum) - h ^= h; - - return (h == t); + return (((atomic_load_explicit((atomic_int*) &rbuf->rb_head, memory_order_relaxed) + 1) % rbuf->rb_bufnum) == + atomic_load_explicit((atomic_int*) &rbuf->rb_tail, memory_order_acquire)); } /*