File: /usr/include/linux/sunrpc/types.h
1 /*
2 * linux/include/linux/sunrpc/types.h
3 *
4 * Generic types and misc stuff for RPC.
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9 #ifndef _LINUX_SUNRPC_TYPES_H_
10 #define _LINUX_SUNRPC_TYPES_H_
11
12 #include <linux/timer.h>
13 #include <linux/tqueue.h>
14 #include <linux/sunrpc/debug.h>
15
16 /*
17 * These are the RPC list manipulation primitives used everywhere.
18 */
19 struct rpc_listitem {
20 struct rpc_listitem * prev;
21 struct rpc_listitem * next;
22 };
23
24 extern __inline__ void
25 __rpc_append_list(struct rpc_listitem **q, struct rpc_listitem *item)
26 {
27 struct rpc_listitem *next, *prev;
28
29 if (!(next = *q)) {
30 *q = item->next = item->prev = item;
31 } else {
32 prev = next->prev;
33 prev->next = item;
34 next->prev = item;
35 item->next = next;
36 item->prev = prev;
37 }
38 }
39
40 extern __inline__ void
41 __rpc_insert_list(struct rpc_listitem **q, struct rpc_listitem *item)
42 {
43 __rpc_append_list(q, item);
44 *q = item;
45 }
46
47 extern __inline__ void
48 __rpc_remove_list(struct rpc_listitem **q, struct rpc_listitem *item)
49 {
50 struct rpc_listitem *prev = item->prev,
51 *next = item->next;
52
53 if (item != prev) {
54 next->prev = prev;
55 prev->next = next;
56 } else {
57 next = NULL;
58 }
59 if (*q == item)
60 *q = next;
61 }
62
63 #define rpc_insert_list(q, i) \
64 __rpc_insert_list((struct rpc_listitem **) q, (struct rpc_listitem *) i)
65 #define rpc_append_list(q, i) \
66 __rpc_append_list((struct rpc_listitem **) q, (struct rpc_listitem *) i)
67 #define rpc_remove_list(q, i) \
68 __rpc_remove_list((struct rpc_listitem **) q, (struct rpc_listitem *) i)
69
70 /*
71 * Shorthands
72 */
73 #define signalled() (signal_pending(current))
74
75 #endif /* _LINUX_SUNRPC_TYPES_H_ */
76