IGT List: igt-gpu-tools Reference Manual

## IGT List IGT List — a list implementation inspired by the kernel |

## Functions

void | IGT_INIT_LIST_HEAD ()
void | igt_list_add ()
void | igt_list_del ()
void | igt_list_del_init ()
void | igt_list_move ()
void | igt_list_move_tail ()
int | igt_list_length ()
bool | igt_list_empty ()
#define | igt_container_of()
#define | igt_list_for_each_entry()
#define | igt_list_for_each_entry_safe()
#define | igt_list_for_each_entry_reverse()
#define | igt_list_for_each_entry_safe_reverse()
#define | IGT_LIST_HEAD()
#define | igt_list_add_tail()
#define | igt_list_first_entry()
#define | igt_list_last_entry()

## Types and Values

struct | igt_list_head

## Includes

    #include <igt_list.h>

## Description

This list data structure mimics the one we can find in the kernel. A few bonus helpers are provided.

igt_list is a doubly-linked list where an instance of igt_list_head is a head sentinel and has to be initialized.

Example usage:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    struct igt_list_head foo_head;

    struct element {
            int foo;
            struct igt_list_head link;
    };

    struct element e1, e2, e3;

    IGT_INIT_LIST_HEAD(&foo_head);
    igt_list_add(&e1.link, &foo_head);   // e1 is the first element
    igt_list_add(&e2.link, &foo_head);   // e2 is now the first element
    igt_list_add(&e3.link, &e2.link);    // insert e3 after e2

    printf("list length: %d\n", igt_list_length(&foo_head));

    struct element *iter;
    igt_list_for_each_entry(iter, &foo_head, link) {
    	printf("  %d\n", iter->foo);
    }

## Functions

### IGT_INIT_LIST_HEAD ()

    void
    IGT_INIT_LIST_HEAD (struct igt_list_head *head);

### igt_list_add ()

    void
    igt_list_add (struct igt_list_head *elem,
                  struct igt_list_head *head);

### igt_list_del ()

    void
    igt_list_del (struct igt_list_head *elem);

### igt_list_del_init ()

    void
    igt_list_del_init (struct igt_list_head *elem);

### igt_list_move ()

    void
    igt_list_move (struct igt_list_head *elem,
                   struct igt_list_head *list);

### igt_list_move_tail ()

    void
    igt_list_move_tail (struct igt_list_head *elem,
                        struct igt_list_head *list);

### igt_list_length ()

    int
    igt_list_length (const struct igt_list_head *head);

### igt_list_empty ()

    bool
    igt_list_empty (const struct igt_list_head *head);

### igt_container_of()

    #define             igt_container_of(ptr, sample, member)

### igt_list_for_each_entry()

    #define             igt_list_for_each_entry(pos, head, member)

### igt_list_for_each_entry_safe()

    #define             igt_list_for_each_entry_safe(pos, tmp, head, member)

### igt_list_for_each_entry_reverse()

    #define             igt_list_for_each_entry_reverse(pos, head, member)

### igt_list_for_each_entry_safe_reverse()

    #define             igt_list_for_each_entry_safe_reverse(pos, tmp, head, member)

### IGT_LIST_HEAD()

    #define IGT_LIST_HEAD(name) struct igt_list_head name = { &(name), &(name) }

Instead of having to use ``IGT_INIT_LIST_HEAD()`` list can be defined using this helper, e.g. `static IGT_LIST_HEAD(list);`

### igt_list_add_tail()

    #define igt_list_add_tail(elem, head) igt_list_add(elem, (head)->prev)

### igt_list_first_entry()

    #define             igt_list_first_entry(head, type, member)

### igt_list_last_entry()

    #define             igt_list_last_entry(head, type, member)

## Types and Values

### struct igt_list_head

    struct igt_list_head {
    	struct igt_list_head *prev;
    	struct igt_list_head *next;
    };