fifo8: introduce fifo8_peek() function
This allows uses to peek the byte at the current head of the FIFO. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Octavian Purdila <tavip@google.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20240828122258.928947-9-mark.cave-ayland@ilande.co.uk> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
parent
28fbf33b3f
commit
570bf14394
@ -62,6 +62,17 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num);
|
|||||||
*/
|
*/
|
||||||
uint8_t fifo8_pop(Fifo8 *fifo);
|
uint8_t fifo8_pop(Fifo8 *fifo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fifo8_peek:
|
||||||
|
* @fifo: fifo to peek from
|
||||||
|
*
|
||||||
|
* Peek the data byte at the current head of the FIFO. Clients are responsible
|
||||||
|
* for checking for emptyness using fifo8_is_empty().
|
||||||
|
*
|
||||||
|
* Returns: The peeked data byte.
|
||||||
|
*/
|
||||||
|
uint8_t fifo8_peek(Fifo8 *fifo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fifo8_pop_buf:
|
* fifo8_pop_buf:
|
||||||
* @fifo: FIFO to pop from
|
* @fifo: FIFO to pop from
|
||||||
|
@ -71,6 +71,12 @@ uint8_t fifo8_pop(Fifo8 *fifo)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t fifo8_peek(Fifo8 *fifo)
|
||||||
|
{
|
||||||
|
assert(fifo->num > 0);
|
||||||
|
return fifo->data[fifo->head];
|
||||||
|
}
|
||||||
|
|
||||||
static const uint8_t *fifo8_peekpop_bufptr(Fifo8 *fifo, uint32_t max,
|
static const uint8_t *fifo8_peekpop_bufptr(Fifo8 *fifo, uint32_t max,
|
||||||
uint32_t skip, uint32_t *numptr,
|
uint32_t skip, uint32_t *numptr,
|
||||||
bool do_pop)
|
bool do_pop)
|
||||||
|
Loading…
Reference in New Issue
Block a user