![]() |
![]() |
TI-RTOS Drivers
tidrivers_full_2_20_01_10
|
Linked List interface for use in drivers.
============================================================================
This module provides simple doubly-link list implementation. There are two main structures:
The following shows how to create a linked list with three elements.
The APIs List_get, List_put, and List_putHead are atomic. The other APIs are not necessarily atomic. In other words, when traversing a linked list, it is up to the application to provide thread-safety (e.g. HwiP_disable/restore or MutexP_pend/post).
Initializing and adding an element to the tail and removing it
The List_put and List_get APIs are used to maintain a first-in first-out (FIFO) linked list.
The List_putHead and List_get APIs are used to maintain a last-in first-out (LIFO) linked list.
Traversing a list from head to tail. Note: thread-safety calls are not shown here.
Traversing a list from tail to head. Note: thread-safety calls are not shown here.
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | List_Elem |
struct | List_List |
Typedefs | |
typedef struct List_Elem | List_Elem |
typedef struct List_List | List_List |
Functions | |
void | List_clearList (List_List *list) |
Function to initialize the contents of a List_List. More... | |
bool | List_empty (List_List *list) |
Function to test whether a linked list is empty. More... | |
List_Elem * | List_get (List_List *list) |
Function to atomically get the first elem in a linked list. More... | |
List_Elem * | List_head (List_List *list) |
Function to return the head of a linked list. More... | |
void | List_insert (List_List *list, List_Elem *newElem, List_Elem *curElem) |
Function to insert an elem into a linked list. More... | |
List_Elem * | List_next (List_Elem *elem) |
Function to return the next elem in a linked list. More... | |
List_Elem * | List_prev (List_Elem *elem) |
Function to return the prev elem in a linked list. More... | |
void | List_put (List_List *list, List_Elem *elem) |
Function to atomically put an elem onto the end of a linked list. More... | |
void | List_putHead (List_List *list, List_Elem *elem) |
Function to atomically put an elem onto the head of a linked list. More... | |
void | List_remove (List_List *list, List_Elem *elem) |
Function to remove an elem from a linked list. More... | |
List_Elem * | List_tail (List_List *list) |
Function to return the tail of a linked list. More... | |
void List_clearList | ( | List_List * | list | ) |
bool List_empty | ( | List_List * | list | ) |
Function to test whether a linked list is empty.
list | A pointer to a linked list |
Function to atomically get the first elem in a linked list.
list | A pointer to a linked list |
Function to return the head of a linked list.
This function does not remove the head, it simply returns a pointer to it. This function is typically used when traversing a linked list.
list | A pointer to the linked list |
Function to insert an elem into a linked list.
list | A pointer to the linked list |
newElem | New elem to insert |
curElem | Elem to insert the newElem in front of. This value cannot be NULL. |
Function to return the next elem in a linked list.
This function does not remove the elem, it simply returns a pointer to next one. This function is typically used when traversing a linked list.
elem | Elem in the list |
Function to return the prev elem in a linked list.
This function does not remove the elem, it simply returns a pointer to prev one. This function is typically used when traversing a linked list.
elem | Elem in the list |
Function to atomically put an elem onto the end of a linked list.
list | A pointer to the linked list |
elem | Element to place onto the end of the linked list |
Function to atomically put an elem onto the head of a linked list.
list | A pointer to the linked list |
elem | Element to place onto the beginning of the linked list |
Function to remove an elem from a linked list.
list | A pointer to the linked list |
elem | Element to be removed from a linked list |
Function to return the tail of a linked list.
This function does not remove the tail, it simply returns a pointer to it. This function is typically used when traversing a linked list.
list | A pointer to the linked list |