pelib  2.0.0
include/pelib/fifo.c File Reference
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
Include dependency graph for fifo.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define state(elem)   PELIB_CONCAT_3(cfifo_, elem, _state)
#define is_in_content(elem)   PELIB_CONCAT_2(is_in_content_, elem)
#define continuous_read_length(elem)   PELIB_CONCAT_2(continuous_read_length_, elem)
#define continuous_write_length(elem)   PELIB_CONCAT_2(continuous_write_length_, elem)
#define CFIFO_EMPTY   "[]"
#define CFIFO_SEPARATOR   ":"
#define CFIFO_BEGIN   "["
#define CFIFO_END   "]"
#define debug(var)   printf("[%s:%s:%d] %s = \"%s\"\n", __FILE__, __FUNCTION__, __LINE__, #var, var); fflush(NULL)
#define debug_addr(var)   printf("[%s:%s:%d] %s = \"%p\"\n", __FILE__, __FUNCTION__, __LINE__, #var, var); fflush(NULL)
#define debug_int(var)   printf("[%s:%s:%d] %s = \"%d\"\n", __FILE__, __FUNCTION__, __LINE__, #var, var); fflush(NULL)
#define debug_size_t(var)   printf("[%s:%s:%d] %s = \"%zu\"\n", __FILE__, __FUNCTION__, __LINE__, #var, (size_t)(var)); fflush(NULL)

Typedefs

typedef enum state state_t

Enumerations

enum  state { NORMAL, REVERSE, EMPTY, FULL }

Functions

int pelib_alloc_buffer (cfifo_t(CFIFO_T))
 cfifo_t (CFIFO_T)
int pelib_init (cfifo_t(CFIFO_T))
int pelib_free (cfifo_t(CFIFO_T))
int pelib_free_struct (cfifo_t(CFIFO_T))
int pelib_free_buffer (cfifo_t(CFIFO_T))
FILE * pelib_printf (cfifo_t(CFIFO_T))
FILE * pelib_printf_detail (cfifo_t(CFIFO_T))
char * pelib_string (cfifo_t(CFIFO_T))
char * pelib_string_detail (cfifo_t(CFIFO_T))
int pelib_cfifo_push() CFIFO_T (cfifo_t(CFIFO_T)*fifo, CFIFO_T elem)
CFIFO_T *pelib_cfifo_peekaddr() CFIFO_T (cfifo_t(CFIFO_T)*fifo, size_t offset, size_t *num, CFIFO_T **addr)
CFIFO_T *pelib_cfifo_writeaddr() CFIFO_T (cfifo_t(CFIFO_T)*fifo, size_t *num, CFIFO_T **addr)
size_t pelib_cfifo_pushmem() CFIFO_T (cfifo_t(CFIFO_T)*fifo, CFIFO_T *mem, size_t num)
size_t pelib_cfifo_peekmem() CFIFO_T (cfifo_t(CFIFO_T)*fifo, CFIFO_T *mem, size_t num, size_t offset)
size_t pelib_cfifo_popfifo() CFIFO_T (cfifo_t(CFIFO_T)*src, cfifo_t(CFIFO_T)*tgt, size_t num)

Define Documentation

#define CFIFO_BEGIN   "["

Definition at line 43 of file fifo.c.

#define CFIFO_EMPTY   "[]"

Definition at line 41 of file fifo.c.

#define CFIFO_END   "]"

Definition at line 44 of file fifo.c.

#define CFIFO_SEPARATOR   ":"

Definition at line 42 of file fifo.c.

#define continuous_read_length (   elem)    PELIB_CONCAT_2(continuous_read_length_, elem)

Definition at line 36 of file fifo.c.

#define continuous_write_length (   elem)    PELIB_CONCAT_2(continuous_write_length_, elem)

Definition at line 38 of file fifo.c.

#define debug (   var)    printf("[%s:%s:%d] %s = \"%s\"\n", __FILE__, __FUNCTION__, __LINE__, #var, var); fflush(NULL)

Definition at line 54 of file fifo.c.

#define debug_addr (   var)    printf("[%s:%s:%d] %s = \"%p\"\n", __FILE__, __FUNCTION__, __LINE__, #var, var); fflush(NULL)

Definition at line 55 of file fifo.c.

#define debug_int (   var)    printf("[%s:%s:%d] %s = \"%d\"\n", __FILE__, __FUNCTION__, __LINE__, #var, var); fflush(NULL)

Definition at line 56 of file fifo.c.

#define debug_size_t (   var)    printf("[%s:%s:%d] %s = \"%zu\"\n", __FILE__, __FUNCTION__, __LINE__, #var, (size_t)(var)); fflush(NULL)

Definition at line 57 of file fifo.c.

#define is_in_content (   elem)    PELIB_CONCAT_2(is_in_content_, elem)

Definition at line 35 of file fifo.c.

#define state (   elem)    PELIB_CONCAT_3(cfifo_, elem, _state)

Definition at line 34 of file fifo.c.


Typedef Documentation

typedef enum state state_t

Definition at line 69 of file fifo.c.


Enumeration Type Documentation

enum state
Enumerator:
NORMAL 
REVERSE 
EMPTY 
FULL 

Definition at line 65 of file fifo.c.


Function Documentation

Definition at line 80 of file fifo.c.

Pushes a new element the tail of the fifo

Definition at line 305 of file fifo.c.

CFIFO_T* pelib_cfifo_peekaddr() CFIFO_T ( cfifo_t(CFIFO_T)*  ,
size_t  offset,
size_t num,
CFIFO_T **  remaining 
)

Returns an address that contains elements to be read. If num is not NULL and if there is at least one element available, writes the number of elements available in address pointer by num. If no element is available, returns NULL and writes nothing in other parameters. Note that *num may take a lower value than pelib_cfifo_length() if pelib_cfifo_length() >= 2. In this case, if remaining is not null, then remaining is set to point to the the rest of the data; otherwise it is set to NULL.

Definition at line 340 of file fifo.c.

CFIFO_T* pelib_cfifo_writeaddr() CFIFO_T ( cfifo_t(CFIFO_T)*  ,
size_t num,
CFIFO_T **  remaining 
)

Returns an address that can hold new elements. If num is not NULL and if there is at least one memory element available, writes the number of additional elements the fifo can store in address pointer by num. If no memory is available, returns NULL and writes nothing in other parameters. Note that *num may take a lower value than pelib_cifo_capacity() - pelib_cfifo_length(). In this case and if remaining is non-null, remaining points to the extra memory buffer. Otherwise, it is set to NULL.

Definition at line 382 of file fifo.c.

Pushes all n elements stored in some memory address and update

Parameters:
Addressof the first element to be pushed
nNumber of elements to push
Returns:
Number of elements that could be pushed. Lower than n if there is not enough space to write all elements

Pops n elements and copy them into memory pointed by addr and update the fifo head element

Parameters:
addrAddress where the first element popped is written
nNumber of elements to pop
Returns:
Number of elements actually popped. May be lower than n if there are not enough elemennts stored

Definition at line 481 of file fifo.c.

Copies the n first elements into addr but do not discard any element in the fifo

Parameters:
nNumber of elements to peek from fifo
offsetNumber of elements to skip before reading
Returns:
Number of elemetns that could actually be read

Definition at line 607 of file fifo.c.

Pops n elements from fifo and pushes them into fifo dest

Parameters:
destFifo that receives the elements popped
nnumber of elements to pop
Returns:
Number of elements actually pushed in fifo dest

Definition at line 699 of file fifo.c.

Definition at line 72 of file fifo.c.

Definition at line 118 of file fifo.c.

Definition at line 133 of file fifo.c.

Definition at line 125 of file fifo.c.

Definition at line 108 of file fifo.c.

Definition at line 140 of file fifo.c.

Definition at line 151 of file fifo.c.

Definition at line 257 of file fifo.c.

Definition at line 263 of file fifo.c.