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 1efeb7e4ff932883283975809d332b2015a6e0b5
Author: Bowen Wang <[email protected]>
AuthorDate: Mon Apr 27 19:53:45 2026 +0800

    include/ring: add ring_space macro to query free slots
    
    Add ring_space(r) that returns the number of available slots
    for enqueue, complementing the existing ring_count/ring_capacity.
    
    Signed-off-by: Bowen Wang <[email protected]>
---
 include/nuttx/ring.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/nuttx/ring.h b/include/nuttx/ring.h
index fec9c7c5453..725423a990b 100644
--- a/include/nuttx/ring.h
+++ b/include/nuttx/ring.h
@@ -185,6 +185,7 @@
    RING_IDX_MASK)
 
 #define ring_capacity(r)    (RING_BASE(r)->capacity)
+#define ring_space(r)       (ring_capacity(r) - ring_count(r))
 
 #define ring_spsc_enqueue(r, items, count) \
   ring_sp_enqueue(RING_BASE(r), items, count, sizeof(*(items)))

Reply via email to