Back to index

libdrm  2.4.37
Classes | Defines | Functions
list.h File Reference

List macros heavily inspired by the Linux kernel list handling. More...

#include <stddef.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  list_head

Defines

#define LIST_INITHEAD(__item)   list_inithead(__item)
#define LIST_ADD(__item, __list)   list_add(__item, __list)
#define LIST_ADDTAIL(__item, __list)   list_addtail(__item, __list)
#define LIST_REPLACE(__from, __to)   list_replace(__from, __to)
#define LIST_DEL(__item)   list_del(__item)
#define LIST_DELINIT(__item)   list_delinit(__item)
#define LIST_ENTRY(__type, __item, __field)   ((__type *)(((char *)(__item)) - offsetof(__type, __field)))
#define LIST_IS_EMPTY(__list)   ((__list)->next == (__list))
#define container_of(ptr, sample, member)
#define LIST_FOR_EACH_ENTRY(pos, head, member)
#define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member)
#define LIST_FOR_EACH_ENTRY_SAFE_REV(pos, storage, head, member)
#define LIST_FOR_EACH_ENTRY_FROM(pos, start, head, member)
#define LIST_FOR_EACH_ENTRY_FROM_REV(pos, start, head, member)

Functions

static void list_inithead (struct list_head *item)
static void list_add (struct list_head *item, struct list_head *list)
static void list_addtail (struct list_head *item, struct list_head *list)
static void list_replace (struct list_head *from, struct list_head *to)
static void list_del (struct list_head *item)
static void list_delinit (struct list_head *item)

Detailed Description

List macros heavily inspired by the Linux kernel list handling.

No list looping yet.

Is not threadsafe, so common operations need to be protected using an external mutex.

Definition in file list.h.


Class Documentation

struct list_head

Definition at line 41 of file list.h.

Collaboration diagram for list_head:
Class Members
struct list_head * next
struct list_head * prev

Define Documentation

#define container_of (   ptr,
  sample,
  member 
)
Value:
(void *)((char *)(ptr)                                         \
            - ((char *)&(sample)->member - (char *)(sample)))

Definition at line 105 of file list.h.

#define LIST_ADD (   __item,
  __list 
)    list_add(__item, __list)

Definition at line 92 of file list.h.

#define LIST_ADDTAIL (   __item,
  __list 
)    list_addtail(__item, __list)

Definition at line 93 of file list.h.

#define LIST_DEL (   __item)    list_del(__item)

Definition at line 95 of file list.h.

#define LIST_DELINIT (   __item)    list_delinit(__item)

Definition at line 96 of file list.h.

#define LIST_ENTRY (   __type,
  __item,
  __field 
)    ((__type *)(((char *)(__item)) - offsetof(__type, __field)))

Definition at line 98 of file list.h.

#define LIST_FOR_EACH_ENTRY (   pos,
  head,
  member 
)
Value:
for (pos = container_of((head)->next, pos, member);                   \
       &pos->member != (head);                                        \
       pos = container_of(pos->member.next, pos, member))

Definition at line 110 of file list.h.

#define LIST_FOR_EACH_ENTRY_FROM (   pos,
  start,
  head,
  member 
)
Value:
for (pos = container_of((start), pos, member);                 \
       &pos->member != (head);                                        \
       pos = container_of(pos->member.next, pos, member))

Definition at line 127 of file list.h.

#define LIST_FOR_EACH_ENTRY_FROM_REV (   pos,
  start,
  head,
  member 
)
Value:
for (pos = container_of((start), pos, member);                 \
       &pos->member != (head);                                        \
       pos = container_of(pos->member.prev, pos, member))

Definition at line 132 of file list.h.

#define LIST_FOR_EACH_ENTRY_SAFE (   pos,
  storage,
  head,
  member 
)
Value:
for (pos = container_of((head)->next, pos, member),                   \
       storage = container_of(pos->member.next, pos, member);  \
       &pos->member != (head);                                        \
       pos = storage, storage = container_of(storage->member.next, storage, member))

Definition at line 115 of file list.h.

#define LIST_FOR_EACH_ENTRY_SAFE_REV (   pos,
  storage,
  head,
  member 
)
Value:
for (pos = container_of((head)->prev, pos, member),                   \
       storage = container_of(pos->member.prev, pos, member);         \
       &pos->member != (head);                                        \
       pos = storage, storage = container_of(storage->member.prev, storage, member))

Definition at line 121 of file list.h.

#define LIST_INITHEAD (   __item)    list_inithead(__item)

Definition at line 91 of file list.h.

#define LIST_IS_EMPTY (   __list)    ((__list)->next == (__list))

Definition at line 101 of file list.h.

#define LIST_REPLACE (   __from,
  __to 
)    list_replace(__from, __to)

Definition at line 94 of file list.h.


Function Documentation

static void list_add ( struct list_head item,
struct list_head list 
) [static]

Definition at line 53 of file list.h.

{
    item->prev = list;
    item->next = list->next;
    list->next->prev = item;
    list->next = item;
}

Here is the caller graph for this function:

static void list_addtail ( struct list_head item,
struct list_head list 
) [static]

Definition at line 61 of file list.h.

{
    item->next = list;
    item->prev = list->prev;
    list->prev->next = item;
    list->prev = item;
}
static void list_del ( struct list_head item) [static]

Definition at line 77 of file list.h.

{
    item->prev->next = item->next;
    item->next->prev = item->prev;
}

Here is the caller graph for this function:

static void list_delinit ( struct list_head item) [static]

Definition at line 83 of file list.h.

{
    item->prev->next = item->next;
    item->next->prev = item->prev;
    item->next = item;
    item->prev = item;
}
static void list_inithead ( struct list_head item) [static]

Definition at line 47 of file list.h.

{
    item->prev = item;
    item->next = item;
}

Here is the caller graph for this function:

static void list_replace ( struct list_head from,
struct list_head to 
) [static]

Definition at line 69 of file list.h.

{
    to->prev = from->prev;
    to->next = from->next;
    from->next->prev = to;
    from->prev->next = to;
}