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) */
33 #include "envopt.h" /* environment options */
34 #include "envdep.h" /* environment dependent */
35 #include "envind.h" /* environment independent */
37 #include "gen.h" /* general layer */
38 #include "ssi.h" /* system services */
40 /* header/extern include files (.x) */
42 #include "gen.x" /* general layer */
43 #include "ssi.x" /* system services */
44 #include "rg_sch_clist.x" /* common functions */
47 /* Linked List functions */
52 * Fun: rgSCHRrCListInit
54 * Desc: initializes a linked list control pointer.
64 PUBLIC Void rgSCHRrCListInit
66 RgSchRrCListCp *lCp /* list control point */
69 PUBLIC Void rgSCHRrCListInit(lCp)
70 RgSchRrCListCp *lCp; /* list control point */
73 TRC2(rgSCHRrCListInit);
75 lCp->first = (RgSchRrCList *)NULLP;
76 lCp->crnt = (RgSchRrCList *)NULLP;
80 } /* end of rgSCHRrCListInit */
82 /* LTE_ADV_FLAG_REMOVED_START */
84 * Fun: rgSCHRrCListAdd2Crnt
86 * Desc: adds node to linked list behind crnt.
95 PUBLIC Void rgSCHRrCListAdd2Crnt
97 RgSchRrCListCp *lCp, /* list control point */
98 RgSchRrCList *node /* node to be added */
101 PUBLIC Void rgSCHRrCListAdd2Crnt(lCp, node)
102 RgSchRrCListCp *lCp; /* list control point */
103 RgSchRrCList *node; /* node to be added */
106 TRC2(rgSCHRrCListAdd2Crnt);
108 if (lCp == (RgSchRrCListCp *)NULLP)
120 lCp->crnt = lCp->first;
125 node->next = lCp->crnt;
126 node->prev = lCp->crnt->prev;
127 lCp->crnt->prev->next = node;
128 lCp->crnt->prev = node;
132 /* LTE_ADV_FLAG_REMOVED_END */
136 * Fun: rgSCHRrCListAdd2Tail
138 * Desc: adds node to linked list after last.
148 PUBLIC Void rgSCHRrCListAdd2Tail
150 RgSchRrCListCp *lCp, /* list control point */
151 RgSchRrCList *node /* node to be added */
154 PUBLIC Void rgSCHRrCListAdd2Tail(lCp, node)
155 RgSchRrCListCp *lCp; /* list control point */
156 RgSchRrCList *node; /* node to be added */
159 TRC2(rgSCHRrCListAdd2Tail);
162 if (lCp == (RgSchRrCListCp *)NULLP)
174 lCp->crnt = lCp->first;
179 node->next = lCp->first;
180 node->prev = lCp->first->prev;
181 lCp->first->prev->next = node;
182 lCp->first->prev = node;
185 } /* end of rgSCHRrCListAdd2Tail */
189 * Fun: rgSCHRrCListDelFrm
191 * Desc: remove node pointed to by nodePtr from list and return node.
192 * nodePtr could be anywhere in the list.
193 * - resets crnt to NULLP.
203 PUBLIC RgSchRrCList *rgSCHRrCListDelFrm
205 RgSchRrCListCp *lCp, /* list control pointer */
206 RgSchRrCList *node /* node to be removed */
209 PUBLIC RgSchRrCList *rgSCHRrCListDelFrm(lCp, node)
210 RgSchRrCListCp *lCp; /* list control pointer */
211 RgSchRrCList *node; /* node to be removed */
214 TRC2(rgSCHRrCListDelFrm);
217 if (lCp == (RgSchRrCListCp *)NULLP)
227 if(lCp->first == node)
229 lCp->first = lCp->crnt = (RgSchRrCList *)NULLP;
231 node->next = node->prev = (RgSchRrCList *)NULLP;
237 if (lCp->first == node)
239 lCp->first->prev->next = node->next;
240 node->next->prev = lCp->first->prev;
241 lCp->first = node->next;
242 if(lCp->crnt == node)
244 lCp->crnt = node->next;
246 node->next = node->prev = (RgSchRrCList *)NULLP;
247 /* Adding this check and guarding the decrement of counter when
248 node is deleted with reshuffling */
253 if(node->prev && node->next)
255 node->prev->next = node->next;
256 node->next->prev = node->prev;
259 if(lCp->crnt == node)
261 lCp->crnt = node->next;
263 node->next = node->prev = (RgSchRrCList *)NULLP;
265 } /* end of rgSCHRrCListDelFrm */
269 * Fun: rgSCHRrCListInsrtAtCrnt
271 * Desc: Inserting the given node at CuRRENT and Moving present CURRENT
282 PUBLIC Void rgSCHRrCListInsrtAtCrnt
284 RgSchRrCListCp *lCp, /* list control pointer */
285 RgSchRrCList *node /* node to be removed */
288 PUBLIC Void rgSCHRrCListInsrtAtCrnt(lCp, node)
289 RgSchRrCListCp *lCp; /* list control pointer */
290 RgSchRrCList *node; /* node to be inserted */
294 TRC2(rgSCHRrCListInsrtAtCrnt);
297 if (lCp == (RgSchRrCListCp *)NULLP)
304 node->prev = crnt->prev;
305 crnt->prev->next = node;
314 /********************************************************************30**
317 **********************************************************************/