Contiki-NG
Loading...
Searching...
No Matches
ringbufindex.h File Reference

Header file for the ringbufindex library. More...

#include "contiki.h"

Go to the source code of this file.

Functions

void ringbufindex_init (struct ringbufindex *r, uint8_t size)
 Initialize a ring buffer.
 
int ringbufindex_put (struct ringbufindex *r)
 Put one element to the ring buffer.
 
int ringbufindex_peek_put (const struct ringbufindex *r)
 Check if there is space to put an element.
 
int ringbufindex_get (struct ringbufindex *r)
 Remove the first element and return its index.
 
int ringbufindex_peek_get (const struct ringbufindex *r)
 Return the index of the first element which will be removed if calling ringbufindex_get.
 
static int ringbufindex_size (const struct ringbufindex *r)
 Return the ring buffer size.
 
static int ringbufindex_elements (const struct ringbufindex *r)
 Return the number of elements currently in the ring buffer.
 
static int ringbufindex_full (const struct ringbufindex *r)
 Is the ring buffer full?
 
static int ringbufindex_empty (const struct ringbufindex *r)
 Is the ring buffer empty?
 

Detailed Description

Header file for the ringbufindex library.

Author
Simon Duquennoy simon.nosp@m.duq@.nosp@m.sics..nosp@m.se

Definition in file ringbufindex.h.

Function Documentation

◆ ringbufindex_elements()

static int ringbufindex_elements ( const struct ringbufindex * r)
inlinestatic

Return the number of elements currently in the ring buffer.

Parameters
rPinter to ringbufindex
Returns
The number of elements in the ring buffer

Definition at line 108 of file ringbufindex.h.

Referenced by ringbufindex_empty(), and tsch_queue_nbr_packet_count().

◆ ringbufindex_empty()

static int ringbufindex_empty ( const struct ringbufindex * r)
inlinestatic

Is the ring buffer empty?

Return values
0Not empty
1Empty

Definition at line 130 of file ringbufindex.h.

References ringbufindex_elements().

Referenced by tsch_queue_is_empty().

◆ ringbufindex_full()

static int ringbufindex_full ( const struct ringbufindex * r)
inlinestatic

Is the ring buffer full?

Return values
0Not full
1Full

Definition at line 119 of file ringbufindex.h.

◆ ringbufindex_get()

int ringbufindex_get ( struct ringbufindex * r)

Remove the first element and return its index.

Parameters
rPinter to ringbufindex
Return values
>=0 The index of the first element
-1No element in the ring buffer

Definition at line 90 of file ringbufindex.c.

Referenced by tsch_queue_remove_packet_from_queue().

◆ ringbufindex_init()

void ringbufindex_init ( struct ringbufindex * r,
uint8_t size )

Initialize a ring buffer.

The size must be a power of two

Parameters
rPointer to ringbufindex
sizeSize of ring buffer

Definition at line 50 of file ringbufindex.c.

Referenced by tsch_queue_add_nbr().

◆ ringbufindex_peek_get()

int ringbufindex_peek_get ( const struct ringbufindex * r)

Return the index of the first element which will be removed if calling ringbufindex_get.

Parameters
rPinter to ringbufindex
Return values
>=0 The index of the first element
-1No element in the ring buffer

Definition at line 115 of file ringbufindex.c.

Referenced by tsch_queue_get_packet_for_nbr().

◆ ringbufindex_peek_put()

int ringbufindex_peek_put ( const struct ringbufindex * r)

Check if there is space to put an element.

Parameters
rPinter to ringbufindex
Return values
>=0 The index where the next element is to be added.
-1Failure; the ring buffer is full

Definition at line 78 of file ringbufindex.c.

Referenced by tsch_queue_add_packet().

◆ ringbufindex_put()

int ringbufindex_put ( struct ringbufindex * r)

Put one element to the ring buffer.

Parameters
rPointer to ringbufindex
Return values
0Failure; the ring buffer is full
1Success; an element is added

Definition at line 58 of file ringbufindex.c.

Referenced by tsch_queue_add_packet().

◆ ringbufindex_size()

static int ringbufindex_size ( const struct ringbufindex * r)
inlinestatic

Return the ring buffer size.

Parameters
rPinter to ringbufindex
Returns
The size of the ring buffer

Definition at line 97 of file ringbufindex.h.