--- libelwix/src/ring.c 2025/09/26 10:16:59 1.2 +++ libelwix/src/ring.c 2025/09/26 16:00:22 1.2.2.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: ring.c,v 1.2 2025/09/26 10:16:59 misho Exp $ +* $Id: ring.c,v 1.2.2.1 2025/09/26 16:00:22 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -59,8 +59,8 @@ rbuf_init(ringbuf_t *rbuf, int num) if (!rbuf) return -1; - atomic_store_explicit(&rbuf->rb_head, 0, memory_order_relaxed); - atomic_store_explicit(&rbuf->rb_tail, 0, memory_order_relaxed); + atomic_store_explicit((atomic_int*) &rbuf->rb_head, 0, memory_order_relaxed); + atomic_store_explicit((atomic_int*) &rbuf->rb_tail, 0, memory_order_relaxed); rbuf->rb_buffer = e_calloc(num, sizeof(struct iovec)); if (!rbuf->rb_buffer) @@ -90,8 +90,8 @@ rbuf_free(ringbuf_t *rbuf) rbuf->rb_bufnum = 0; } - atomic_store_explicit(&rbuf->rb_head, 0, memory_order_relaxed); - atomic_store_explicit(&rbuf->rb_tail, 0, memory_order_relaxed); + atomic_store_explicit((atomic_int*) &rbuf->rb_head, 0, memory_order_relaxed); + atomic_store_explicit((atomic_int*) &rbuf->rb_tail, 0, memory_order_relaxed); } /* @@ -109,8 +109,8 @@ rbuf_purge(ringbuf_t *rbuf) if (rbuf->rb_buffer) memset(rbuf->rb_buffer, 0, rbuf->rb_bufnum * sizeof(struct iovec)); - atomic_store_explicit(&rbuf->rb_head, 0, memory_order_relaxed); - atomic_store_explicit(&rbuf->rb_tail, 0, memory_order_relaxed); + atomic_store_explicit((atomic_int*) &rbuf->rb_head, 0, memory_order_relaxed); + atomic_store_explicit((atomic_int*) &rbuf->rb_tail, 0, memory_order_relaxed); } /* @@ -125,8 +125,8 @@ rbuf_isempty(ringbuf_t *rbuf) if (!rbuf) return -1; - return (atomic_load_explicit(&rbuf->rb_head, memory_order_acquire) == - atomic_load_explicit(&rbuf->rb_tail, memory_order_acquire)); + return (atomic_load_explicit((atomic_int*) &rbuf->rb_head, memory_order_acquire) == + atomic_load_explicit((atomic_int*) &rbuf->rb_tail, memory_order_acquire)); } /* @@ -143,8 +143,8 @@ rbuf_isfull(ringbuf_t *rbuf) if (!rbuf->rb_bufnum) return 1; - return (((atomic_load_explicit(&rbuf->rb_head, memory_order_relaxed) + 1) % rbuf->rb_bufnum) == - atomic_load_explicit(&rbuf->rb_tail, memory_order_acquire)); + 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)); } /* @@ -166,8 +166,8 @@ rbuf_enqueue(ringbuf_t *rbuf, void *data, size_t len) if (!rbuf->rb_bufnum) return 1; - h = atomic_load_explicit(&rbuf->rb_head, memory_order_relaxed); - t = atomic_load_explicit(&rbuf->rb_tail, memory_order_acquire); + h = atomic_load_explicit((atomic_int*) &rbuf->rb_head, memory_order_relaxed); + t = atomic_load_explicit((atomic_int*) &rbuf->rb_tail, memory_order_acquire); n = (h + 1) % rbuf->rb_bufnum; if (n == t) @@ -177,7 +177,7 @@ rbuf_enqueue(ringbuf_t *rbuf, void *data, size_t len) iov->iov_len = len; iov->iov_base = data; - atomic_store_explicit(&rbuf->rb_head, n, memory_order_release); + atomic_store_explicit((atomic_int*) &rbuf->rb_head, n, memory_order_release); return 0; } @@ -198,8 +198,8 @@ rbuf_dequeue(ringbuf_t *rbuf, struct iovec *out) if (!rbuf->rb_bufnum) return 1; - h = atomic_load_explicit(&rbuf->rb_head, memory_order_acquire); - t = atomic_load_explicit(&rbuf->rb_tail, memory_order_relaxed); + h = atomic_load_explicit((atomic_int*) &rbuf->rb_head, memory_order_acquire); + t = atomic_load_explicit((atomic_int*) &rbuf->rb_tail, memory_order_relaxed); n = (t + 1) % rbuf->rb_bufnum; if (h == t) @@ -208,6 +208,6 @@ rbuf_dequeue(ringbuf_t *rbuf, struct iovec *out) if (out) *out = rbuf->rb_buffer[t]; - atomic_store_explicit(&rbuf->rb_tail, n, memory_order_release); + atomic_store_explicit((atomic_int*) &rbuf->rb_tail, n, memory_order_release); return 0; }