forked from PAWPAW-Mirror/lib_xua
Add functions for working with queues of bytes.
This is used by the IAP code.
This commit is contained in:
@@ -43,6 +43,17 @@ inline unsigned queue_pop_word(queue_t &q, unsigned array[]) {
|
||||
return array[q.rdptr++ & q.mask];
|
||||
}
|
||||
|
||||
inline void queue_push_byte(queue_t &q, unsigned char array[], unsigned data)
|
||||
{
|
||||
assert(!queue_is_full(q));
|
||||
array[q.wrptr++ & q.mask] = data;
|
||||
}
|
||||
|
||||
inline unsigned queue_pop_byte(queue_t &q, unsigned char array[]) {
|
||||
assert(!queue_is_empty(q));
|
||||
return array[q.rdptr++ & q.mask];
|
||||
}
|
||||
|
||||
inline unsigned queue_items(const queue_t &q) {
|
||||
return q.wrptr - q.rdptr;
|
||||
}
|
||||
|
||||
@@ -7,5 +7,7 @@ extern inline int queue_is_empty(const queue_t &q);
|
||||
extern inline int queue_is_full(const queue_t &q);
|
||||
extern inline void queue_push_word(queue_t &q, unsigned array[], unsigned data);
|
||||
extern inline unsigned queue_pop_word(queue_t &q, unsigned array[]);
|
||||
extern inline void queue_push_byte(queue_t &q, unsigned char array[], unsigned data);
|
||||
extern inline unsigned queue_pop_byte(queue_t &q, unsigned char array[]);
|
||||
extern inline unsigned queue_space(const queue_t &q);
|
||||
extern inline unsigned queue_items(const queue_t &q);
|
||||
|
||||
Reference in New Issue
Block a user