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.
56 RgSchRrCListCp *lCp /* list control point */
60 lCp->first = (RgSchRrCList *)NULLP;
61 lCp->crnt = (RgSchRrCList *)NULLP;
65 } /* end of rgSCHRrCListInit */
67 /* LTE_ADV_FLAG_REMOVED_START */
69 * Fun: rgSCHRrCListAdd2Crnt
71 * Desc: adds node to linked list behind crnt.
79 Void rgSCHRrCListAdd2Crnt
81 RgSchRrCListCp *lCp, /* list control point */
82 RgSchRrCList *node /* node to be added */
86 if (lCp == (RgSchRrCListCp *)NULLP)
98 lCp->crnt = lCp->first;
103 node->next = lCp->crnt;
104 node->prev = lCp->crnt->prev;
105 lCp->crnt->prev->next = node;
106 lCp->crnt->prev = node;
110 /* LTE_ADV_FLAG_REMOVED_END */
114 * Fun: rgSCHRrCListAdd2Tail
116 * Desc: adds node to linked list after last.
125 Void rgSCHRrCListAdd2Tail
127 RgSchRrCListCp *lCp, /* list control point */
128 RgSchRrCList *node /* node to be added */
133 if (lCp == (RgSchRrCListCp *)NULLP)
145 lCp->crnt = lCp->first;
150 node->next = lCp->first;
151 node->prev = lCp->first->prev;
152 lCp->first->prev->next = node;
153 lCp->first->prev = node;
156 } /* end of rgSCHRrCListAdd2Tail */
160 * Fun: rgSCHRrCListDelFrm
162 * Desc: remove node pointed to by nodePtr from list and return node.
163 * nodePtr could be anywhere in the list.
164 * - resets crnt to NULLP.
173 RgSchRrCList *rgSCHRrCListDelFrm
175 RgSchRrCListCp *lCp, /* list control pointer */
176 RgSchRrCList *node /* node to be removed */
181 if (lCp == (RgSchRrCListCp *)NULLP)
191 if(lCp->first == node)
193 lCp->first = lCp->crnt = (RgSchRrCList *)NULLP;
195 node->next = node->prev = (RgSchRrCList *)NULLP;
201 if (lCp->first == node)
203 lCp->first->prev->next = node->next;
204 node->next->prev = lCp->first->prev;
205 lCp->first = node->next;
206 if(lCp->crnt == node)
208 lCp->crnt = node->next;
210 node->next = node->prev = (RgSchRrCList *)NULLP;
211 /* Adding this check and guarding the decrement of counter when
212 node is deleted with reshuffling */
217 if(node->prev && node->next)
219 node->prev->next = node->next;
220 node->next->prev = node->prev;
223 if(lCp->crnt == node)
225 lCp->crnt = node->next;
227 node->next = node->prev = (RgSchRrCList *)NULLP;
229 } /* end of rgSCHRrCListDelFrm */
233 * Fun: rgSCHRrCListInsrtAtCrnt
235 * Desc: Inserting the given node at CuRRENT and Moving present CURRENT
245 Void rgSCHRrCListInsrtAtCrnt
247 RgSchRrCListCp *lCp, /* list control pointer */
248 RgSchRrCList *node /* node to be removed */
254 if (lCp == (RgSchRrCListCp *)NULLP)
261 node->prev = crnt->prev;
262 crnt->prev->next = node;
271 /********************************************************************30**
274 **********************************************************************/