AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
list.h File Reference
#include <stddef.h>
#include <core/types.h>

Go to the source code of this file.

Data Structures

struct  list_node
 A link in a list, inside the structure that is listed. More...
struct  list
 A list: its first and last nodes, and how many there are. More...

Macros

#define list_entry(node, type, member)
#define list_for(n, l)

Functions

static int list_empty (struct list *list)
 Returns whether list has no nodes.
static int list_linked (struct list_node *node)
 Returns whether node is on a list (node->list says which).
static void list_append (struct list *list, struct list_node *node)
 Adds node at the end of list.
static void list_prepend (struct list *list, struct list_node *node)
 Adds node at the head of list, so that list_pop() returns it next.
static void list_remove (struct list_node *node)
 Takes node off the list it is on.
static struct list_node * list_pop (struct list *list)
 Takes the first node off list and returns it, or NULL if it's empty.

Macro Definition Documentation

◆ list_entry

#define list_entry ( node,
type,
member )
Value:
((type *) ((char *) (node) - offsetof(type, member)))
#define offsetof(type, field)
Definition stddef.h:31

Definition at line 43 of file list.h.

Referenced by sched_timer_tick(), schedule(), and waitq_wakeup_nopoll().

◆ list_for

#define list_for ( n,
l )
Value:
for (struct list_node *(n) = (l)->head, *__next_##n = (n) ? (n)->next : NULL; \
(n); (n) = __next_##n, __next_##n = (n) ? (n)->next : NULL)
#define NULL
Definition stddef.h:27
A link in a list, inside the structure that is listed.
Definition list.h:31

Definition at line 48 of file list.h.

Referenced by sched_timer_tick().

Function Documentation

◆ list_append()

void list_append ( struct list * list,
struct list_node * node )
inlinestatic

Adds node at the end of list.

Definition at line 65 of file list.h.

References list::count, list::head, list_node::list, list_node::next, NULL, list_node::prev, and list::tail.

◆ list_empty()

int list_empty ( struct list * list)
inlinestatic

Returns whether list has no nodes.

Definition at line 53 of file list.h.

References list::head.

◆ list_linked()

int list_linked ( struct list_node * node)
inlinestatic

Returns whether node is on a list (node->list says which).

Definition at line 59 of file list.h.

References list_node::list, and NULL.

◆ list_pop()

struct list_node * list_pop ( struct list * list)
inlinestatic

Takes the first node off list and returns it, or NULL if it's empty.

Definition at line 120 of file list.h.

References list::head, and list_remove().

◆ list_prepend()

void list_prepend ( struct list * list,
struct list_node * node )
inlinestatic

Adds node at the head of list, so that list_pop() returns it next.

Definition at line 81 of file list.h.

References list::count, list::head, list_node::list, list_node::next, NULL, list_node::prev, and list::tail.

◆ list_remove()

void list_remove ( struct list_node * node)
inlinestatic

Takes node off the list it is on.

A node on no list is left alone.

Definition at line 97 of file list.h.

References list::count, list::head, list_node::list, list_node::next, NULL, list_node::prev, and list::tail.

Referenced by list_pop().