SYNOPSIS

#include <stdint.h>

#include <qb/qbdefs.h>

Data Structures

struct qb_list_head

Defines

#define QB_LIST_DECLARE(name) struct qb_list_head name = { &(name), &(name) }

Declare and initialize a list head. #define QB_INIT_LIST_HEAD(ptr)

#define qb_list_entry(ptr, type, member) ((type *)((char *)(ptr)-(char*)(&((type *)0)->member)))

Get the struct for this entry. #define qb_list_for_each(pos, head) for (pos = (head)->next; pos != (head); pos = pos->next)

Iterate over a list. #define qb_list_for_each_reverse(pos, head) for (pos = (head)->prev; pos != (head); pos = pos->prev)

Iterate over a list backwards. #define qb_list_for_each_safe(pos, n, head)

Iterate over a list safe against removal of list entry. #define qb_list_for_each_entry(pos, head, member)

Iterate over list of given type. #define qb_list_for_each_entry_reverse(pos, head, member)

Iterate backwards over list of given type. #define qb_list_for_each_entry_safe(pos, n, head, member)

Iterate over list of given type safe against removal of list entry. #define qb_list_for_each_entry_safe_reverse(pos, n, head, member)

Iterate backwards over list safe against removal.

Functions

static void qb_list_init (struct qb_list_head *head)

Initialize the list entry. static void qb_list_add (struct qb_list_head *element, struct qb_list_head *head)

Add this element to the list. static void qb_list_add_tail (struct qb_list_head *element, struct qb_list_head *head)

Add to the list (but at the end of the list). static void qb_list_del (struct qb_list_head *_remove)

Delete an entry from the list. static int32_t qb_list_empty (const struct qb_list_head *head)

A quick test to see if the list is empty (pointing to it's self). static void qb_list_splice (struct qb_list_head *list, struct qb_list_head *head)

Join two lists. static int32_t qb_list_length (struct qb_list_head *head)

Count the number of items in the list.

Detailed Description

This is a kernel style list implementation.

Author:

Steven Dake <[email protected]>

Define Documentation

#define \fBQB_INIT_LIST_HEAD\fP(ptr) \fBValue:\fP

do {          (ptr)->next = (ptr); (ptr)->prev = (ptr);  } while (0)

#define \fBQB_LIST_DECLARE\fP(name) struct \fBqb_list_head\fP name = { &(name), &(name) }

Declare and initialize a list head.

#define \fBqb_list_entry\fP(ptr, type, member) ((type *)((char *)(ptr)-(char*)(&((type *)0)->member)))

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.

#define \fBqb_list_for_each\fP(pos, head) for (pos = (head)->next; pos != (head); pos = pos->next)

Iterate over a list. Parameters:

pos,: the &struct list_head to use as a loop counter.

head,: the head for your list.

Referenced by qb_list_length().

#define \fBqb_list_for_each_entry\fP(pos, head, member) \fBValue:\fP

for (pos = qb_list_entry((head)->next, typeof(*pos), member);                 &pos->member != (head);                                                  pos = qb_list_entry(pos->member.next, typeof(*pos), member))

Iterate over list of given type. Parameters:

pos,: the type * to use as a loop counter.

head,: the head for your list.

member,: the name of the list_struct within the struct.

#define \fBqb_list_for_each_entry_reverse\fP(pos, head, member) \fBValue:\fP

for (pos = qb_list_entry((head)->prev, typeof(*pos), member);                &pos->member != (head);                                                  pos = qb_list_entry(pos->member.prev, typeof(*pos), member))

Iterate backwards over list of given type. Parameters:

pos,: the type to use as a loop counter.

head,: the head for your list.

member,: the name of the list_struct within the struct.

#define \fBqb_list_for_each_entry_safe\fP(pos, n, head, member) \fBValue:\fP

for (pos = qb_list_entry((head)->next, typeof(*pos), member),                           n = qb_list_entry(pos->member.next, typeof(*pos), member);                     &pos->member != (head);                                                          pos = n, n = qb_list_entry(n->member.next, typeof(*n), member))

Iterate over list of given type safe against removal of list entry. Parameters:

pos,: the type * to use as a loop cursor.

n,: another type * to use as temporary storage

head,: the head for your list.

member,: the name of the list_struct within the struct.

#define \fBqb_list_for_each_entry_safe_reverse\fP(pos, n, head, member) \fBValue:\fP

for (pos = qb_list_entry((head)->prev, typeof(*pos), member),                           n = qb_list_entry(pos->member.prev, typeof(*pos), member);                     &pos->member != (head);                                                          pos = n, n = qb_list_entry(n->member.prev, typeof(*n), member))

Iterate backwards over list safe against removal. Parameters:

pos,: the type * to use as a loop cursor.

n,: another type * to use as temporary storage

head,: the head for your list.

member,: the name of the list_struct within the struct.

#define \fBqb_list_for_each_reverse\fP(pos, head) for (pos = (head)->prev; pos != (head); pos = pos->prev)

Iterate over a list backwards. Parameters:

pos,: the &struct list_head to use as a loop counter.

head,: the head for your list.

#define \fBqb_list_for_each_safe\fP(pos, n, head) \fBValue:\fP

for (pos = (head)->next, n = pos->next; pos != (head);                  pos = n, n = pos->next)

Iterate over a list safe against removal of list entry. Parameters:

pos,: the &struct list_head to use as a loop counter.

n,: another &struct list_head to use as temporary storage

head,: the head for your list.

Function Documentation

static void \fBqb_list_add\fP (struct \fBqb_list_head\fP *element, struct \fBqb_list_head\fP *head)\fC [inline, static]\fP

Add this element to the list. Parameters:

element the new element to insert.

head pointer to the list head

References qb_list_head::next, and qb_list_head::prev.

static void \fBqb_list_add_tail\fP (struct \fBqb_list_head\fP *element, struct \fBqb_list_head\fP *head)\fC [inline, static]\fP

Add to the list (but at the end of the list). Parameters:

element pointer to the element to add

head pointer to the list head

See also:

qb_list_add()

References qb_list_head::next, and qb_list_head::prev.

static void \fBqb_list_del\fP (struct \fBqb_list_head\fP *_remove)\fC [inline, static]\fP

Delete an entry from the list. Parameters:

_remove the list item to remove

References qb_list_head::next, and qb_list_head::prev.

static int32_t \fBqb_list_empty\fP (const struct \fBqb_list_head\fP *head)\fC [inline, static]\fP

A quick test to see if the list is empty (pointing to it's self). Parameters:

head pointer to the list head

Returns:

boolean true/false

References qb_list_head::next.

static void \fBqb_list_init\fP (struct \fBqb_list_head\fP *head)\fC [inline, static]\fP

Initialize the list entry. Points next and prev pointers to head.

Parameters:

head pointer to the list head

References qb_list_head::next, and qb_list_head::prev.

static int32_t \fBqb_list_length\fP (struct \fBqb_list_head\fP *head)\fC [inline, static]\fP

Count the number of items in the list. Parameters:

head,: the head for your list.

Returns:

length of the list.

References qb_list_for_each.

static void \fBqb_list_splice\fP (struct \fBqb_list_head\fP *list, struct \fBqb_list_head\fP *head)\fC [inline, static]\fP

Join two lists. Parameters:

list the new list to add.

head the place to add it in the first list.

Note:

The 'list' is reinitialised

References qb_list_head::next, and qb_list_head::prev.

Author

Generated automatically by Doxygen for libqb from the source code.