]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ring: also add ring_area(), ring_head(), ring_tail()
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Mar 2024 15:40:39 +0000 (16:40 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Mar 2024 17:34:19 +0000 (17:34 +0000)
These will essentially be used to simplify the conversion to a new API.

include/haproxy/ring.h

index 81440f538e2a82a53c581c8d121f0363d53be094..f8401d8b827ad1f047928e17fc50d6c6de256d20 100644 (file)
@@ -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 <src> over ring <dst> for no more than <max> bytes or no
  * more than the amount of data present in <src>. It's assumed that the
  * destination ring is always large enough for <max>. The number of bytes