From: Willy Tarreau Date: Wed, 6 Mar 2024 15:40:39 +0000 (+0100) Subject: MINOR: ring: also add ring_area(), ring_head(), ring_tail() X-Git-Tag: v3.0-dev6~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b30fd8cc2d99858deff8c4216c392c62ce7158af;p=thirdparty%2Fhaproxy.git MINOR: ring: also add ring_area(), ring_head(), ring_tail() These will essentially be used to simplify the conversion to a new API. --- diff --git a/include/haproxy/ring.h b/include/haproxy/ring.h index 81440f538e..f8401d8b82 100644 --- a/include/haproxy/ring.h +++ b/include/haproxy/ring.h @@ -45,6 +45,12 @@ size_t ring_max_payload(const struct ring *ring); int ring_dispatch_messages(struct ring *ring, void *ctx, size_t *ofs_ptr, size_t *last_ofs_ptr, uint flags, ssize_t (*msg_handler)(void *ctx, const struct buffer *buf, size_t ofs, size_t len)); +/* returns the ring storage's area */ +static inline void *ring_area(const struct ring *ring) +{ + return b_orig(&ring->buf); +} + /* returns the number of bytes in the ring */ static inline size_t ring_data(const struct ring *ring) { @@ -57,6 +63,18 @@ static inline size_t ring_size(const struct ring *ring) return b_size(&ring->buf); } +/* returns the head offset of the ring */ +static inline size_t ring_head(const struct ring *ring) +{ + return b_head_ofs(&ring->buf); +} + +/* returns the tail offset of the ring */ +static inline size_t ring_tail(const struct ring *ring) +{ + return b_tail_ofs(&ring->buf); +} + /* duplicates ring over ring for no more than bytes or no * more than the amount of data present in . It's assumed that the * destination ring is always large enough for . The number of bytes