diff options
author | Michael Hope <michael.hope@linaro.org> | 2010-09-29 20:45:57 +1300 |
---|---|---|
committer | Michael Hope <michael.hope@linaro.org> | 2010-09-29 20:45:57 +1300 |
commit | 6fcd4cd306dbecf56f5b0b506a3c23762d1219fa (patch) | |
tree | 467125eca5a2e6706001cad8e09bc475e58a12d9 /libmaple/ring_buffer.h | |
parent | 368e4fc1662c2594b2a0908900713a2555a3ed8e (diff) | |
parent | adde11b099ff5dad176e410279d21feac39d2c7e (diff) | |
download | librambutan-6fcd4cd306dbecf56f5b0b506a3c23762d1219fa.tar.gz librambutan-6fcd4cd306dbecf56f5b0b506a3c23762d1219fa.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'libmaple/ring_buffer.h')
-rw-r--r-- | libmaple/ring_buffer.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/libmaple/ring_buffer.h b/libmaple/ring_buffer.h index 95b9dd8..6a54747 100644 --- a/libmaple/ring_buffer.h +++ b/libmaple/ring_buffer.h @@ -21,30 +21,30 @@ typedef struct ring_buffer { } ring_buffer; static inline void rb_init(ring_buffer *rb, uint8 size, uint8 *buf) { - ASSERT(IS_POWER_OF_TWO(size)); - rb->head = 0; - rb->tail = 0; - rb->size = size; - rb->buf = buf; + ASSERT(IS_POWER_OF_TWO(size)); + rb->head = 0; + rb->tail = 0; + rb->size = size; + rb->buf = buf; } static inline void rb_insert(ring_buffer *rb, uint8 element) { - rb->buf[(rb->tail)++] = element; - rb->tail &= (rb->size - 1); + rb->buf[(rb->tail)++] = element; + rb->tail &= (rb->size - 1); } static inline uint8 rb_remove(ring_buffer *rb) { - uint8 ch = rb->buf[rb->head++]; - rb->head &= (rb->size - 1); - return ch; + uint8 ch = rb->buf[rb->head++]; + rb->head &= (rb->size - 1); + return ch; } static inline uint32 rb_full_count(ring_buffer *rb) { - return rb->tail - rb->head; + return rb->tail - rb->head; } static inline void rb_reset(ring_buffer *rb) { - rb->tail = rb->head; + rb->tail = rb->head; } #ifdef __cplusplus |