5 #ifndef HAKA_CONTAINER_LIST_H 6 #define HAKA_CONTAINER_LIST_H 8 #include <haka/compiler.h> 17 #define LIST_INIT {NULL, NULL} 19 #define list_getuserptr(l, offset) ((l) ? (void*)((char*)(l)-(offset)) : NULL) 21 #define list_init(a) { _list_init(&(a)->list); } 22 #define list_next(a) ((typeof(a))(list_getuserptr((a)->list.next, offsetof(typeof(*a), list)))) 23 #define list_prev(a) ((typeof(a))(list_getuserptr((a)->list.prev, offsetof(typeof(*a), list)))) 24 #define list_remove(a, h, t) _list_remove(&(a)->list, offsetof(typeof(*a), list), (void**)(h), (void**)(t)) 25 #define list_insert_after(a, i, h, t) _list_insert_after(&(a)->list, (i) ? &(((typeof(a))(i))->list) : NULL, offsetof(typeof(*a), list), (void**)(h), (void**)(t)) 26 #define list_insert_before(a, i, h, t) _list_insert_before(&(a)->list, (i) ? &(((typeof(a))(i))->list) : NULL, offsetof(typeof(*a), list), (void**)(h), (void**)(t)) 28 void _list_init(
struct list *l);
29 void _list_remove(
struct list *l,
int offset,
void **head,
void **tail);
30 void _list_insert_after(
struct list *elem,
struct list *l,
int offset,
31 void **head,
void **tail);
32 void _list_insert_before(
struct list *elem,
struct list *l,
int offset,
33 void **head,
void **tail);