mdcore  0.1.5
Defines | Functions | Variables
/home/pedro/work/mdcore/src/fifo.c File Reference
#include "../config.h"
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <math.h>
#include <float.h>
#include <string.h>
#include <limits.h>
#include "cycle.h"
#include "errs.h"
#include "fifo.h"

Defines

#define error(id)   ( fifo_err = errs_register( id , fifo_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) )

Functions

int fifo_push_nb (struct fifo *f, int e)
 Add an element to the fifo, non-blocking.
int fifo_pop_nb (struct fifo *f, int *e)
 Remove an element from the fifo, non-blocking.
int fifo_push (struct fifo *f, int e)
 Add an element to the fifo, blocking.
int fifo_pop (struct fifo *f, int *e)
 Remove an element from the fifo, blocking.
int fifo_init (struct fifo *f, int size)
 Initialize the given fifo.

Variables

int fifo_err = fifo_err_ok
char * fifo_err_msg [6]

Define Documentation

#define error (   id)    ( fifo_err = errs_register( id , fifo_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) )

Function Documentation

int fifo_init ( struct fifo f,
int  size 
)

Initialize the given fifo.

Parameters:
fThe fifo
sizeThe number of entries
Returns:
fifo_err_ok or < 0 on error (see fifo_err).
int fifo_pop ( struct fifo f,
int *  e 
)

Remove an element from the fifo, blocking.

Parameters:
fThe fifo
ePointer to the popped element.
Returns:
The new number of entries or < 0 on error (see fifo_err).
int fifo_pop_nb ( struct fifo f,
int *  e 
)

Remove an element from the fifo, non-blocking.

Parameters:
fThe fifo
ePointer to the popped element.
Returns:
The new number of entries or < 0 on error (see fifo_err).
int fifo_push ( struct fifo f,
int  e 
)

Add an element to the fifo, blocking.

Parameters:
fThe fifo
eThe entry to add.
Returns:
The new number of entries or < 0 on error (see fifo_err).
int fifo_push_nb ( struct fifo f,
int  e 
)

Add an element to the fifo, non-blocking.

Parameters:
fThe fifo
eThe entry to add.
Returns:
The new number of entries or < 0 on error (see fifo_err).

Variable Documentation

The ID of the last error.

char* fifo_err_msg[6]
Initial value:
 {
        "Nothing bad happened.",
    "An unexpected NULL pointer was encountered.",
    "A call to malloc failed, probably due to insufficient memory.",
    "A call to a pthread routine failed.",
    "Tried to push onto a full FIFO-queue." ,
    "Tried to pop from an empty FIFO-queue." 
        }
 All Data Structures Files Functions Variables Typedefs Enumerator Defines