list.h File Reference
Go to the source code of this file.
|
Data Structures |
struct | list_head |
Defines |
#define | LIST_HEAD_INIT(name) { &(name), &(name) } |
#define | LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name) |
#define | offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) |
#define | container_of(ptr, type, member) |
#define | list_entry(ptr, type, member) container_of(ptr, type, member) |
#define | list_first_entry(ptr, type, member) list_entry((ptr)->next, type, member) |
#define | list_for_each(pos, head) |
#define | list_for_each_prev(pos, head) |
#define | list_for_each_entry(pos, head, member) |
#define | list_for_each_entry_reverse(pos, head, member) |
#define | list_prepare_entry(pos, head, member) ((pos) ? : list_entry(head, typeof(*pos), member)) |
Define Documentation
#define container_of |
( |
ptr, |
|
|
type, |
|
|
member |
|
) |
|
Value:
({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#define list_entry |
( |
ptr, |
|
|
type, |
|
|
member |
|
) |
container_of(ptr, type, member) |
#define list_first_entry |
( |
ptr, |
|
|
type, |
|
|
member |
|
) |
list_entry((ptr)->next, type, member) |
list_first_entry - get the first element from a list
- Parameters:
-
| ptr | the list head to take the element from. |
| type | the type of the struct this is embedded in. |
| member | the name of the list_struct within the struct. |
Note, that list is expected to be not empty.
#define list_for_each |
( |
pos, |
|
|
head |
|
) |
|
Value:
for (pos = (head)->next; pos != (head); \
pos = pos->next)
list_for_each - iterate over a list
- Parameters:
-
| pos | the &struct list_head to use as a loop cursor. |
| head | the head for your list. |
#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))
list_for_each_entry - iterate over list of given type
- Parameters:
-
| pos | the type * to use as a loop cursor. |
| head | the head for your list. |
| member | the name of the list_struct within the struct. |
#define list_for_each_entry_reverse |
( |
pos, |
|
|
head, |
|
|
member |
|
) |
|
Value:
for (pos = list_entry((head)->prev, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))
list_for_each_entry_reverse - iterate backwards over list of given type.
- Parameters:
-
| pos | the type * to use as a loop cursor. |
| head | the head for your list. |
| member | the name of the list_struct within the struct. |
#define list_for_each_prev |
( |
pos, |
|
|
head |
|
) |
|
Value:
for (pos = (head)->prev; pos != (head); \
pos = pos->prev)
list_for_each_prev - iterate over a list backwards : the &struct
list_head to use as a loop cursor. : the head for your list.
#define LIST_HEAD |
( |
name |
|
) |
struct list_head name = LIST_HEAD_INIT(name) |
#define LIST_HEAD_INIT |
( |
name |
|
) |
{ &(name), &(name) } |
#define list_prepare_entry |
( |
pos, |
|
|
head, |
|
|
member |
|
) |
((pos) ? : list_entry(head, typeof(*pos), member)) |
list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
- Parameters:
-
| pos | the type * to use as a start point |
| head | the head of the list |
| member | the name of the list_struct within the struct. |
Prepares a pos entry for use as a start point in list_for_each_entry_continue().
#define offsetof |
( |
TYPE, |
|
|
MEMBER |
|
) |
((size_t) &((TYPE *)0)->MEMBER) |
list_entry - get the struct for this entry
- Parameters:
-
| ptr | the &struct list_head pointer. |
| type | the type of the struct this is embedded in. |
| member | the name of the list_struct within the struct. |