Home | History | Annotate | Download | only in ffsb-6.0-rc2
      1 
      2 /*
      3  * Simple list implementation mostly take from the Linux Kernel
      4  */
      5 
      6 #include <stdlib.h>
      7 #include "list.h"
      8 
      9 void INIT_LIST_HEAD(struct list_head *list)
     10 {
     11 	list->next = list;
     12 	list->prev = list;
     13 }
     14 
     15 void __list_add(struct list_head *new,
     16 		struct list_head *prev, struct list_head *next)
     17 {
     18 	next->prev = new;
     19 	new->next = next;
     20 	new->prev = prev;
     21 	prev->next = new;
     22 }
     23 
     24 void __list_del(struct list_head *prev, struct list_head *next)
     25 {
     26 	next->prev = prev;
     27 	prev->next = next;
     28 }
     29 
     30 void list_add(struct list_head *new, struct list_head *head)
     31 {
     32 	__list_add(new, head, head->next);
     33 }
     34 
     35 void list_add_tail(struct list_head *new, struct list_head *head)
     36 {
     37 	__list_add(new, head->prev, head);
     38 }
     39 
     40 void list_del(struct list_head *entry)
     41 {
     42 	__list_del(entry->prev, entry->next);
     43 	entry->next = NULL;
     44 	entry->prev = NULL;
     45 }
     46 
     47 void list_replace(struct list_head *old, struct list_head *new)
     48 {
     49 	new->next = old->next;
     50 	new->next->prev = new;
     51 	new->prev = old->prev;
     52 	new->prev->next = new;
     53 }
     54