1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /********************************************************************20**
21 Name: common functions - linked list management
25 Desc: common functions for linked lists
27 File: rg_sch_utl_clist.c
29 *********************************************************************21*/
31 /* header include files (.h) */
32 #include "common_def.h"
34 /* header/extern include files (.x) */
35 #include "rg_sch_clist.x" /* common functions */
38 /* Linked List functions */
43 * Fun: rgSCHRrCListInit
45 * Desc: initializes a linked list control pointer.
57 RgSchRrCListCp *lCp /* list control point */
60 Void rgSCHRrCListInit(lCp)
61 RgSchRrCListCp *lCp; /* list control point */
64 TRC2(rgSCHRrCListInit);
66 lCp->first = (RgSchRrCList *)NULLP;
67 lCp->crnt = (RgSchRrCList *)NULLP;
71 } /* end of rgSCHRrCListInit */
73 /* LTE_ADV_FLAG_REMOVED_START */
75 * Fun: rgSCHRrCListAdd2Crnt
77 * Desc: adds node to linked list behind crnt.
86 Void rgSCHRrCListAdd2Crnt
88 RgSchRrCListCp *lCp, /* list control point */
89 RgSchRrCList *node /* node to be added */
92 Void rgSCHRrCListAdd2Crnt(lCp, node)
93 RgSchRrCListCp *lCp; /* list control point */
94 RgSchRrCList *node; /* node to be added */
97 TRC2(rgSCHRrCListAdd2Crnt);
99 if (lCp == (RgSchRrCListCp *)NULLP)
111 lCp->crnt = lCp->first;
116 node->next = lCp->crnt;
117 node->prev = lCp->crnt->prev;
118 lCp->crnt->prev->next = node;
119 lCp->crnt->prev = node;
123 /* LTE_ADV_FLAG_REMOVED_END */
127 * Fun: rgSCHRrCListAdd2Tail
129 * Desc: adds node to linked list after last.
139 Void rgSCHRrCListAdd2Tail
141 RgSchRrCListCp *lCp, /* list control point */
142 RgSchRrCList *node /* node to be added */
145 Void rgSCHRrCListAdd2Tail(lCp, node)
146 RgSchRrCListCp *lCp; /* list control point */
147 RgSchRrCList *node; /* node to be added */
150 TRC2(rgSCHRrCListAdd2Tail);
153 if (lCp == (RgSchRrCListCp *)NULLP)
165 lCp->crnt = lCp->first;
170 node->next = lCp->first;
171 node->prev = lCp->first->prev;
172 lCp->first->prev->next = node;
173 lCp->first->prev = node;
176 } /* end of rgSCHRrCListAdd2Tail */
180 * Fun: rgSCHRrCListDelFrm
182 * Desc: remove node pointed to by nodePtr from list and return node.
183 * nodePtr could be anywhere in the list.
184 * - resets crnt to NULLP.
194 RgSchRrCList *rgSCHRrCListDelFrm
196 RgSchRrCListCp *lCp, /* list control pointer */
197 RgSchRrCList *node /* node to be removed */
200 RgSchRrCList *rgSCHRrCListDelFrm(lCp, node)
201 RgSchRrCListCp *lCp; /* list control pointer */
202 RgSchRrCList *node; /* node to be removed */
205 TRC2(rgSCHRrCListDelFrm);
208 if (lCp == (RgSchRrCListCp *)NULLP)
218 if(lCp->first == node)
220 lCp->first = lCp->crnt = (RgSchRrCList *)NULLP;
222 node->next = node->prev = (RgSchRrCList *)NULLP;
228 if (lCp->first == node)
230 lCp->first->prev->next = node->next;
231 node->next->prev = lCp->first->prev;
232 lCp->first = node->next;
233 if(lCp->crnt == node)
235 lCp->crnt = node->next;
237 node->next = node->prev = (RgSchRrCList *)NULLP;
238 /* Adding this check and guarding the decrement of counter when
239 node is deleted with reshuffling */
244 if(node->prev && node->next)
246 node->prev->next = node->next;
247 node->next->prev = node->prev;
250 if(lCp->crnt == node)
252 lCp->crnt = node->next;
254 node->next = node->prev = (RgSchRrCList *)NULLP;
256 } /* end of rgSCHRrCListDelFrm */
260 * Fun: rgSCHRrCListInsrtAtCrnt
262 * Desc: Inserting the given node at CuRRENT and Moving present CURRENT
273 Void rgSCHRrCListInsrtAtCrnt
275 RgSchRrCListCp *lCp, /* list control pointer */
276 RgSchRrCList *node /* node to be removed */
279 Void rgSCHRrCListInsrtAtCrnt(lCp, node)
280 RgSchRrCListCp *lCp; /* list control pointer */
281 RgSchRrCList *node; /* node to be inserted */
285 TRC2(rgSCHRrCListInsrtAtCrnt);
288 if (lCp == (RgSchRrCListCp *)NULLP)
295 node->prev = crnt->prev;
296 crnt->prev->next = node;
305 /********************************************************************30**
308 **********************************************************************/