/*-------------------------------- Arctic Core ------------------------------
 * Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
 * Contact: <contact@arccore.com>
 * 
 * You may ONLY use this file:
 * 1)if you have a valid commercial ArcCore license and then in accordance with  
 * the terms contained in the written license agreement between you and ArcCore, 
 * or alternatively
 * 2)if you follow the terms found in GNU General Public License version 2 as 
 * published by the Free Software Foundation and appearing in the file 
 * LICENSE.GPL included in the packaging of this file or here 
 * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
 *-------------------------------- Arctic Core -----------------------------*/

/**
@file cirq_buffer.c
@brief A circular buffer implementation.
*/

/********************************************************************************************
Multi-Inlcude-Prevent Section
********************************************************************************************/
#ifndef CIRQ_BUFFER_H_
#define CIRQ_BUFFER_H_
/********************************************************************************************
Include File Section
********************************************************************************************/

#include "Std_Types.h"

/********************************************************************************************
Macro Definition Section
********************************************************************************************/

/********************************************************************************************
Structure Type Declaration Section
********************************************************************************************/
typedef struct {
    /* The max number of elements in the list */
    uint32_t maxCnt;
    uint32_t currCnt;

    /* Size of the elements in the list */
    uint32_t dataSize;
    /* List head and tail */
    void *head;
    void *tail;

    /* Buffer start/stop */
    void *bufStart;
    void *bufEnd;
} CirqBufferType;


/********************************************************************************************
Prototype Declaration Section                                   
********************************************************************************************/
/* Static implementation */
int32_t lCirqBuffPush( CirqBufferType *cPtr, void *dataPtr );
int32_t lCirqBuffPop(CirqBufferType *cPtr, void *dataPtr );
void *pvCirqBuffPushLock( CirqBufferType *cPtr);
void *pvCirqBuffPopLock(CirqBufferType *cPtr );
void vCirqBuffInit(CirqBufferType *cirqbuffer, void *buffer, uint32_t maxCnt, uint32_t dataSize);
int32_t CirqBuffPush_noos( CirqBufferType *cPtr, void *dataPtr );
int32_t CirqBuffPop_noos(CirqBufferType *cPtr, void *dataPtr );
void *CirqBuff_PushLock_noos( CirqBufferType *cPtr);
void *CirqBuff_PopLock_noos(CirqBufferType *cPtr );
void CirqBuff_Init_noos(CirqBufferType *cirqbuffer, void *buffer, uint32_t maxCnt, uint32_t dataSize);



#endif /* CIRQ_BUFFER_H_ */


