43#ifndef CYGONCE_FS_JFFS2_LIST_H
44#define CYGONCE_FS_JFFS2_LIST_H
53#include <cyg/infra/cyg_type.h>
64#define LIST_HEAD_INIT(name) { &(name), &(name) }
66#define LIST_HEAD(name) \
67 struct list_head name = LIST_HEAD_INIT(name)
69#define INIT_LIST_HEAD( _list_ ) \
71(_list_)->next = (_list_)->prev = (_list_); \
80 struct list_head *next = afterthisent->next;
82 newent->prev = afterthisent;
83 afterthisent->next = newent;
91 struct list_head *prev = beforethisent->prev;
93 newent->next = beforethisent;
94 beforethisent->prev = newent;
102 ent->prev->next = ent->next;
103 ent->next->prev = ent->prev;
106static __inline__
void
110 list_add( list, head );
113static __inline__
void
117 list_add_tail( list, head );
124 return ( list->next == list );
132#define list_entry( _list_, _type_, _member_ ) \
133 ((_type_ *)((char *)(_list_)-(char *)(offsetof(_type_,_member_))))
137#define list_for_each( _ent_, _list_ ) \
138 for ( (_ent_) = (_list_)->next; \
139 (_ent_) != (_list_); \
140 (_ent_) = (_ent_)->next )
145#define list_for_each_safe( _ent_, _tmp_, _list_ ) \
146 for ( (_ent_) = (_list_)->next, (_tmp_) = (_ent_)->next; \
147 (_ent_) != (_list_); \
148 (_ent_) = (_tmp_), (_tmp_) = (_ent_)->next )
154#define list_for_each_entry(_list_, _head_, _item_) \
155for ((_list_) = list_entry((_head_)->next, typeof(*_list_), _item_); \
156 &((_list_)->_item_) != (_head_); \
157 (_list_) = list_entry((_list_)->_item_.next, typeof(*_list_), _item_))