72#define GP_LIST_ENTRY(ptr, structure, member) \
73 GP_CONTAINER_OF(ptr, structure, member)
100#define GP_LIST_FOREACH(list, entry) \
101 for (entry = (list)->head; entry; entry = entry->next)
130#define GP_DLIST_REV_FOREACH(list, entry) \
131 for (entry = (list)->tail; entry; entry = entry->prev)
188 gp_list_push_tail_(list, entry);
238 entry->
next = before;
246 before->
prev = entry;
289 if (ret && ret->
next)
349 int (*cmp)(
const void *,
const void *))
353 if (!head || !head->
next)
356 for (middle = tmp = head; tmp; tmp = tmp->
next) {
358 middle = middle->
next;
364 head = gp_list_merge_sort(head, cmp);
365 middle = gp_list_merge_sort(middle, cmp);
367 if (cmp(head, middle)) {
372 middle = middle->
next;
375 while (head || middle) {
376 while (head && (!middle || cmp(middle, head) <= 0)) {
382 while (middle && (!head || cmp(head, middle) <= 0)) {
385 middle = middle->
next;
421 int (*cmp)(
const void *,
const void *))
428 list->
head = gp_list_merge_sort(list->
head, cmp);
444 int (*cmp)(
const void *,
const void *))
static void gp_dlist_push_tail(gp_dlist *list, gp_dlist_head *entry)
Pushes into tail of double linked list.
static void gp_dlist_push_after(gp_dlist *list, gp_dlist_head *after, gp_dlist_head *entry)
Pushes an entry into a double linked list after an entry.
static gp_dlist_head * gp_dlist_pop_head(gp_dlist *list)
Pops from a head of a double linked list.
static void gp_dlist_push_before(gp_dlist *list, gp_dlist_head *before, gp_dlist_head *entry)
Pushes an entry into a double linked list before an entry.
static gp_list_head * gp_list_pop_head(gp_list *list)
Pops from a head of a linked list.
static void gp_list_push_tail(gp_list *list, gp_list_head *entry)
Pushes into tail of linked list.
static void gp_dlist_rem(gp_dlist *list, gp_dlist_head *entry)
Removes a entry from a double linked list.
static void gp_list_push_head(gp_list *list, gp_list_head *entry)
Pushes into head of linked list.
static void gp_dlist_push_head(gp_dlist *list, gp_dlist_head *entry)
Pushes into head of double linked list.
static gp_dlist_head * gp_dlist_pop_tail(gp_dlist *list)
Pops from a tail of a double linked list.
static void gp_dlist_sort(gp_dlist *list, int(*cmp)(const void *, const void *))
Sorts a double linked list given a compare function.
static void gp_list_sort(gp_list *list, int(*cmp)(const void *, const void *))
Sorts a linked list given a element comparsion function.
A double linked list header.
struct gp_dlist_head * prev
Pointer to previous list element.
struct gp_dlist_head * next
Pointer to next list element.
A double linked list pointers.
gp_dlist_head * head
A pointer to list head.
size_t cnt
A number of elements in the list.
gp_dlist_head * tail
A pointer to list tail.
struct gp_list_head * next
Pointer to next list element.
gp_list_head * tail
A pointer to list tail.
size_t cnt
A number of elements in the list.
gp_list_head * head
A pointer to list head.