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 */
65 lCp->first = (RgSchRrCList *)NULLP;
66 lCp->crnt = (RgSchRrCList *)NULLP;
70 } /* end of rgSCHRrCListInit */
72 /* LTE_ADV_FLAG_REMOVED_START */
74 * Fun: rgSCHRrCListAdd2Crnt
76 * Desc: adds node to linked list behind crnt.
85 Void rgSCHRrCListAdd2Crnt
87 RgSchRrCListCp *lCp, /* list control point */
88 RgSchRrCList *node /* node to be added */
91 Void rgSCHRrCListAdd2Crnt(lCp, node)
92 RgSchRrCListCp *lCp; /* list control point */
93 RgSchRrCList *node; /* node to be added */
97 if (lCp == (RgSchRrCListCp *)NULLP)
109 lCp->crnt = lCp->first;
114 node->next = lCp->crnt;
115 node->prev = lCp->crnt->prev;
116 lCp->crnt->prev->next = node;
117 lCp->crnt->prev = node;
121 /* LTE_ADV_FLAG_REMOVED_END */
125 * Fun: rgSCHRrCListAdd2Tail
127 * Desc: adds node to linked list after last.
137 Void rgSCHRrCListAdd2Tail
139 RgSchRrCListCp *lCp, /* list control point */
140 RgSchRrCList *node /* node to be added */
143 Void rgSCHRrCListAdd2Tail(lCp, node)
144 RgSchRrCListCp *lCp; /* list control point */
145 RgSchRrCList *node; /* node to be added */
150 if (lCp == (RgSchRrCListCp *)NULLP)
162 lCp->crnt = lCp->first;
167 node->next = lCp->first;
168 node->prev = lCp->first->prev;
169 lCp->first->prev->next = node;
170 lCp->first->prev = node;
173 } /* end of rgSCHRrCListAdd2Tail */
177 * Fun: rgSCHRrCListDelFrm
179 * Desc: remove node pointed to by nodePtr from list and return node.
180 * nodePtr could be anywhere in the list.
181 * - resets crnt to NULLP.
191 RgSchRrCList *rgSCHRrCListDelFrm
193 RgSchRrCListCp *lCp, /* list control pointer */
194 RgSchRrCList *node /* node to be removed */
197 RgSchRrCList *rgSCHRrCListDelFrm(lCp, node)
198 RgSchRrCListCp *lCp; /* list control pointer */
199 RgSchRrCList *node; /* node to be removed */
204 if (lCp == (RgSchRrCListCp *)NULLP)
214 if(lCp->first == node)
216 lCp->first = lCp->crnt = (RgSchRrCList *)NULLP;
218 node->next = node->prev = (RgSchRrCList *)NULLP;
224 if (lCp->first == node)
226 lCp->first->prev->next = node->next;
227 node->next->prev = lCp->first->prev;
228 lCp->first = node->next;
229 if(lCp->crnt == node)
231 lCp->crnt = node->next;
233 node->next = node->prev = (RgSchRrCList *)NULLP;
234 /* Adding this check and guarding the decrement of counter when
235 node is deleted with reshuffling */
240 if(node->prev && node->next)
242 node->prev->next = node->next;
243 node->next->prev = node->prev;
246 if(lCp->crnt == node)
248 lCp->crnt = node->next;
250 node->next = node->prev = (RgSchRrCList *)NULLP;
252 } /* end of rgSCHRrCListDelFrm */
256 * Fun: rgSCHRrCListInsrtAtCrnt
258 * Desc: Inserting the given node at CuRRENT and Moving present CURRENT
269 Void rgSCHRrCListInsrtAtCrnt
271 RgSchRrCListCp *lCp, /* list control pointer */
272 RgSchRrCList *node /* node to be removed */
275 Void rgSCHRrCListInsrtAtCrnt(lCp, node)
276 RgSchRrCListCp *lCp; /* list control pointer */
277 RgSchRrCList *node; /* node to be inserted */
283 if (lCp == (RgSchRrCListCp *)NULLP)
290 node->prev = crnt->prev;
291 crnt->prev->next = node;
300 /********************************************************************30**
303 **********************************************************************/