AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
queue.h File Reference
#include <core/system.h>
#include <core/string.h>

Go to the source code of this file.

Data Structures

struct  qnode
 A queue's node, holding one entry. More...
struct  queue
 A queue. More...

Macros

#define QUEUE_TRACE   1
#define queue_for(n, q)
#define QUEUE_NEW()

Functions

static struct queue * queue_new (void)
 Returns a new, empty queue from kmalloc(), or NULL if there was no memory for it.
static struct qnode * enqueue (struct queue *queue, void *value)
 Adds an entry at the end of a queue.
static struct qnode * enqueue_head (struct queue *queue, void *value)
 Adds an entry at the head of a queue, so that dequeue() returns it next.
static void * dequeue (struct queue *queue)
 Takes the first entry off a queue, frees its node, and returns the entry, or NULL if the queue is empty.
static void queue_remove (struct queue *queue, void *value)
 Removes the first node whose entry is value, if there's one.
static void queue_node_remove (struct queue *queue, struct qnode *node)
 Removes a node from a queue, and frees it.

Macro Definition Documentation

◆ queue_for

◆ QUEUE_NEW

#define QUEUE_NEW ( )
Value:
&(struct queue){0}
A queue.
Definition queue.h:29

Definition at line 40 of file queue.h.

◆ QUEUE_TRACE

#define QUEUE_TRACE   1

Definition at line 26 of file queue.h.

Referenced by enqueue().

Function Documentation

◆ dequeue()

void * dequeue ( struct queue * queue)
inlinestatic

Takes the first entry off a queue, frees its node, and returns the entry, or NULL if the queue is empty.

Definition at line 117 of file queue.h.

References queue::count, queue::head, kfree(), qnode::next, NULL, qnode::prev, queue::tail, and qnode::value.

Referenced by queue_remove().

◆ enqueue()

struct qnode * enqueue ( struct queue * queue,
void * value )
inlinestatic

Adds an entry at the end of a queue.

Returns its node, or NULL if there was no memory for it.

Definition at line 57 of file queue.h.

References queue::count, queue::flags, queue::head, kmalloc(), memset(), qnode::next, NULL, qnode::prev, printk(), QUEUE_TRACE, queue::tail, and qnode::value.

◆ enqueue_head()

struct qnode * enqueue_head ( struct queue * queue,
void * value )
inlinestatic

Adds an entry at the head of a queue, so that dequeue() returns it next.

Returns its node, or NULL if there was no memory for it.

Definition at line 92 of file queue.h.

References queue::count, enqueue_head(), queue::head, kmalloc(), memset(), qnode::next, NULL, qnode::prev, queue::tail, and qnode::value.

Referenced by enqueue_head().

◆ queue_new()

struct queue * queue_new ( void )
inlinestatic

Returns a new, empty queue from kmalloc(), or NULL if there was no memory for it.

Definition at line 44 of file queue.h.

References kmalloc(), memset(), and NULL.

◆ queue_node_remove()

void queue_node_remove ( struct queue * queue,
struct qnode * node )
inlinestatic

Removes a node from a queue, and frees it.

Definition at line 167 of file queue.h.

References queue::count, queue::head, kfree(), qnode::next, qnode::prev, and queue::tail.

◆ queue_remove()

void queue_remove ( struct queue * queue,
void * value )
inlinestatic

Removes the first node whose entry is value, if there's one.

Definition at line 140 of file queue.h.

References queue::count, dequeue(), kfree(), qnode::next, NULL, qnode::prev, queue_for, queue::tail, and qnode::value.