Browse Source

ringbuffer: whitespace

sbg
Ban Siesta 10 years ago
parent
commit
b9ce447cc9
  1. 30
      src/drivers/device/ringbuffer.cpp
  2. 2
      src/drivers/device/ringbuffer.h

30
src/drivers/device/ringbuffer.cpp

@ -57,25 +57,25 @@ RingBuffer::~RingBuffer() @@ -57,25 +57,25 @@ RingBuffer::~RingBuffer()
unsigned
RingBuffer::_next(unsigned index)
{
return (0 == index) ? _num_items : (index - 1);
return (0 == index) ? _num_items : (index - 1);
}
bool
RingBuffer::empty()
{
return _tail == _head;
return _tail == _head;
}
bool
RingBuffer::full()
{
return _next(_head) == _tail;
return _next(_head) == _tail;
}
unsigned
RingBuffer::size()
{
return (_buf != nullptr) ? _num_items : 0;
return (_buf != nullptr) ? _num_items : 0;
}
void
@ -86,7 +86,7 @@ RingBuffer::flush() @@ -86,7 +86,7 @@ RingBuffer::flush()
}
bool
RingBuffer::put(const void *val, size_t val_size)
RingBuffer::put(const void *val, size_t val_size)
{
unsigned next = _next(_head);
if (next != _tail) {
@ -250,7 +250,7 @@ static inline bool my_sync_bool_compare_and_swap(volatile unsigned *a, unsigned @@ -250,7 +250,7 @@ static inline bool my_sync_bool_compare_and_swap(volatile unsigned *a, unsigned
#define __PX4_SBCAP __sync_bool_compare_and_swap
#endif
bool
RingBuffer::get(void *val, size_t val_size)
RingBuffer::get(void *val, size_t val_size)
{
if (_tail != _head) {
unsigned candidate;
@ -340,7 +340,7 @@ RingBuffer::get(double &val) @@ -340,7 +340,7 @@ RingBuffer::get(double &val)
}
unsigned
RingBuffer::space(void)
RingBuffer::space(void)
{
unsigned tail, head;
@ -361,7 +361,7 @@ RingBuffer::space(void) @@ -361,7 +361,7 @@ RingBuffer::space(void)
}
unsigned
RingBuffer::count(void)
RingBuffer::count(void)
{
/*
* Note that due to the conservative nature of space(), this may
@ -371,7 +371,7 @@ RingBuffer::count(void) @@ -371,7 +371,7 @@ RingBuffer::count(void)
}
bool
RingBuffer::resize(unsigned new_size)
RingBuffer::resize(unsigned new_size)
{
char *old_buffer;
char *new_buffer = new char [(new_size+1) * _item_size];
@ -388,13 +388,13 @@ RingBuffer::resize(unsigned new_size) @@ -388,13 +388,13 @@ RingBuffer::resize(unsigned new_size)
}
void
RingBuffer::print_info(const char *name)
RingBuffer::print_info(const char *name)
{
printf("%s %u/%lu (%u/%u @ %p)\n",
name,
_num_items,
(unsigned long)_num_items * _item_size,
_head,
_tail,
name,
_num_items,
(unsigned long)_num_items * _item_size,
_head,
_tail,
_buf);
}

2
src/drivers/device/ringbuffer.h

@ -161,7 +161,7 @@ public: @@ -161,7 +161,7 @@ public:
private:
unsigned _num_items;
const size_t _item_size;
char *_buf;
char *_buf;
volatile unsigned _head; /**< insertion point in _item_size units */
volatile unsigned _tail; /**< removal point in _item_size units */

Loading…
Cancel
Save