btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / src / add-ons / kernel / file_systems / googlefs / lists.h
blob6c3aadf2ab484663789b627e67efedef2fa25758
1 /*
2 * Copyright 2004-2008, François Revol, <revol@free.fr>.
3 * Distributed under the terms of the MIT License.
4 */
5 /* good old single linked list stuff */
6 #ifndef _LISTS_H
7 #define _LISTS_H
9 #include <stddef.h>
11 typedef struct _slist_entry {
12 struct _slist_entry *next;
13 char id[0];
14 } slist_entry;
16 typedef int (*slist_compare_func)(struct _slist_entry *item, void *id);
18 extern void slist_init(struct _slist_entry *item);
19 extern void slist_uninit(struct _slist_entry *item);
20 extern struct _slist_entry *slist_find(struct _slist_entry *head, slist_compare_func func, void *id);
21 extern status_t slist_insert_head(struct _slist_entry **head, struct _slist_entry *item);
22 extern struct _slist_entry *slist_dequeue_tail(struct _slist_entry **head);
23 extern status_t slist_remove(struct _slist_entry **head, struct _slist_entry *item);
24 extern struct _slist_entry *slist_next(struct _slist_entry *item);
26 #define LENT_TO_OBJ(_obtype, _sle, _moff) ((_obtype *)(((char *)(_sle)) - offsetof(_obtype, _moff)))
27 #define OBJ_TO_LENT(_obj, _member) (&((_obj)->_member))
30 #endif /* _LISTS_H */