List.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2018, 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 #ifdef __cplusplus
119 extern "C" {
120 #endif
121 
122 #include <stdint.h>
123 #include <stdbool.h>
124 #include <stddef.h>
125 
126 typedef struct List_Elem {
127  struct List_Elem *next;
128  struct List_Elem *prev;
129 } List_Elem;
130 
131 typedef struct List_List {
134 } List_List;
135 
142 extern void List_clearList(List_List *list);
143 
151 static inline bool List_empty(List_List *list)
152 {
153  return (list->head == NULL);
154 }
155 
163 extern List_Elem *List_get(List_List *list);
164 
175 static inline List_Elem *List_head(List_List *list)
176 {
177  return (list->head);
178 }
179 
190 extern void List_insert(List_List *list, List_Elem *newElem,
191  List_Elem *curElem);
192 
203 static inline List_Elem *List_next(List_Elem *elem)
204 {
205  return (elem->next);
206 }
207 
218 static inline List_Elem *List_prev(List_Elem *elem)
219 {
220  return (elem->prev);
221 }
222 
230 extern void List_put(List_List *list, List_Elem *elem);
231 
239 extern void List_putHead(List_List *list, List_Elem *elem);
240 
248 extern void List_remove(List_List *list, List_Elem *elem);
249 
260 static inline List_Elem *List_tail(List_List *list)
261 {
262  return (list->tail);
263 }
264 
265 #ifdef __cplusplus
266 }
267 #endif
268 
269 #endif /* ti_drivers_utils_List__include */
List_Elem * tail
Definition: List.h:133
struct List_Elem * prev
Definition: List.h:128
Definition: List.h:131
void List_remove(List_List *list, List_Elem *elem)
Function to remove an elem from a linked list.
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:132
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 * next
Definition: List.h:127
struct List_List List_List
Definition: List.h:126
static List_Elem * List_head(List_List *list)
Function to return the head of a linked list.
Definition: List.h:175
static List_Elem * List_prev(List_Elem *elem)
Function to return the prev elem in a linked list.
Definition: List.h:218
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:151
struct List_Elem List_Elem
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:203
static List_Elem * List_tail(List_List *list)
Function to return the tail of a linked list.
Definition: List.h:260
© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale