#include "asterisk/lock.h"
Include dependency graph for linkedlists.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | AST_LIST_APPEND_LIST(head, list, field) |
Appends a whole list to the tail of a list. | |
#define | AST_LIST_EMPTY(head) (AST_LIST_FIRST(head) == NULL) |
Checks whether the specified list contains any entries. | |
#define | AST_LIST_ENTRY(type) |
Declare a forward link structure inside a list entry. | |
#define | AST_LIST_FIRST(head) ((head)->first) |
Returns the first entry contained in a list. | |
#define | AST_LIST_HEAD(name, type) |
Defines a structure to be used to hold a list of specified type. | |
#define | AST_LIST_HEAD_DESTROY(head) |
Destroys a list head structure. | |
#define | AST_LIST_HEAD_INIT(head) |
Initializes a list head structure. | |
#define | AST_LIST_HEAD_INIT_NOLOCK(head) |
Initializes a list head structure. | |
#define | AST_LIST_HEAD_INIT_VALUE |
Defines initial values for a declaration of AST_LIST_HEAD. | |
#define | AST_LIST_HEAD_NOLOCK(name, type) |
Defines a structure to be used to hold a list of specified type (with no lock). | |
#define | AST_LIST_HEAD_NOLOCK_INIT_VALUE |
Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK. | |
#define | AST_LIST_HEAD_NOLOCK_STATIC(name, type) |
Defines a structure to be used to hold a list of specified type, statically initialized. | |
#define | AST_LIST_HEAD_SET(head, entry) |
Initializes a list head structure with a specified first entry. | |
#define | AST_LIST_HEAD_SET_NOLOCK(head, entry) |
Initializes a list head structure with a specified first entry. | |
#define | AST_LIST_HEAD_STATIC(name, type) |
Defines a structure to be used to hold a list of specified type, statically initialized. | |
#define | AST_LIST_INSERT_AFTER(head, listelm, elm, field) |
Inserts a list entry after a given entry. | |
#define | AST_LIST_INSERT_HEAD(head, elm, field) |
Inserts a list entry at the head of a list. | |
#define | AST_LIST_INSERT_TAIL(head, elm, field) |
Appends a list entry to the tail of a list. | |
#define | AST_LIST_LAST(head) ((head)->last) |
Returns the last entry contained in a list. | |
#define | AST_LIST_LOCK(head) ast_mutex_lock(&(head)->lock) |
Attempts to lock a list. | |
#define | AST_LIST_NEXT(elm, field) ((elm)->field.next) |
Returns the next entry in the list after the given entry. | |
#define | AST_LIST_REMOVE(head, elm, field) |
Removes a specific entry from a list. | |
#define | AST_LIST_REMOVE_CURRENT(head, field) |
Removes the current entry from a list during a traversal. | |
#define | AST_LIST_REMOVE_HEAD(head, field) |
Removes and returns the head entry from a list. | |
#define | AST_LIST_TRAVERSE(head, var, field) for((var) = (head)->first; (var); (var) = (var)->field.next) |
Loops over (traverses) the entries in a list. | |
#define | AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field) |
Loops safely over (traverses) the entries in a list. | |
#define | AST_LIST_TRAVERSE_SAFE_END } |
Closes a safe loop traversal block. | |
#define | AST_LIST_UNLOCK(head) ast_mutex_unlock(&(head)->lock) |
Attempts to unlock a list. |
Definition in file linkedlists.h.
#define AST_LIST_APPEND_LIST | ( | head, | |||
list, | |||||
field | ) |
Appends a whole list to the tail of a list.
head | This is a pointer to the list head structure | |
list | This is a pointer to the list to be appended. | |
field | This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together. |
Definition at line 439 of file linkedlists.h.
#define AST_LIST_EMPTY | ( | head | ) | (AST_LIST_FIRST(head) == NULL) |
Checks whether the specified list contains any entries.
head | This is a pointer to the list head structure |
Definition at line 230 of file linkedlists.h.
#define AST_LIST_ENTRY | ( | type | ) |
Value:
struct { \ struct type *next; \ }
type | This is the type of each list entry. |
struct list_entry { ... AST_LIST_ENTRY(list_entry) list; }
The field name list here is arbitrary, and can be anything you wish.
Definition at line 199 of file linkedlists.h.
#define AST_LIST_FIRST | ( | head | ) | ((head)->first) |
Returns the first entry contained in a list.
head | This is a pointer to the list head structure |
Definition at line 208 of file linkedlists.h.
#define AST_LIST_HEAD | ( | name, | |||
type | ) |
Value:
struct name { \ struct type *first; \ struct type *last; \ ast_mutex_t lock; \ }
name | This will be the name of the defined structure. | |
type | This is the type of each list entry. |
Example usage:
static AST_LIST_HEAD(entry_list, entry) entries;
This would define struct
entry_list
, and declare an instance of it named entries, all intended to hold a list of type struct
entry
.
Definition at line 71 of file linkedlists.h.
#define AST_LIST_HEAD_DESTROY | ( | head | ) |
Value:
{ \ (head)->first = NULL; \ (head)->last = NULL; \ ast_mutex_destroy(&(head)->lock); \ }
head | This is a pointer to the list head structure |
Definition at line 362 of file linkedlists.h.
#define AST_LIST_HEAD_INIT | ( | head | ) |
Value:
{ \ (head)->first = NULL; \ (head)->last = NULL; \ ast_mutex_init(&(head)->lock); \ }
head | This is a pointer to the list head structure |
Definition at line 348 of file linkedlists.h.
#define AST_LIST_HEAD_INIT_NOLOCK | ( | head | ) |
Value:
{ \ (head)->first = NULL; \ (head)->last = NULL; \ }
head | This is a pointer to the list head structure |
Definition at line 376 of file linkedlists.h.
#define AST_LIST_HEAD_INIT_VALUE |
Value:
{ \ .first = NULL, \ .last = NULL, \ .lock = AST_MUTEX_INIT_VALUE, \ }
Definition at line 106 of file linkedlists.h.
#define AST_LIST_HEAD_NOLOCK | ( | name, | |||
type | ) |
Value:
struct name { \ struct type *first; \ struct type *last; \ }
name | This will be the name of the defined structure. | |
type | This is the type of each list entry. |
Example usage:
static AST_LIST_HEAD_NOLOCK(entry_list, entry) entries;
This would define struct
entry_list
, and declare an instance of it named entries, all intended to hold a list of type struct
entry
.
Definition at line 97 of file linkedlists.h.
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE |
Value:
{ \ .first = NULL, \ .last = NULL, \ }
Definition at line 115 of file linkedlists.h.
#define AST_LIST_HEAD_NOLOCK_STATIC | ( | name, | |||
type | ) |
Value:
struct name { \ struct type *first; \ struct type *last; \ } name = AST_LIST_HEAD_NOLOCK_INIT_VALUE
This is the same as AST_LIST_HEAD_STATIC, except without the lock included.
Definition at line 149 of file linkedlists.h.
#define AST_LIST_HEAD_SET | ( | head, | |||
entry | ) |
Value:
do { \ (head)->first = (entry); \ (head)->last = (entry); \ ast_mutex_init(&(head)->lock); \ } while (0)
head | This is a pointer to the list head structure | |
entry | pointer to the list entry that will become the head of the list |
Definition at line 163 of file linkedlists.h.
#define AST_LIST_HEAD_SET_NOLOCK | ( | head, | |||
entry | ) |
Value:
do { \ (head)->first = (entry); \ (head)->last = (entry); \ } while (0)
head | This is a pointer to the list head structure | |
entry | pointer to the list entry that will become the head of the list |
Definition at line 177 of file linkedlists.h.
#define AST_LIST_HEAD_STATIC | ( | name, | |||
type | ) |
Value:
struct name { \ struct type *first; \ struct type *last; \ ast_mutex_t lock; \ } name = AST_LIST_HEAD_INIT_VALUE
name | This will be the name of the defined structure. | |
type | This is the type of each list entry. |
Example usage:
static AST_LIST_HEAD_STATIC(entry_list, entry);
This would define struct
entry_list
, intended to hold a list of type struct
entry
.
Definition at line 137 of file linkedlists.h.
#define AST_LIST_INSERT_AFTER | ( | head, | |||
listelm, | |||||
elm, | |||||
field | ) |
Inserts a list entry after a given entry.
head | This is a pointer to the list head structure | |
listelm | This is a pointer to the entry after which the new entry should be inserted. | |
elm | This is a pointer to the entry to be inserted. | |
field | This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together. |
Definition at line 390 of file linkedlists.h.
#define AST_LIST_INSERT_HEAD | ( | head, | |||
elm, | |||||
field | ) |
Inserts a list entry at the head of a list.
head | This is a pointer to the list head structure | |
elm | This is a pointer to the entry to be inserted. | |
field | This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together. |
Definition at line 404 of file linkedlists.h.
#define AST_LIST_INSERT_TAIL | ( | head, | |||
elm, | |||||
field | ) |
Appends a list entry to the tail of a list.
head | This is a pointer to the list head structure | |
elm | This is a pointer to the entry to be appended. | |
field | This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together. |
Definition at line 422 of file linkedlists.h.
#define AST_LIST_LAST | ( | head | ) | ((head)->last) |
Returns the last entry contained in a list.
head | This is a pointer to the list tail structure |
Definition at line 214 of file linkedlists.h.
#define AST_LIST_LOCK | ( | head | ) | ast_mutex_lock(&(head)->lock) |
Attempts to lock a list.
head | This is a pointer to the list head structure |
Definition at line 38 of file linkedlists.h.
#define AST_LIST_NEXT | ( | elm, | |||
field | ) | ((elm)->field.next) |
Returns the next entry in the list after the given entry.
elm | This is a pointer to the current entry. | |
field | This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together. |
Definition at line 222 of file linkedlists.h.
#define AST_LIST_REMOVE | ( | head, | |||
elm, | |||||
field | ) |
Removes a specific entry from a list.
head | This is a pointer to the list head structure | |
elm | This is a pointer to the entry to be removed. | |
field | This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together. |
Definition at line 477 of file linkedlists.h.
#define AST_LIST_REMOVE_CURRENT | ( | head, | |||
field | ) |
Removes the current entry from a list during a traversal.
head | This is a pointer to the list head structure | |
field | This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together. |
Definition at line 327 of file linkedlists.h.
#define AST_LIST_REMOVE_HEAD | ( | head, | |||
field | ) |
Removes and returns the head entry from a list.
head | This is a pointer to the list head structure | |
field | This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together. |
Definition at line 458 of file linkedlists.h.
#define AST_LIST_TRAVERSE | ( | head, | |||
var, | |||||
field | ) | for((var) = (head)->first; (var); (var) = (var)->field.next) |
Loops over (traverses) the entries in a list.
head | This is a pointer to the list head structure | |
var | This is the name of the variable that will hold a pointer to the current list entry on each iteration. It must be declared before calling this macro. | |
field | This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together. |
static AST_LIST_HEAD(entry_list, list_entry) entries; ... struct list_entry { ... AST_LIST_ENTRY(list_entry) list; } ... struct list_entry *current; ... AST_LIST_TRAVERSE(&entries, current, list) { (do something with current here) }
Definition at line 268 of file linkedlists.h.
#define AST_LIST_TRAVERSE_SAFE_BEGIN | ( | head, | |||
var, | |||||
field | ) |
Loops safely over (traverses) the entries in a list.
head | This is a pointer to the list head structure | |
var | This is the name of the variable that will hold a pointer to the current list entry on each iteration. It must be declared before calling this macro. | |
field | This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of this list together. |
static AST_LIST_HEAD(entry_list, list_entry) entries; ... struct list_entry { ... AST_LIST_ENTRY(list_entry) list; } ... struct list_entry *current; ... AST_LIST_TRAVERSE_SAFE_BEGIN(&entries, current, list) { (do something with current here) } AST_LIST_TRAVERSE_SAFE_END;
It differs from AST_LIST_TRAVERSE() in that the code inside the loop can modify (or even free, after calling AST_LIST_REMOVE_CURRENT()) the entry pointed to by the current pointer without affecting the loop traversal.
Definition at line 304 of file linkedlists.h.
#define AST_LIST_UNLOCK | ( | head | ) | ast_mutex_unlock(&(head)->lock) |
Attempts to unlock a list.
head | This is a pointer to the list head structure |
Definition at line 49 of file linkedlists.h.