|
|
| version 1.6, 2026/02/11 13:36:09 | version 1.7, 2026/02/18 01:34:17 |
|---|---|
| Line 138 rbuf_isempty(ringbuf_t *rbuf) | Line 138 rbuf_isempty(ringbuf_t *rbuf) |
| int | int |
| rbuf_isfull(ringbuf_t *rbuf) | rbuf_isfull(ringbuf_t *rbuf) |
| { | { |
| int h, t; | |
| if (!rbuf) | if (!rbuf) |
| return -1; | return -1; |
| if (!rbuf->rb_bufnum) | if (!rbuf->rb_bufnum) |
| return 1; | return 1; |
| t = atomic_load_explicit((atomic_int*) &rbuf->rb_tail, memory_order_acquire); | return (((atomic_load_explicit((atomic_int*) &rbuf->rb_head, memory_order_relaxed) + 1) % rbuf->rb_bufnum) == |
| h = atomic_load_explicit((atomic_int*) &rbuf->rb_head, memory_order_relaxed) + 1; | atomic_load_explicit((atomic_int*) &rbuf->rb_tail, memory_order_acquire)); |
| if (h >= rbuf->rb_bufnum) | |
| h ^= h; | |
| return (h == t); | |
| } | } |
| /* | /* |