1 /*******************************************************************************
2 * Copyright 2003, Marvell Semiconductor Israel LTD. *
3 * THIS CODE CONTAINS CONFIDENTIAL INFORMATION OF MARVELL. *
4 * NO RIGHTS ARE GRANTED HEREIN UNDER ANY PATENT, MASK WORK RIGHT OR COPYRIGHT *
5 * OF MARVELL OR ANY THIRD PARTY. MARVELL RESERVES THE RIGHT AT ITS SOLE *
6 * DISCRETION TO REQUEST THAT THIS CODE BE IMMEDIATELY RETURNED TO MARVELL. *
7 * THIS CODE IS PROVIDED "AS IS". MARVELL MAKES NO WARRANTIES, EXPRESSED, *
8 * IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, COMPLETENESS OR PERFORMANCE. *
10 * MARVELL COMPRISES MARVELL TECHNOLOGY GROUP LTD. (MTGL) AND ITS SUBSIDIARIES, *
11 * MARVELL INTERNATIONAL LTD. (MIL), MARVELL TECHNOLOGY, INC. (MTI), MARVELL *
12 * SEMICONDUCTOR, INC. (MSI), MARVELL ASIA PTE LTD. (MAPL), MARVELL JAPAN K.K. *
13 * (MJKK), MARVELL SEMICONDUCTOR ISRAEL LTD (MSIL). *
14 ********************************************************************************
15 * mvStack.h - Header File for :
17 * FILENAME: $Workfile: mvStack.h $
18 * REVISION: $Revision: 1.1 $
19 * LAST UPDATE: $Modtime: $
22 * This file defines simple Stack (LIFO) functionality.
24 *******************************************************************************/
38 /* Data structure describes general purpose Stack */
43 MV_U32
* stackElements
;
46 static INLINE MV_BOOL
mvStackIsFull(void* stackHndl
)
48 MV_STACK
* pStack
= (MV_STACK
*)stackHndl
;
50 if(pStack
->stackIdx
== pStack
->numOfElements
)
56 static INLINE MV_BOOL
mvStackIsEmpty(void* stackHndl
)
58 MV_STACK
* pStack
= (MV_STACK
*)stackHndl
;
60 if(pStack
->stackIdx
== 0)
65 /* Purpose: Push new element to stack
67 * - void* stackHndl - Stack handle as returned by "mvStackCreate()" function.
68 * - MV_U32 value - New element.
70 * Return: MV_STATUS MV_FULL - Failure. Stack is full.
71 * MV_OK - Success. Element is put to stack.
73 static INLINE
void mvStackPush(void* stackHndl
, MV_U32 value
)
75 MV_STACK
* pStack
= (MV_STACK
*)stackHndl
;
78 if(pStack
->stackIdx
== pStack
->numOfElements
)
80 mvOsPrintf("mvStackPush: Stack is FULL\n");
83 #endif /* MV_RT_DEBUG */
85 pStack
->stackElements
[pStack
->stackIdx
] = value
;
89 /* Purpose: Pop element from the top of stack and copy it to "pValue"
91 * - void* stackHndl - Stack handle as returned by "mvStackCreate()" function.
92 * - MV_U32 value - Element in the top of stack.
94 * Return: MV_STATUS MV_EMPTY - Failure. Stack is empty.
95 * MV_OK - Success. Element is removed from the stack and
96 * copied to pValue argument
98 static INLINE MV_U32
mvStackPop(void* stackHndl
)
100 MV_STACK
* pStack
= (MV_STACK
*)stackHndl
;
103 if(pStack
->stackIdx
== 0)
105 mvOsPrintf("mvStackPop: Stack is EMPTY\n");
108 #endif /* MV_RT_DEBUG */
111 return pStack
->stackElements
[pStack
->stackIdx
];
114 static INLINE
int mvStackIndex(void* stackHndl
)
116 MV_STACK
* pStack
= (MV_STACK
*)stackHndl
;
118 return pStack
->stackIdx
;
121 static INLINE
int mvStackFreeElements(void* stackHndl
)
123 MV_STACK
* pStack
= (MV_STACK
*)stackHndl
;
125 return (pStack
->numOfElements
- pStack
->stackIdx
);
128 /* mvStack.h API list */
130 /* Create new Stack */
131 void* mvStackCreate(int numOfElements
);
133 /* Delete existing stack */
134 MV_STATUS
mvStackDelete(void* stackHndl
);
136 /* Print status of the stack */
137 void mvStackStatus(void* stackHndl
, MV_BOOL isPrintElements
);
139 #endif /* __mvStack_h__ */
This page took 0.052353 seconds and 5 git commands to generate.