List.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2019, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
115 #ifndef ti_drivers_utils_List__include
116 #define ti_drivers_utils_List__include
117 
118 #include <stdint.h>
119 #include <stdbool.h>
120 #include <stddef.h>
121 
122 #ifdef __cplusplus
123 extern "C" {
124 #endif
125 
126 typedef struct List_Elem_
127 {
128  struct List_Elem_ *next;
129  struct List_Elem_ *prev;
130 } List_Elem;
131 
132 typedef struct
133 {
136 } List_List;
137 
144 extern void List_clearList(List_List *list);
145 
153 static inline bool List_empty(List_List *list)
154 {
155  return (list->head == NULL);
156 }
157 
165 extern List_Elem *List_get(List_List *list);
166 
177 static inline List_Elem *List_head(List_List *list)
178 {
179  return (list->head);
180 }
181 
192 extern void List_insert(List_List *list, List_Elem *newElem, List_Elem *curElem);
193 
204 static inline List_Elem *List_next(List_Elem *elem)
205 {
206  return (elem->next);
207 }
208 
219 static inline List_Elem *List_prev(List_Elem *elem)
220 {
221  return (elem->prev);
222 }
223 
231 extern void List_put(List_List *list, List_Elem *elem);
232 
240 extern void List_putHead(List_List *list, List_Elem *elem);
241 
249 extern void List_remove(List_List *list, List_Elem *elem);
250 
261 static inline List_Elem *List_tail(List_List *list)
262 {
263  return (list->tail);
264 }
265 
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 #endif /* ti_drivers_utils_List__include */
List_Elem * tail
Definition: List.h:135
Definition: List.h:132
void List_remove(List_List *list, List_Elem *elem)
Function to remove an elem from a linked list.
struct List_Elem_ List_Elem
struct List_Elem_ * next
Definition: List.h:128
List_Elem * List_get(List_List *list)
Function to atomically get the first elem in a linked list.
void List_insert(List_List *list, List_Elem *newElem, List_Elem *curElem)
Function to insert an elem into a linked list.
List_Elem * head
Definition: List.h:134
void List_put(List_List *list, List_Elem *elem)
Function to atomically put an elem onto the end of a linked list.
struct List_Elem_ * prev
Definition: List.h:129
static List_Elem * List_head(List_List *list)
Function to return the head of a linked list.
Definition: List.h:177
static List_Elem * List_prev(List_Elem *elem)
Function to return the prev elem in a linked list.
Definition: List.h:219
void List_clearList(List_List *list)
Function to initialize the contents of a List_List.
static bool List_empty(List_List *list)
Function to test whether a linked list is empty.
Definition: List.h:153
void List_putHead(List_List *list, List_Elem *elem)
Function to atomically put an elem onto the head of a linked list.
static List_Elem * List_next(List_Elem *elem)
Function to return the next elem in a linked list.
Definition: List.h:204
Definition: List.h:126
static List_Elem * List_tail(List_List *list)
Function to return the tail of a linked list.
Definition: List.h:261
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale