From 3f1896b9b7588e48f84b9acf07ce069b91ab6918 Mon Sep 17 00:00:00 2001 From: Murilo Belluzzo Date: Wed, 27 Jul 2016 22:03:05 -0300 Subject: [PATCH] RingBuffer: Remove 'old style' version --- libraries/AP_HAL/utility/RingBuffer.h | 30 ++++----------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/libraries/AP_HAL/utility/RingBuffer.h b/libraries/AP_HAL/utility/RingBuffer.h index 6bac86f790..8d0ad2e794 100644 --- a/libraries/AP_HAL/utility/RingBuffer.h +++ b/libraries/AP_HAL/utility/RingBuffer.h @@ -1,31 +1,11 @@ #pragma once #include -#include #include - +#include /* - old style ring buffer handling macros - - These macros assume a ring buffer like this: - - uint8_t *_buf; - uint16_t _buf_size; - volatile uint16_t _buf_head; - volatile uint16_t _buf_tail; - - These should be converted to a class in future - */ -#define BUF_AVAILABLE(buf) ((buf##_head > (_tail=buf##_tail))? (buf##_size - buf##_head) + _tail: _tail - buf##_head) -#define BUF_SPACE(buf) (((_head=buf##_head) > buf##_tail)?(_head - buf##_tail) - 1:((buf##_size - buf##_tail) + _head) - 1) -#define BUF_EMPTY(buf) (buf##_head == buf##_tail) -#define BUF_ADVANCETAIL(buf, n) buf##_tail = (buf##_tail + n) % buf##_size -#define BUF_ADVANCEHEAD(buf, n) buf##_head = (buf##_head + n) % buf##_size - - -/* - new style buffers + * Circular buffer of bytes. */ class ByteBuffer { public: @@ -108,10 +88,8 @@ private: uint8_t *buf; uint32_t size; - // head is where the next available data is. tail is where new - // data is written - std::atomic head{0}; - std::atomic tail{0}; + std::atomic head{0}; // where to read data + std::atomic tail{0}; // where to write data }; /*