diff --git a/core/include/cib.h b/core/include/cib.h index 70702d1b6..1e9e725c0 100644 --- a/core/include/cib.h +++ b/core/include/cib.h @@ -86,6 +86,22 @@ static inline int cib_get(cib_t *__restrict cib) return -1; } +/** + * @brief Get the index of the next item in buffer without removing it. + * + * @param[in,out] cib corresponding *cib* to buffer. + * Must not be NULL. + * @return index of next item, -1 if the buffer is empty + */ +static inline int cib_peek(cib_t *__restrict cib) +{ + if (cib->write_count > cib->read_count) { + return (int) (cib->read_count & cib->mask); + } + + return -1; +} + /** * @brief Get index for item in buffer to put to. *