]> rtime.felk.cvut.cz Git - arc.git/blob - include/cirq_buffer.h
Dcm, Dynamic DIDs should be excluded in lookupDid.
[arc.git] / include / cirq_buffer.h
1 /* -------------------------------- Arctic Core ------------------------------
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com
3  *
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
5  *
6  * This source code is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 as published by the
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * for more details.
14  * -------------------------------- Arctic Core ------------------------------*/
15
16 #ifndef CIRQ_BUFFER_H_
17 #define CIRQ_BUFFER_H_
18
19 #include <stddef.h>
20 #include "Platform_Types.h"
21
22 typedef struct {
23         /* The max number of elements in the list */
24         int maxCnt;
25         int currCnt;
26
27         /* Size of the elements in the list */
28         size_t dataSize;
29         /* List head and tail */
30         void *head;
31         void *tail;
32
33         /* Buffer start/stop */
34         void *bufStart;
35         void *bufEnd;
36 } CirqBufferType;
37
38 /* Dynamic implementation */
39 CirqBufferType *CirqBuffDynCreate( size_t size, size_t dataSize );
40 int CirqBuffDynDestroy(CirqBufferType *cPtr );
41
42 /* Static implementation */
43 CirqBufferType CirqBuffStatCreate(void *buffer, int maxCnt, size_t dataSize);
44
45 int CirqBuffPush( CirqBufferType *cPtr, void *dataPtr );
46 int CirqBuffPop(CirqBufferType *cPtr, void *dataPtr );
47 void *CirqBuff_PushLock( CirqBufferType *cPtr);
48 void *CirqBuff_PopLock(CirqBufferType *cPtr );
49 void CirqBuff_Init(CirqBufferType *cirqbuffer, void *buffer, int maxCnt, size_t dataSize);
50
51 static inline boolean CirqBuff_Empty(CirqBufferType *cPtr ) {
52         return (cPtr->currCnt == 0);
53 }
54 static inline void CirqBuff_PushRelease( CirqBufferType *cPtr) {
55         ++cPtr->currCnt;
56 }
57
58 static inline void CirqBuff_PopRelease( CirqBufferType *cPtr) {
59         --cPtr->currCnt;
60 }
61
62
63 #endif /* CIRQ_BUFFER_H_ */