paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Data Structures | Macros
list.h File Reference

Doubly linked list implementation. More...

#include <stddef.h>

Data Structures

struct  list_head
 A list head is just a pair of pointers. More...
 

Macros

#define container_of(ptr, type, member)
 Get the struct this entry is embedded in. More...
 
#define INITIALIZED_LIST_HEAD(name)   struct list_head name = {&(name), &(name)}
 Define an initialized list head. More...
 
#define list_entry(ptr, type, member)   container_of(ptr, type, member)
 Get the struct in which this entry is embedded in. More...
 
#define list_for_each_entry(pos, head, member)
 Iterate over a list. More...
 
#define list_for_each_entry_safe(pos, n, head, member)
 Iterate over list, safe against removal of list entry. More...
 
#define list_first_entry(ptr, type, member)    list_entry((ptr)->next, type, member)
 Get the first element of a list. More...
 
#define list_last_entry(ptr, type, member)    list_entry((ptr)->prev, type, member)
 

Detailed Description

Doubly linked list implementation.

Macro Definition Documentation

◆ container_of

#define container_of (   ptr,
  type,
  member 
)
Value:
({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})

Get the struct this entry is embedded in.

◆ INITIALIZED_LIST_HEAD

#define INITIALIZED_LIST_HEAD (   name)    struct list_head name = {&(name), &(name)}

Define an initialized list head.

◆ list_entry

#define list_entry (   ptr,
  type,
  member 
)    container_of(ptr, type, member)

Get the struct in which this entry is embedded in.

Parameters
ptrThe list head pointer.
typeThe type of containing structure.
memberThe name of the list head member within the structure.

◆ list_for_each_entry

#define list_for_each_entry (   pos,
  head,
  member 
)
Value:
for (pos = list_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))

Iterate over a list.

Parameters
posA struct pointer which serves as the iterator.
headThe head of the list.
memberThe name of the list head member within the structure.

◆ list_for_each_entry_safe

#define list_for_each_entry_safe (   pos,
  n,
  head,
  member 
)
Value:
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))

Iterate over list, safe against removal of list entry.

Parameters
posThe iterator struct pointer.
nA second struct pointer which is used as temporary storage.
headThe head of the list.
memberThe name of the list head member within the structure.

◆ list_first_entry

#define list_first_entry (   ptr,
  type,
  member 
)     list_entry((ptr)->next, type, member)

Get the first element of a list.

Parameters
ptrThe list head to take the element from.
typeThe type of the struct this is embedded in.
memberThe name of the list_struct within the struct.

Note that the list is expected to be non-empty.

◆ list_last_entry

#define list_last_entry (   ptr,
  type,
  member 
)     list_entry((ptr)->prev, type, member)
list_entry
#define list_entry(ptr, type, member)
Get the struct in which this entry is embedded in.
Definition: list.h:125