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 3fbbe955d9814c49543aac07723d0ef5d2354bbd Author: chenzihan1 <[email protected]> AuthorDate: Fri May 15 17:51:10 2026 +0800 include/nuttx/ring.h: add RING_SIZE_MAX and RING_SIZE_VALID macros Add compile-time helpers for ring buffer size validation: - RING_SIZE_MAX: maximum allowed capacity (2^23, limited by 24-bit index) - RING_SIZE_VALID(sz): validates size is > 0, power-of-2, and <= RING_SIZE_MAX This allows users of ring.h to validate buffer sizes consistently without open-coding the constraints. Signed-off-by: chenzihan1 <[email protected]> --- include/nuttx/ring.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/nuttx/ring.h b/include/nuttx/ring.h index 88adceedc81..cd7cbc1867a 100644 --- a/include/nuttx/ring.h +++ b/include/nuttx/ring.h @@ -137,6 +137,10 @@ #define RING_IDX_MASK 0xffffff +/* Maximum ring capacity: must be power-of-2 and fit in 24-bit index space */ + +#define RING_SIZE_MAX (1u << 23) + /* 32-bit RTS packed type: {cnt:8, idx:24} in a single atomic_t. * * Layout (little-endian and big-endian safe via shift/mask):
