netatalk  4.4.0dev
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
include/atalk/list.h
Go to the documentation of this file.
1/* This code has been stolen from Linux kernel :) */
2/* distributed under GNU GPL version 2. */
3
4#ifndef _ATALK_LIST_H
5#define _ATALK_LIST_H
6
7/*
8 * Simple doubly linked list implementation.
9 *
10 * Some of the internal functions ("__xxx") are useful when
11 * manipulating whole lists rather than single entries, as
12 * sometimes we already know the next/prev entries and we can
13 * generate better code by using them directly rather than
14 * using the generic single-entry routines.
15 */
16
17struct list_head {
18 struct list_head *next, *prev;
19};
20
21#define ATALK_LIST_HEAD_INIT(name) { &(name), &(name) }
22
23#define ATALK_LIST_HEAD(name) \
24 struct list_head name = ATALK_LIST_HEAD_INIT(name)
25
26#define ATALK_INIT_LIST_HEAD(ptr) do { \
27 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
28} while (0)
29
30#ifdef USE_LIST
31/*
32 * Insert a new entry between two known consecutive entries.
33 *
34 * This is only for internal list manipulation where we know
35 * the prev/next entries already!
36 */
37static inline void __list_add(struct list_head *new,
38 struct list_head *prev,
39 struct list_head *next)
40{
41 next->prev = new;
42 new->next = next;
43 new->prev = prev;
44 prev->next = new;
45}
46
55static inline void list_add(struct list_head *new, struct list_head *head)
56{
57 __list_add(new, head, head->next);
58}
59
68static inline void list_add_tail(struct list_head *new, struct list_head *head)
69{
70 __list_add(new, head->prev, head);
71}
72
73/*
74 * Delete a list entry by making the prev/next entries
75 * point to each other.
76 *
77 * This is only for internal list manipulation where we know
78 * the prev/next entries already!
79 */
80static inline void __list_del(struct list_head *prev,
81 struct list_head *next)
82{
83 next->prev = prev;
84 prev->next = next;
85}
86
92static inline void list_del(struct list_head *entry)
93{
94 __list_del(entry->prev, entry->next);
95}
96
101static inline void list_del_init(struct list_head *entry)
102{
103 __list_del(entry->prev, entry->next);
105}
106
111static inline int list_empty(struct list_head *head)
112{
113 return head->next == head;
114}
115
121static inline void list_splice(struct list_head *list, struct list_head *head)
122{
123 struct list_head *first = list->next;
124
125 if (first != list) {
126 struct list_head *last = list->prev;
127 struct list_head *at = head->next;
128 first->prev = head;
129 head->next = first;
130 last->next = at;
131 at->prev = last;
132 }
133}
134
135#endif
142#define list_entry(ptr, type, member) \
143 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
144
150#define list_for_each(pos, head) \
151 for (pos = (head)->next; pos != (head); \
152 pos = pos->next)
153
159#define list_for_each_prev(pos, head) \
160 for (pos = (head)->prev; pos != (head); \
161 pos = pos->prev)
162#endif
#define next
Definition hash.c:35
#define ATALK_INIT_LIST_HEAD(ptr)
Definition include/atalk/list.h:26
static int first
Definition nad_ls.c:54
Definition ad_open.c:97
Definition include/atalk/list.h:17
struct list_head * prev
Definition include/atalk/list.h:18
struct list_head * next
Definition include/atalk/list.h:18
Definition etc/atalkd/list.h:6