This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 6e6cbddacbcd1ee6100942511e7736d2b88dad63 Author: Bowen Wang <[email protected]> AuthorDate: Thu Apr 23 14:51:36 2026 +0800 include/ring: add skip API for advancing indices without data copy Add dequeue_skip variants that advance ring indices without touching data, built on the reserve + commit building blocks from the previous patch. Signed-off-by: Bowen Wang <[email protected]> --- include/nuttx/ring.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/include/nuttx/ring.h b/include/nuttx/ring.h index 21bca27f292..d9dfbf36b63 100644 --- a/include/nuttx/ring.h +++ b/include/nuttx/ring.h @@ -181,6 +181,18 @@ #define ring_mpsc_dequeue(r, items, count) \ ring_sc_dequeue(RING_BASE(r), items, count, sizeof(*(items))) +#define ring_spsc_dequeue_skip(r, count) \ + ring_sc_dequeue_skip(RING_BASE(r), count) + +#define ring_mpmc_dequeue_skip(r, count) \ + ring_mc_dequeue_skip(RING_BASE(r), count) + +#define ring_spmc_dequeue_skip(r, count) \ + ring_mc_dequeue_skip(RING_BASE(r), count) + +#define ring_mpsc_dequeue_skip(r, count) \ + ring_sc_dequeue_skip(RING_BASE(r), count) + /**************************************************************************** * Public Types ****************************************************************************/ @@ -718,4 +730,44 @@ ring_mc_dequeue(FAR struct ring_s *r, FAR void *items, return buf.cnt; } +/**************************************************************************** + * Name: ring_sc_dequeue_skip + * + * Description: + * Single-consumer dequeue skip. Advance cons_tail by count without + * reading data. Returns actual count skipped. + * + ****************************************************************************/ + +static inline_function uint32_t +ring_sc_dequeue_skip(FAR struct ring_s *r, uint32_t count) +{ + struct ring_buf_s buf; + + ring_sc_start(r, count, 0, &buf); + ring_sc_finish(r, &buf); + + return buf.cnt; +} + +/**************************************************************************** + * Name: ring_mc_dequeue_skip + * + * Description: + * Multi-consumer dequeue skip. Reserve and finish slots on + * cons_head and cons_tail without reading data. + * + ****************************************************************************/ + +static inline_function uint32_t +ring_mc_dequeue_skip(FAR struct ring_s *r, uint32_t count) +{ + struct ring_buf_s buf; + + ring_mc_start(r, count, 0, &buf); + ring_mc_finish(r, &buf); + + return buf.cnt; +} + #endif /* __INCLUDE_NUTTX_RING_H */
