xref: /freebsd-src/sys/contrib/ncsw/inc/etc/list_ext.h (revision c2c014f24c10f90d85126ac5fbd4d8524de32b1c)
1*852ba100SJustin Hibbits /* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
20aeed3e9SJustin Hibbits  * All rights reserved.
30aeed3e9SJustin Hibbits  *
40aeed3e9SJustin Hibbits  * Redistribution and use in source and binary forms, with or without
50aeed3e9SJustin Hibbits  * modification, are permitted provided that the following conditions are met:
60aeed3e9SJustin Hibbits  *     * Redistributions of source code must retain the above copyright
70aeed3e9SJustin Hibbits  *       notice, this list of conditions and the following disclaimer.
80aeed3e9SJustin Hibbits  *     * Redistributions in binary form must reproduce the above copyright
90aeed3e9SJustin Hibbits  *       notice, this list of conditions and the following disclaimer in the
100aeed3e9SJustin Hibbits  *       documentation and/or other materials provided with the distribution.
110aeed3e9SJustin Hibbits  *     * Neither the name of Freescale Semiconductor nor the
120aeed3e9SJustin Hibbits  *       names of its contributors may be used to endorse or promote products
130aeed3e9SJustin Hibbits  *       derived from this software without specific prior written permission.
140aeed3e9SJustin Hibbits  *
150aeed3e9SJustin Hibbits  *
160aeed3e9SJustin Hibbits  * ALTERNATIVELY, this software may be distributed under the terms of the
170aeed3e9SJustin Hibbits  * GNU General Public License ("GPL") as published by the Free Software
180aeed3e9SJustin Hibbits  * Foundation, either version 2 of that License or (at your option) any
190aeed3e9SJustin Hibbits  * later version.
200aeed3e9SJustin Hibbits  *
210aeed3e9SJustin Hibbits  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
220aeed3e9SJustin Hibbits  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
230aeed3e9SJustin Hibbits  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
240aeed3e9SJustin Hibbits  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
250aeed3e9SJustin Hibbits  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
260aeed3e9SJustin Hibbits  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
270aeed3e9SJustin Hibbits  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
280aeed3e9SJustin Hibbits  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
290aeed3e9SJustin Hibbits  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
300aeed3e9SJustin Hibbits  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
310aeed3e9SJustin Hibbits  */
320aeed3e9SJustin Hibbits 
33*852ba100SJustin Hibbits 
340aeed3e9SJustin Hibbits /**************************************************************************//**
350aeed3e9SJustin Hibbits 
360aeed3e9SJustin Hibbits  @File          list_ext.h
370aeed3e9SJustin Hibbits 
380aeed3e9SJustin Hibbits  @Description   External prototypes for list.c
390aeed3e9SJustin Hibbits *//***************************************************************************/
400aeed3e9SJustin Hibbits 
410aeed3e9SJustin Hibbits #ifndef __LIST_EXT_H
420aeed3e9SJustin Hibbits #define __LIST_EXT_H
430aeed3e9SJustin Hibbits 
440aeed3e9SJustin Hibbits 
450aeed3e9SJustin Hibbits #include "std_ext.h"
460aeed3e9SJustin Hibbits 
470aeed3e9SJustin Hibbits 
480aeed3e9SJustin Hibbits /**************************************************************************//**
490aeed3e9SJustin Hibbits  @Group         etc_id   Utility Library Application Programming Interface
500aeed3e9SJustin Hibbits 
510aeed3e9SJustin Hibbits  @Description   External routines.
520aeed3e9SJustin Hibbits 
530aeed3e9SJustin Hibbits  @{
540aeed3e9SJustin Hibbits *//***************************************************************************/
550aeed3e9SJustin Hibbits 
560aeed3e9SJustin Hibbits /**************************************************************************//**
570aeed3e9SJustin Hibbits  @Group         list_id List
580aeed3e9SJustin Hibbits 
590aeed3e9SJustin Hibbits  @Description   List module functions,definitions and enums.
600aeed3e9SJustin Hibbits 
610aeed3e9SJustin Hibbits  @{
620aeed3e9SJustin Hibbits *//***************************************************************************/
630aeed3e9SJustin Hibbits 
640aeed3e9SJustin Hibbits /**************************************************************************//**
650aeed3e9SJustin Hibbits  @Description   List structure.
660aeed3e9SJustin Hibbits *//***************************************************************************/
670aeed3e9SJustin Hibbits typedef struct List
680aeed3e9SJustin Hibbits {
690aeed3e9SJustin Hibbits     struct List *p_Next;  /**< A pointer to the next list object     */
700aeed3e9SJustin Hibbits     struct List *p_Prev;  /**< A pointer to the previous list object */
710aeed3e9SJustin Hibbits } t_List;
720aeed3e9SJustin Hibbits 
730aeed3e9SJustin Hibbits 
740aeed3e9SJustin Hibbits /**************************************************************************//**
75*852ba100SJustin Hibbits  @Function      NCSW_LIST_FIRST/NCSW_LIST_LAST/NCSW_LIST_NEXT/NCSW_LIST_PREV
760aeed3e9SJustin Hibbits 
770aeed3e9SJustin Hibbits  @Description   Macro to get first/last/next/previous entry in a list.
780aeed3e9SJustin Hibbits 
790aeed3e9SJustin Hibbits  @Param[in]     p_List - A pointer to a list.
800aeed3e9SJustin Hibbits *//***************************************************************************/
810aeed3e9SJustin Hibbits #define NCSW_LIST_FIRST(p_List) (p_List)->p_Next
82*852ba100SJustin Hibbits #define NCSW_LIST_LAST(p_List)  (p_List)->p_Prev
830aeed3e9SJustin Hibbits #define NCSW_LIST_NEXT          NCSW_LIST_FIRST
84*852ba100SJustin Hibbits #define NCSW_LIST_PREV          NCSW_LIST_LAST
850aeed3e9SJustin Hibbits 
860aeed3e9SJustin Hibbits 
870aeed3e9SJustin Hibbits /**************************************************************************//**
880aeed3e9SJustin Hibbits  @Function      NCSW_LIST_INIT
890aeed3e9SJustin Hibbits 
900aeed3e9SJustin Hibbits  @Description   Macro for initialization of a list struct.
910aeed3e9SJustin Hibbits 
920aeed3e9SJustin Hibbits  @Param[in]     lst - The t_List object to initialize.
930aeed3e9SJustin Hibbits *//***************************************************************************/
940aeed3e9SJustin Hibbits #define NCSW_LIST_INIT(lst) {&(lst), &(lst)}
950aeed3e9SJustin Hibbits 
960aeed3e9SJustin Hibbits 
970aeed3e9SJustin Hibbits /**************************************************************************//**
98*852ba100SJustin Hibbits  @Function      NCSW_LIST
990aeed3e9SJustin Hibbits 
1000aeed3e9SJustin Hibbits  @Description   Macro to declare of a list.
1010aeed3e9SJustin Hibbits 
1020aeed3e9SJustin Hibbits  @Param[in]     listName - The list object name.
1030aeed3e9SJustin Hibbits *//***************************************************************************/
104*852ba100SJustin Hibbits #define NCSW_LIST(listName) t_List listName = NCSW_LIST_INIT(listName)
1050aeed3e9SJustin Hibbits 
1060aeed3e9SJustin Hibbits 
1070aeed3e9SJustin Hibbits /**************************************************************************//**
1080aeed3e9SJustin Hibbits  @Function      INIT_LIST
1090aeed3e9SJustin Hibbits 
1100aeed3e9SJustin Hibbits  @Description   Macro to initialize a list pointer.
1110aeed3e9SJustin Hibbits 
1120aeed3e9SJustin Hibbits  @Param[in]     p_List - The list pointer.
1130aeed3e9SJustin Hibbits *//***************************************************************************/
114*852ba100SJustin Hibbits #define INIT_LIST(p_List)   NCSW_LIST_FIRST(p_List) = NCSW_LIST_LAST(p_List) = (p_List)
1150aeed3e9SJustin Hibbits 
1160aeed3e9SJustin Hibbits 
1170aeed3e9SJustin Hibbits /**************************************************************************//**
118*852ba100SJustin Hibbits  @Function      NCSW_LIST_OBJECT
1190aeed3e9SJustin Hibbits 
1200aeed3e9SJustin Hibbits  @Description   Macro to get the struct (object) for this entry.
1210aeed3e9SJustin Hibbits 
1220aeed3e9SJustin Hibbits  @Param[in]     type   - The type of the struct (object) this list is embedded in.
1230aeed3e9SJustin Hibbits  @Param[in]     member - The name of the t_List object within the struct.
1240aeed3e9SJustin Hibbits 
1250aeed3e9SJustin Hibbits  @Return        The structure pointer for this entry.
1260aeed3e9SJustin Hibbits *//***************************************************************************/
1270aeed3e9SJustin Hibbits #define MEMBER_OFFSET(type, member) (PTR_TO_UINT(&((type *)0)->member))
128*852ba100SJustin Hibbits #define NCSW_LIST_OBJECT(p_List, type, member) \
1290aeed3e9SJustin Hibbits     ((type *)((char *)(p_List)-MEMBER_OFFSET(type, member)))
1300aeed3e9SJustin Hibbits 
1310aeed3e9SJustin Hibbits 
1320aeed3e9SJustin Hibbits /**************************************************************************//**
133*852ba100SJustin Hibbits  @Function      NCSW_LIST_FOR_EACH
1340aeed3e9SJustin Hibbits 
1350aeed3e9SJustin Hibbits  @Description   Macro to iterate over a list.
1360aeed3e9SJustin Hibbits 
1370aeed3e9SJustin Hibbits  @Param[in]     p_Pos  - A pointer to a list to use as a loop counter.
1380aeed3e9SJustin Hibbits  @Param[in]     p_Head - A pointer to the head for your list pointer.
1390aeed3e9SJustin Hibbits 
1400aeed3e9SJustin Hibbits  @Cautions      You can't delete items with this routine.
141*852ba100SJustin Hibbits                 For deletion use NCSW_LIST_FOR_EACH_SAFE().
1420aeed3e9SJustin Hibbits *//***************************************************************************/
143*852ba100SJustin Hibbits #define NCSW_LIST_FOR_EACH(p_Pos, p_Head) \
1440aeed3e9SJustin Hibbits     for (p_Pos = NCSW_LIST_FIRST(p_Head); p_Pos != (p_Head); p_Pos = NCSW_LIST_NEXT(p_Pos))
1450aeed3e9SJustin Hibbits 
1460aeed3e9SJustin Hibbits 
1470aeed3e9SJustin Hibbits /**************************************************************************//**
148*852ba100SJustin Hibbits  @Function      NCSW_LIST_FOR_EACH_SAFE
1490aeed3e9SJustin Hibbits 
1500aeed3e9SJustin Hibbits  @Description   Macro to iterate over a list safe against removal of list entry.
1510aeed3e9SJustin Hibbits 
1520aeed3e9SJustin Hibbits  @Param[in]     p_Pos  - A pointer to a list to use as a loop counter.
1530aeed3e9SJustin Hibbits  @Param[in]     p_Tmp  - Another pointer to a list to use as temporary storage.
1540aeed3e9SJustin Hibbits  @Param[in]     p_Head - A pointer to the head for your list pointer.
1550aeed3e9SJustin Hibbits *//***************************************************************************/
156*852ba100SJustin Hibbits #define NCSW_LIST_FOR_EACH_SAFE(p_Pos, p_Tmp, p_Head)                \
1570aeed3e9SJustin Hibbits     for (p_Pos = NCSW_LIST_FIRST(p_Head), p_Tmp = NCSW_LIST_FIRST(p_Pos); \
1580aeed3e9SJustin Hibbits          p_Pos != (p_Head);                                     \
1590aeed3e9SJustin Hibbits          p_Pos = p_Tmp, p_Tmp = NCSW_LIST_NEXT(p_Pos))
1600aeed3e9SJustin Hibbits 
1610aeed3e9SJustin Hibbits 
1620aeed3e9SJustin Hibbits /**************************************************************************//**
163*852ba100SJustin Hibbits  @Function      NCSW_LIST_FOR_EACH_OBJECT_SAFE
1640aeed3e9SJustin Hibbits 
1650aeed3e9SJustin Hibbits  @Description   Macro to iterate over list of given type safely.
1660aeed3e9SJustin Hibbits 
1670aeed3e9SJustin Hibbits  @Param[in]     p_Pos  - A pointer to a list to use as a loop counter.
1680aeed3e9SJustin Hibbits  @Param[in]     p_Tmp  - Another pointer to a list to use as temporary storage.
1690aeed3e9SJustin Hibbits  @Param[in]     type   - The type of the struct this is embedded in.
1700aeed3e9SJustin Hibbits  @Param[in]     p_Head - A pointer to the head for your list pointer.
1710aeed3e9SJustin Hibbits  @Param[in]     member - The name of the list_struct within the struct.
1720aeed3e9SJustin Hibbits 
1730aeed3e9SJustin Hibbits  @Cautions      You can't delete items with this routine.
174*852ba100SJustin Hibbits                 For deletion use NCSW_LIST_FOR_EACH_SAFE().
1750aeed3e9SJustin Hibbits *//***************************************************************************/
176*852ba100SJustin Hibbits #define NCSW_LIST_FOR_EACH_OBJECT_SAFE(p_Pos, p_Tmp, p_Head, type, member)      \
177*852ba100SJustin Hibbits     for (p_Pos = NCSW_LIST_OBJECT(NCSW_LIST_FIRST(p_Head), type, member),            \
178*852ba100SJustin Hibbits          p_Tmp = NCSW_LIST_OBJECT(NCSW_LIST_FIRST(&p_Pos->member), type, member);    \
1790aeed3e9SJustin Hibbits          &p_Pos->member != (p_Head);                                       \
1800aeed3e9SJustin Hibbits          p_Pos = p_Tmp,                                                    \
181*852ba100SJustin Hibbits          p_Tmp = NCSW_LIST_OBJECT(NCSW_LIST_FIRST(&p_Pos->member), type, member))
1820aeed3e9SJustin Hibbits 
1830aeed3e9SJustin Hibbits /**************************************************************************//**
184*852ba100SJustin Hibbits  @Function      NCSW_LIST_FOR_EACH_OBJECT
1850aeed3e9SJustin Hibbits 
1860aeed3e9SJustin Hibbits  @Description   Macro to iterate over list of given type.
1870aeed3e9SJustin Hibbits 
1880aeed3e9SJustin Hibbits  @Param[in]     p_Pos  - A pointer to a list to use as a loop counter.
1890aeed3e9SJustin Hibbits  @Param[in]     type   - The type of the struct this is embedded in.
1900aeed3e9SJustin Hibbits  @Param[in]     p_Head - A pointer to the head for your list pointer.
1910aeed3e9SJustin Hibbits  @Param[in]     member - The name of the list_struct within the struct.
1920aeed3e9SJustin Hibbits 
1930aeed3e9SJustin Hibbits  @Cautions      You can't delete items with this routine.
194*852ba100SJustin Hibbits                 For deletion use NCSW_LIST_FOR_EACH_SAFE().
1950aeed3e9SJustin Hibbits *//***************************************************************************/
196*852ba100SJustin Hibbits #define NCSW_LIST_FOR_EACH_OBJECT(p_Pos, type, p_Head, member)                  \
197*852ba100SJustin Hibbits     for (p_Pos = NCSW_LIST_OBJECT(NCSW_LIST_FIRST(p_Head), type, member);            \
1980aeed3e9SJustin Hibbits          &p_Pos->member != (p_Head);                                       \
199*852ba100SJustin Hibbits          p_Pos = NCSW_LIST_OBJECT(NCSW_LIST_FIRST(&(p_Pos->member)), type, member))
2000aeed3e9SJustin Hibbits 
2010aeed3e9SJustin Hibbits 
2020aeed3e9SJustin Hibbits /**************************************************************************//**
203*852ba100SJustin Hibbits  @Function      NCSW_LIST_Add
2040aeed3e9SJustin Hibbits 
2050aeed3e9SJustin Hibbits  @Description   Add a new entry to a list.
2060aeed3e9SJustin Hibbits 
2070aeed3e9SJustin Hibbits                 Insert a new entry after the specified head.
2080aeed3e9SJustin Hibbits                 This is good for implementing stacks.
2090aeed3e9SJustin Hibbits 
2100aeed3e9SJustin Hibbits  @Param[in]     p_New  - A pointer to a new list entry to be added.
2110aeed3e9SJustin Hibbits  @Param[in]     p_Head - A pointer to a list head to add it after.
2120aeed3e9SJustin Hibbits 
2130aeed3e9SJustin Hibbits  @Return        none.
2140aeed3e9SJustin Hibbits *//***************************************************************************/
NCSW_LIST_Add(t_List * p_New,t_List * p_Head)215*852ba100SJustin Hibbits static __inline__ void NCSW_LIST_Add(t_List *p_New, t_List *p_Head)
2160aeed3e9SJustin Hibbits {
2170aeed3e9SJustin Hibbits     NCSW_LIST_PREV(NCSW_LIST_NEXT(p_Head)) = p_New;
2180aeed3e9SJustin Hibbits     NCSW_LIST_NEXT(p_New)             = NCSW_LIST_NEXT(p_Head);
2190aeed3e9SJustin Hibbits     NCSW_LIST_PREV(p_New)             = p_Head;
2200aeed3e9SJustin Hibbits     NCSW_LIST_NEXT(p_Head)            = p_New;
2210aeed3e9SJustin Hibbits }
2220aeed3e9SJustin Hibbits 
2230aeed3e9SJustin Hibbits 
2240aeed3e9SJustin Hibbits /**************************************************************************//**
225*852ba100SJustin Hibbits  @Function      NCSW_LIST_AddToTail
2260aeed3e9SJustin Hibbits 
2270aeed3e9SJustin Hibbits  @Description   Add a new entry to a list.
2280aeed3e9SJustin Hibbits 
2290aeed3e9SJustin Hibbits                 Insert a new entry before the specified head.
2300aeed3e9SJustin Hibbits                 This is useful for implementing queues.
2310aeed3e9SJustin Hibbits 
2320aeed3e9SJustin Hibbits  @Param[in]     p_New  - A pointer to a new list entry to be added.
233*852ba100SJustin Hibbits  @Param[in]     p_Head - A pointer to a list head to add it before.
2340aeed3e9SJustin Hibbits 
2350aeed3e9SJustin Hibbits  @Return        none.
2360aeed3e9SJustin Hibbits *//***************************************************************************/
NCSW_LIST_AddToTail(t_List * p_New,t_List * p_Head)237*852ba100SJustin Hibbits static __inline__ void NCSW_LIST_AddToTail(t_List *p_New, t_List *p_Head)
2380aeed3e9SJustin Hibbits {
2390aeed3e9SJustin Hibbits     NCSW_LIST_NEXT(NCSW_LIST_PREV(p_Head)) = p_New;
2400aeed3e9SJustin Hibbits     NCSW_LIST_PREV(p_New)             = NCSW_LIST_PREV(p_Head);
2410aeed3e9SJustin Hibbits     NCSW_LIST_NEXT(p_New)             = p_Head;
2420aeed3e9SJustin Hibbits     NCSW_LIST_PREV(p_Head)            = p_New;
2430aeed3e9SJustin Hibbits }
2440aeed3e9SJustin Hibbits 
2450aeed3e9SJustin Hibbits 
2460aeed3e9SJustin Hibbits /**************************************************************************//**
247*852ba100SJustin Hibbits  @Function      NCSW_LIST_Del
2480aeed3e9SJustin Hibbits 
2490aeed3e9SJustin Hibbits  @Description   Deletes entry from a list.
2500aeed3e9SJustin Hibbits 
2510aeed3e9SJustin Hibbits  @Param[in]     p_Entry - A pointer to the element to delete from the list.
2520aeed3e9SJustin Hibbits 
2530aeed3e9SJustin Hibbits  @Return        none.
2540aeed3e9SJustin Hibbits 
255*852ba100SJustin Hibbits  @Cautions      NCSW_LIST_IsEmpty() on entry does not return true after this,
2560aeed3e9SJustin Hibbits                 the entry is in an undefined state.
2570aeed3e9SJustin Hibbits *//***************************************************************************/
NCSW_LIST_Del(t_List * p_Entry)258*852ba100SJustin Hibbits static __inline__ void NCSW_LIST_Del(t_List *p_Entry)
2590aeed3e9SJustin Hibbits {
2600aeed3e9SJustin Hibbits     NCSW_LIST_PREV(NCSW_LIST_NEXT(p_Entry)) = NCSW_LIST_PREV(p_Entry);
2610aeed3e9SJustin Hibbits     NCSW_LIST_NEXT(NCSW_LIST_PREV(p_Entry)) = NCSW_LIST_NEXT(p_Entry);
2620aeed3e9SJustin Hibbits }
2630aeed3e9SJustin Hibbits 
2640aeed3e9SJustin Hibbits 
2650aeed3e9SJustin Hibbits /**************************************************************************//**
266*852ba100SJustin Hibbits  @Function      NCSW_LIST_DelAndInit
2670aeed3e9SJustin Hibbits 
2680aeed3e9SJustin Hibbits  @Description   Deletes entry from list and reinitialize it.
2690aeed3e9SJustin Hibbits 
2700aeed3e9SJustin Hibbits  @Param[in]     p_Entry - A pointer to the element to delete from the list.
2710aeed3e9SJustin Hibbits 
2720aeed3e9SJustin Hibbits  @Return        none.
2730aeed3e9SJustin Hibbits *//***************************************************************************/
NCSW_LIST_DelAndInit(t_List * p_Entry)274*852ba100SJustin Hibbits static __inline__ void NCSW_LIST_DelAndInit(t_List *p_Entry)
2750aeed3e9SJustin Hibbits {
276*852ba100SJustin Hibbits     NCSW_LIST_Del(p_Entry);
2770aeed3e9SJustin Hibbits     INIT_LIST(p_Entry);
2780aeed3e9SJustin Hibbits }
2790aeed3e9SJustin Hibbits 
2800aeed3e9SJustin Hibbits 
2810aeed3e9SJustin Hibbits /**************************************************************************//**
282*852ba100SJustin Hibbits  @Function      NCSW_LIST_Move
2830aeed3e9SJustin Hibbits 
2840aeed3e9SJustin Hibbits  @Description   Delete from one list and add as another's head.
2850aeed3e9SJustin Hibbits 
2860aeed3e9SJustin Hibbits  @Param[in]     p_Entry - A pointer to the list entry to move.
2870aeed3e9SJustin Hibbits  @Param[in]     p_Head  - A pointer to the list head that will precede our entry.
2880aeed3e9SJustin Hibbits 
2890aeed3e9SJustin Hibbits  @Return        none.
2900aeed3e9SJustin Hibbits *//***************************************************************************/
NCSW_LIST_Move(t_List * p_Entry,t_List * p_Head)291*852ba100SJustin Hibbits static __inline__ void NCSW_LIST_Move(t_List *p_Entry, t_List *p_Head)
2920aeed3e9SJustin Hibbits {
293*852ba100SJustin Hibbits     NCSW_LIST_Del(p_Entry);
294*852ba100SJustin Hibbits     NCSW_LIST_Add(p_Entry, p_Head);
2950aeed3e9SJustin Hibbits }
2960aeed3e9SJustin Hibbits 
2970aeed3e9SJustin Hibbits 
2980aeed3e9SJustin Hibbits /**************************************************************************//**
299*852ba100SJustin Hibbits  @Function      NCSW_LIST_MoveToTail
3000aeed3e9SJustin Hibbits 
3010aeed3e9SJustin Hibbits  @Description   Delete from one list and add as another's tail.
3020aeed3e9SJustin Hibbits 
3030aeed3e9SJustin Hibbits  @Param[in]     p_Entry - A pointer to the entry to move.
3040aeed3e9SJustin Hibbits  @Param[in]     p_Head  - A pointer to the list head that will follow our entry.
3050aeed3e9SJustin Hibbits 
3060aeed3e9SJustin Hibbits  @Return        none.
3070aeed3e9SJustin Hibbits *//***************************************************************************/
NCSW_LIST_MoveToTail(t_List * p_Entry,t_List * p_Head)308*852ba100SJustin Hibbits static __inline__ void NCSW_LIST_MoveToTail(t_List *p_Entry, t_List *p_Head)
3090aeed3e9SJustin Hibbits {
310*852ba100SJustin Hibbits     NCSW_LIST_Del(p_Entry);
311*852ba100SJustin Hibbits     NCSW_LIST_AddToTail(p_Entry, p_Head);
3120aeed3e9SJustin Hibbits }
3130aeed3e9SJustin Hibbits 
3140aeed3e9SJustin Hibbits 
3150aeed3e9SJustin Hibbits /**************************************************************************//**
316*852ba100SJustin Hibbits  @Function      NCSW_LIST_IsEmpty
3170aeed3e9SJustin Hibbits 
3180aeed3e9SJustin Hibbits  @Description   Tests whether a list is empty.
3190aeed3e9SJustin Hibbits 
3200aeed3e9SJustin Hibbits  @Param[in]     p_List - A pointer to the list to test.
3210aeed3e9SJustin Hibbits 
3220aeed3e9SJustin Hibbits  @Return        1 if the list is empty, 0 otherwise.
3230aeed3e9SJustin Hibbits *//***************************************************************************/
NCSW_LIST_IsEmpty(t_List * p_List)324*852ba100SJustin Hibbits static __inline__ int NCSW_LIST_IsEmpty(t_List *p_List)
3250aeed3e9SJustin Hibbits {
3260aeed3e9SJustin Hibbits     return (NCSW_LIST_FIRST(p_List) == p_List);
3270aeed3e9SJustin Hibbits }
3280aeed3e9SJustin Hibbits 
3290aeed3e9SJustin Hibbits 
3300aeed3e9SJustin Hibbits /**************************************************************************//**
331*852ba100SJustin Hibbits  @Function      NCSW_LIST_Append
3320aeed3e9SJustin Hibbits 
3330aeed3e9SJustin Hibbits  @Description   Join two lists.
3340aeed3e9SJustin Hibbits 
3350aeed3e9SJustin Hibbits  @Param[in]     p_NewList - A pointer to the new list to add.
3360aeed3e9SJustin Hibbits  @Param[in]     p_Head    - A pointer to the place to add it in the first list.
3370aeed3e9SJustin Hibbits 
3380aeed3e9SJustin Hibbits  @Return        none.
3390aeed3e9SJustin Hibbits *//***************************************************************************/
340*852ba100SJustin Hibbits void NCSW_LIST_Append(t_List *p_NewList, t_List *p_Head);
3410aeed3e9SJustin Hibbits 
3420aeed3e9SJustin Hibbits 
3430aeed3e9SJustin Hibbits /**************************************************************************//**
344*852ba100SJustin Hibbits  @Function      NCSW_LIST_NumOfObjs
3450aeed3e9SJustin Hibbits 
3460aeed3e9SJustin Hibbits  @Description   Counts number of objects in the list
3470aeed3e9SJustin Hibbits 
3480aeed3e9SJustin Hibbits  @Param[in]     p_List - A pointer to the list which objects are to be counted.
3490aeed3e9SJustin Hibbits 
3500aeed3e9SJustin Hibbits  @Return        Number of objects in the list.
3510aeed3e9SJustin Hibbits *//***************************************************************************/
352*852ba100SJustin Hibbits int NCSW_LIST_NumOfObjs(t_List *p_List);
3530aeed3e9SJustin Hibbits 
3540aeed3e9SJustin Hibbits /** @} */ /* end of list_id group */
3550aeed3e9SJustin Hibbits /** @} */ /* end of etc_id group */
3560aeed3e9SJustin Hibbits 
3570aeed3e9SJustin Hibbits 
3580aeed3e9SJustin Hibbits #endif /* __LIST_EXT_H */
359