Blame as10k1/list.h

Packit Service b98cfc
/* From linux kernel source */
Packit Service b98cfc
Packit Service b98cfc
Packit Service b98cfc
#ifndef _LINUX_LIST_H
Packit Service b98cfc
#define _LINUX_LIST_H
Packit Service b98cfc
Packit Service b98cfc
/*
Packit Service b98cfc
 * Simple doubly linked list implementation.
Packit Service b98cfc
 *
Packit Service b98cfc
 * Some of the internal functions ("__xxx") are useful when
Packit Service b98cfc
 * manipulating whole lists rather than single entries, as
Packit Service b98cfc
 * sometimes we already know the next/prev entries and we can
Packit Service b98cfc
 * generate better code by using them directly rather than
Packit Service b98cfc
 * using the generic single-entry routines.
Packit Service b98cfc
 */
Packit Service b98cfc
Packit Service b98cfc
struct list_head {
Packit Service b98cfc
	struct list_head *next, *prev;
Packit Service b98cfc
};
Packit Service b98cfc
Packit Service b98cfc
#define LIST_HEAD(name) \
Packit Service b98cfc
	struct list_head name = { &name, &name }
Packit Service b98cfc
Packit Service b98cfc
#define INIT_LIST_HEAD(ptr) do { \
Packit Service b98cfc
	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
Packit Service b98cfc
} while (0)
Packit Service b98cfc
Packit Service b98cfc
/*
Packit Service b98cfc
 * Insert a new entry between two known consecutive entries. 
Packit Service b98cfc
 *
Packit Service b98cfc
 * This is only for internal list manipulation where we know
Packit Service b98cfc
 * the prev/next entries already!
Packit Service b98cfc
 */
Packit Service b98cfc
static __inline__ void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
Packit Service b98cfc
{
Packit Service b98cfc
	next->prev = new;
Packit Service b98cfc
	new->next = next;
Packit Service b98cfc
	new->prev = prev;
Packit Service b98cfc
	prev->next = new;
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
/*
Packit Service b98cfc
 * Insert a new entry after the specified head..
Packit Service b98cfc
 */
Packit Service b98cfc
static __inline__ void list_add(struct list_head *new, struct list_head *head)
Packit Service b98cfc
{
Packit Service b98cfc
	__list_add(new, head, head->next);
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
/*
Packit Service b98cfc
 * Insert a new entry before the specified head..
Packit Service b98cfc
 */
Packit Service b98cfc
static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
Packit Service b98cfc
{
Packit Service b98cfc
	__list_add(new, head->prev, head);
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
Packit Service b98cfc
/*
Packit Service b98cfc
 * Delete a list entry by making the prev/next entries
Packit Service b98cfc
 * point to each other.
Packit Service b98cfc
 *
Packit Service b98cfc
 * This is only for internal list manipulation where we know
Packit Service b98cfc
 * the prev/next entries already!
Packit Service b98cfc
 */
Packit Service b98cfc
static __inline__ void __list_del(struct list_head *prev, struct list_head *next)
Packit Service b98cfc
{
Packit Service b98cfc
	next->prev = prev;
Packit Service b98cfc
	prev->next = next;
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
static __inline__ void list_del(struct list_head *entry)
Packit Service b98cfc
{
Packit Service b98cfc
	__list_del(entry->prev, entry->next);
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
static __inline__ int list_empty(struct list_head *head)
Packit Service b98cfc
{
Packit Service b98cfc
	return head->next == head;
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
#define list_entry(ptr, type, member) \
Packit Service b98cfc
	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
Packit Service b98cfc
Packit Service b98cfc
#define list_for_each(pos, head) \
Packit Service b98cfc
        for (pos = (head)->next; pos != (head); pos = pos->next)
Packit Service b98cfc
Packit Service b98cfc
#endif