CIRCLEQ_ENTRY - Linux


Overview

CIRCLEQ_ENTRY: A generic doubly linked list entry structure used for implementing circular doubly linked lists in the Linux kernel.

Syntax

struct circleq_entry {
    struct circleq_entry *prev;
    struct circleq_entry *next;
};

Options/Flags

None.

Examples

Declare a circular doubly linked list:

struct circleq_entry my_list;

Initialize the list:

CIRCLEQ_INIT(&my_list);

Add an entry to the list:

CIRCLEQ_INSERT_TAIL(&my_list, &my_entry, prev, next);

Traverse the list:

struct circleq_entry *entry;
CIRCLEQ_FOREACH(entry, &my_list, prev, next) {
    // Do something with `entry`
}

Common Issues

  • Uninitialized lists: Ensure to initialize circular doubly linked lists using CIRCLEQ_INIT() before using them.

Integration

  • CIRCLEQ_HEAD(): Get the header of a circular doubly linked list.
  • CIRCLEQ_INSERT_HEAD(): Insert an entry at the head of a list.
  • CIRCLEQ_REMOVE(): Remove an entry from a list.

Related Commands

  • list_entry(): Get a pointer to a list entry structure.
  • list_head(): Get the header of a doubly linked list.