ibmpc: ringbuf optimization for c

This commit is contained in:
tmk 2021-07-07 23:00:35 +09:00
parent 369b5cb21e
commit 7438f7baab
2 changed files with 18 additions and 9 deletions

View file

@ -19,6 +19,7 @@ static inline void ringbuf_write(ringbuf_t *buf, uint8_t data);
static inline bool ringbuf_is_empty(ringbuf_t *buf);
static inline bool ringbuf_is_full(ringbuf_t *buf);
static inline void ringbuf_reset(ringbuf_t *buf);
static inline void ringbuf_push(ringbuf_t *buf, uint8_t data);
static inline void ringbuf_init(ringbuf_t *buf, uint8_t *array, uint8_t size)
{
@ -70,4 +71,10 @@ static inline void ringbuf_reset(ringbuf_t *buf)
buf->head = 0;
buf->tail = 0;
}
static inline void ringbuf_push(ringbuf_t *buf, uint8_t data)
{
buf->buffer[buf->head] = data;
buf->head++;
buf->head &= buf->size_mask;
}
#endif