LMMS
Loading...
Searching...
No Matches
list.h File Reference
#include <stddef.h>

Go to the source code of this file.

Classes

struct  list_head

Macros

#define offsetof(TYPE, MEMBER)
#define container_of(ptr, type, member)
#define container_of_const(ptr, type, member)
#define prefetch(x)
#define LIST_POISON1   ((void *) 0x00100100)
#define LIST_POISON2   ((void *) 0x00200200)
#define LIST_HEAD_INIT(name)
#define LIST_HEAD(name)
#define list_entry(ptr, type, member)
#define list_entry_const(ptr, type, member)
#define list_for_each(pos, head)
#define __list_for_each(pos, head)
#define list_for_each_prev(pos, head)
#define list_for_each_safe(pos, n, 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)
#define list_for_each_entry_continue(pos, head, member)
#define list_for_each_entry_from(pos, head, member)
#define list_for_each_entry_safe(pos, n, head, member)
#define list_for_each_entry_safe_continue(pos, n, head, member)
#define list_for_each_entry_safe_from(pos, n, head, member)
#define list_for_each_entry_safe_reverse(pos, n, head, member)

Functions

static void INIT_LIST_HEAD (struct list_head *list)
static void __list_add (struct list_head *new_, struct list_head *prev, struct list_head *next)
static void list_add (struct list_head *new_, struct list_head *head)
static void list_add_tail (struct list_head *new_, struct list_head *head)
static void __list_del (struct list_head *prev, struct list_head *next)
static void list_del (struct list_head *entry)
static void list_del_init (struct list_head *entry)
static void list_move (struct list_head *list, struct list_head *head)
static void list_move_tail (struct list_head *list, struct list_head *head)
static int list_empty (const struct list_head *head)
static int list_empty_careful (const struct list_head *head)
static void __list_splice (struct list_head *list, struct list_head *head)
static void __list_splice_tail (struct list_head *list, struct list_head *head)
static void list_splice (struct list_head *list, struct list_head *head)
static void list_splice_tail (struct list_head *list, struct list_head *head)
static void list_splice_init (struct list_head *list, struct list_head *head)
static void list_splice_tail_init (struct list_head *list, struct list_head *head)

Macro Definition Documentation

◆ __list_for_each

#define __list_for_each ( pos,
head )
Value:
for (pos = (head)->next; pos != (head); pos = pos->next)
Definition misc.c:36

__list_for_each - iterate over a list

Parameters
posthe &struct list_head to use as a loop counter.
headthe head for your list.

This variant differs from list_for_each() in that it's the simplest possible list iteration code, no prefetching is done. Use this for code that knows the list to be very short (empty or 1 entry) most of the time.

◆ container_of

#define container_of ( ptr,
type,
member )
Value:
({ \
typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type, member) );})
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
#define offsetof(TYPE, MEMBER)
Definition list.h:42

container_of - cast a member of a structure out to the containing structure

Parameters
ptrthe pointer to the member.
typethe type of the container struct this is embedded in.
memberthe name of the member within the struct.

◆ container_of_const

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

◆ list_entry

#define list_entry ( ptr,
type,
member )
Value:
((type *)((char *)(ptr)-offsetof(type, member)))

list_entry - get the struct for this entry

Parameters
ptrthe &struct list_head pointer.
typethe type of the struct this is embedded in.
memberthe name of the list_struct within the struct.

◆ list_entry_const

#define list_entry_const ( ptr,
type,
member )
Value:
((const type *)((const char *)(ptr)-offsetof(type, member)))

◆ list_for_each

#define list_for_each ( pos,
head )
Value:
for (pos = (head)->next; prefetch(pos->next), pos != (head); \
pos = pos->next)
#define prefetch(x)
Definition list.h:60

list_for_each - iterate over a list

Parameters
posthe &struct list_head to use as a loop counter.
headthe head for your list.

◆ list_for_each_entry

#define list_for_each_entry ( pos,
head,
member )
Value:
for (pos = list_entry((head)->next, typeof(*pos), member); \
prefetch(pos->member.next), &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
#define list_entry(ptr, type, member)
Definition list.h:313

list_for_each_entry - iterate over list of given type

Parameters
posthe type * to use as a loop counter.
headthe head for your list.
memberthe name of the list_struct within the struct.

◆ list_for_each_entry_continue

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

list_for_each_entry_continue - iterate over list of given type continuing after existing point

Parameters
posthe type * to use as a loop counter.
headthe head for your list.
memberthe name of the list_struct within the struct.

◆ list_for_each_entry_from

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

list_for_each_entry_from - iterate over list of given type continuing from existing point

Parameters
posthe type * to use as a loop counter.
headthe head for your list.
memberthe name of the list_struct within the struct.

◆ list_for_each_entry_reverse

#define list_for_each_entry_reverse ( pos,
head,
member )
Value:
for (pos = list_entry((head)->prev, typeof(*pos), member); \
prefetch(pos->member.prev), &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
posthe type * to use as a loop counter.
headthe head for your list.
memberthe name of the list_struct within the struct.

◆ 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))
int n
Definition crypt.c:458

list_for_each_entry_safe - iterate over list of given type safe against removal of list entry

Parameters
posthe type * to use as a loop counter.
nanother type * to use as temporary storage
headthe head for your list.
memberthe name of the list_struct within the struct.

◆ list_for_each_entry_safe_continue

#define list_for_each_entry_safe_continue ( pos,
n,
head,
member )
Value:
for (pos = list_entry(pos->member.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))

list_for_each_entry_safe_continue - iterate over list of given type continuing after existing point safe against removal of list entry

Parameters
posthe type * to use as a loop counter.
nanother type * to use as temporary storage
headthe head for your list.
memberthe name of the list_struct within the struct.

◆ list_for_each_entry_safe_from

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

list_for_each_entry_safe_from - iterate over list of given type from existing point safe against removal of list entry

Parameters
posthe type * to use as a loop counter.
nanother type * to use as temporary storage
headthe head for your list.
memberthe name of the list_struct within the struct.

◆ list_for_each_entry_safe_reverse

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

list_for_each_entry_safe_reverse - iterate backwards over list of given type safe against removal of list entry

Parameters
posthe type * to use as a loop counter.
nanother type * to use as temporary storage
headthe head for your list.
memberthe name of the list_struct within the struct.

◆ list_for_each_prev

#define list_for_each_prev ( pos,
head )
Value:
for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
pos = pos->prev)

list_for_each_prev - iterate over a list backwards

Parameters
posthe &struct list_head to use as a loop counter.
headthe head for your list.

◆ list_for_each_safe

#define list_for_each_safe ( pos,
n,
head )
Value:
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)

list_for_each_safe - iterate over a list safe against removal of list entry

Parameters
posthe &struct list_head to use as a loop counter.
nanother &struct list_head to use as temporary storage
headthe head for your list.

◆ LIST_HEAD

#define LIST_HEAD ( name)
Value:
static const char * name
Definition pugl.h:1582
#define LIST_HEAD_INIT(name)
Definition list.h:84
Definition list.h:80

◆ LIST_HEAD_INIT

#define LIST_HEAD_INIT ( name)
Value:
{ &(name), &(name) }

◆ LIST_POISON1

#define LIST_POISON1   ((void *) 0x00100100)

◆ LIST_POISON2

#define LIST_POISON2   ((void *) 0x00200200)

◆ list_prepare_entry

#define list_prepare_entry ( pos,
head,
member )
Value:
((pos) ? : list_entry(head, typeof(*pos), member))

list_prepare_entry - prepare a pos entry for use as a start point in list_for_each_entry_continue

Parameters
posthe type * to use as a start point
headthe head of the list
memberthe name of the list_struct within the struct.

◆ offsetof

#define offsetof ( TYPE,
MEMBER )
Value:
((size_t) &((TYPE *)0)->MEMBER)
@ TYPE
Definition inflate.h:35

◆ prefetch

#define prefetch ( x)
Value:
(x = x)
unsigned x[BMAX+1]
Definition inflate.c:1586

Function Documentation

◆ __list_add()

void __list_add ( struct list_head * new_,
struct list_head * prev,
struct list_head * next )
inlinestatic

◆ __list_del()

void __list_del ( struct list_head * prev,
struct list_head * next )
inlinestatic

◆ __list_splice()

void __list_splice ( struct list_head * list,
struct list_head * head )
inlinestatic

◆ __list_splice_tail()

void __list_splice_tail ( struct list_head * list,
struct list_head * head )
inlinestatic

◆ INIT_LIST_HEAD()

void INIT_LIST_HEAD ( struct list_head * list)
inlinestatic

◆ list_add()

void list_add ( struct list_head * new_,
struct list_head * head )
inlinestatic

list_add - add a new entry

Parameters
new_new entry to be added
headlist head to add it after

Insert a new entry after the specified head. This is good for implementing stacks.

◆ list_add_tail()

void list_add_tail ( struct list_head * new_,
struct list_head * head )
inlinestatic

list_add_tail - add a new entry

Parameters
new_new entry to be added
headlist head to add it before

Insert a new entry before the specified head. This is useful for implementing queues.

◆ list_del()

void list_del ( struct list_head * entry)
inlinestatic

list_del - deletes entry from list.

Parameters
entrythe element to delete from the list. Note: list_empty on entry does not return true after this, the entry is in an undefined state.

◆ list_del_init()

void list_del_init ( struct list_head * entry)
inlinestatic

list_del_init - deletes entry from list and reinitialize it.

Parameters
entrythe element to delete from the list.

◆ list_empty()

int list_empty ( const struct list_head * head)
inlinestatic

list_empty - tests whether a list is empty

Parameters
headthe list to test.

◆ list_empty_careful()

int list_empty_careful ( const struct list_head * head)
inlinestatic

list_empty_careful - tests whether a list is empty and checks that no other CPU might be in the process of still modifying either member

NOTE: using list_empty_careful() without synchronization can only be safe if the only activity that can happen to the list entry is list_del_init(). Eg. it cannot be used if another CPU could re-list_add() it.

Parameters
headthe list to test.

◆ list_move()

void list_move ( struct list_head * list,
struct list_head * head )
inlinestatic

list_move - delete from one list and add as another's head

Parameters
listthe entry to move
headthe head that will precede our entry

◆ list_move_tail()

void list_move_tail ( struct list_head * list,
struct list_head * head )
inlinestatic

list_move_tail - delete from one list and add as another's tail

Parameters
listthe entry to move
headthe head that will follow our entry

◆ list_splice()

void list_splice ( struct list_head * list,
struct list_head * head )
inlinestatic

list_splice - join two lists

Parameters
listthe new list to add.
headthe place to add it in the first list.

◆ list_splice_init()

void list_splice_init ( struct list_head * list,
struct list_head * head )
inlinestatic

list_splice_init - join two lists and reinitialise the emptied list.

Parameters
listthe new list to add.
headthe place to add it in the first list.

The list at list is reinitialised

◆ list_splice_tail()

void list_splice_tail ( struct list_head * list,
struct list_head * head )
inlinestatic

list_splice_tail - join two lists

Parameters
listthe new list to add.
headthe place to add it in the first list.

list goes to the end (at head->prev)

◆ list_splice_tail_init()

void list_splice_tail_init ( struct list_head * list,
struct list_head * head )
inlinestatic

list_splice_tail_init - join two lists and reinitialise the emptied list.

Parameters
listthe new list to add.
headthe place to add it in the first list.

The list list is reinitialised list goes to the end (at head->prev)