smbnetfs  0.6.3
About: SMBNetFS is a Linux/FreeBSD filesystem that allow you to use samba/microsoft network in the same manner as the network neighborhood in Microsoft Windows.
  Fossies Dox: smbnetfs-0.6.3.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

list.h
Go to the documentation of this file.
1 #ifndef __LIST_H__
2 #define __LIST_H__
3 
4 #include <stddef.h>
5 
6 typedef struct __LIST{
7  struct __LIST *next;
8  struct __LIST *prev;
9 } LIST;
10 
11 #define list_entry(ptr, type, member) \
12  (type*)((char*)(ptr) - offsetof(type, member))
13 
14 #define STATIC_LIST_INITIALIZER(list) { &(list), &(list) }
15 
16 static inline LIST* first_list_elem(LIST *list){
17  return list->next;
18 }
19 
20 static inline LIST* last_list_elem(LIST *list){
21  return list->prev;
22 }
23 
24 static inline void add_to_list(LIST *list, LIST *elem){
25  /* Yes, i want SIGSEGV for debug */
26  if ((elem->next != NULL) || (elem->prev != NULL)) __builtin_trap();
27 
28  elem->next = list->next;
29  elem->prev = list;
30  list->next->prev = elem;
31  list->next = elem;
32 }
33 
34 static inline void add_to_list_back(LIST *list, LIST *elem){
35  /* Yes, i want SIGSEGV for debug */
36  if ((elem->next != NULL) || (elem->prev != NULL)) __builtin_trap();
37 
38  elem->next = list;
39  elem->prev = list->prev;
40  list->prev->next = elem;
41  list->prev = elem;
42 }
43 
44 static inline void insert_to_list_after(LIST *list, LIST *elem, LIST *new_elem){
45  (void)list;
46 
47  /* Yes, i want SIGSEGV for debug */
48  if ((new_elem->next != NULL) || (new_elem->prev != NULL)) __builtin_trap();
49 
50  new_elem->next = elem->next;
51  new_elem->prev = elem;
52  elem->next->prev = new_elem;
53  elem->next = new_elem;
54 }
55 
56 static inline void insert_to_list_before(LIST *list, LIST *elem, LIST *new_elem){
57  (void)list;
58 
59  /* Yes, i want SIGSEGV for debug */
60  if ((new_elem->next != NULL) || (new_elem->prev != NULL)) __builtin_trap();
61 
62  new_elem->next = elem;
63  new_elem->prev = elem->prev;
64  elem->prev->next = new_elem;
65  elem->prev = new_elem;
66 }
67 
68 static inline void replace_in_list(LIST *list, LIST *elem, LIST *new_elem){
69  (void)list;
70  new_elem->next = elem->next;
71  new_elem->prev = elem->prev;
72  elem->next->prev = new_elem;
73  elem->prev->next = new_elem;
74  elem->next = elem->prev = NULL;
75 }
76 
77 static inline void remove_from_list(LIST *list, LIST *elem){
78  (void)list;
79  elem->prev->next = elem->next;
80  elem->next->prev = elem->prev;
81  elem->next = elem->prev = NULL;
82 }
83 
84 static inline int is_list_empty(LIST *list){
85  return (list == list->next);
86 }
87 
88 static inline int is_valid_list_elem(LIST *list, LIST *elem){
89  return (elem != list);
90 }
91 
92 static inline void init_list(LIST *list){
93  list->next = list->prev = list;
94 }
95 
96 #endif /* __LIST_H__ */
static int is_valid_list_elem(LIST *list, LIST *elem)
Definition: list.h:88
static LIST * last_list_elem(LIST *list)
Definition: list.h:20
static void init_list(LIST *list)
Definition: list.h:92
static LIST * first_list_elem(LIST *list)
Definition: list.h:16
static void add_to_list_back(LIST *list, LIST *elem)
Definition: list.h:34
static void insert_to_list_before(LIST *list, LIST *elem, LIST *new_elem)
Definition: list.h:56
static int is_list_empty(LIST *list)
Definition: list.h:84
struct __LIST LIST
static void replace_in_list(LIST *list, LIST *elem, LIST *new_elem)
Definition: list.h:68
static void add_to_list(LIST *list, LIST *elem)
Definition: list.h:24
static void insert_to_list_after(LIST *list, LIST *elem, LIST *new_elem)
Definition: list.h:44
static void remove_from_list(LIST *list, LIST *elem)
Definition: list.h:77
Definition: list.h:6
struct __LIST * next
Definition: list.h:7
struct __LIST * prev
Definition: list.h:8