1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef __EXTRAS_H__
24#define __EXTRAS_H__
25
26#if defined WIN32
27#define __inline__ __inline
28#define new newHack
29#endif
30
31
32#if 1
33
34
35
36
37#if 0
38typedef unsigned char __u8;
39typedef unsigned short __u16;
40typedef unsigned __u32;
41#endif
42
43#include <asm/types.h>
44
45
46
47
48
49
50
51
52
53
54
55#define prefetch(x) 1
56
57struct list_head {
58 struct list_head *next, *prev;
59};
60
61#define LIST_HEAD_INIT(name) { &(name), &(name) }
62
63#define LIST_HEAD(name) \
64 struct list_head name = LIST_HEAD_INIT(name)
65
66#define INIT_LIST_HEAD(ptr) do { \
67 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
68} while (0)
69
70
71
72
73
74
75
76static __inline__ void __list_add(struct list_head *new,
77 struct list_head *prev,
78 struct list_head *next)
79{
80 next->prev = new;
81 new->next = next;
82 new->prev = prev;
83 prev->next = new;
84}
85
86
87
88
89
90
91
92
93
94static __inline__ void list_add(struct list_head *new, struct list_head *head)
95{
96 __list_add(new, head, head->next);
97}
98
99
100
101
102
103
104
105
106
107static __inline__ void list_add_tail(struct list_head *new,
108 struct list_head *head)
109{
110 __list_add(new, head->prev, head);
111}
112
113
114
115
116
117
118
119
120static __inline__ void __list_del(struct list_head *prev,
121 struct list_head *next)
122{
123 next->prev = prev;
124 prev->next = next;
125}
126
127
128
129
130
131
132
133static __inline__ void list_del(struct list_head *entry)
134{
135 __list_del(entry->prev, entry->next);
136}
137
138
139
140
141
142static __inline__ void list_del_init(struct list_head *entry)
143{
144 __list_del(entry->prev, entry->next);
145 INIT_LIST_HEAD(entry);
146}
147
148
149
150
151
152static __inline__ int list_empty(struct list_head *head)
153{
154 return head->next == head;
155}
156
157
158
159
160
161
162static __inline__ void list_splice(struct list_head *list,
163 struct list_head *head)
164{
165 struct list_head *first = list->next;
166
167 if (first != list) {
168 struct list_head *last = list->prev;
169 struct list_head *at = head->next;
170
171 first->prev = head;
172 head->next = first;
173
174 last->next = at;
175 at->prev = last;
176 }
177}
178
179
180
181
182
183
184
185#define list_entry(ptr, type, member) \
186 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
187
188
189
190
191
192
193#define list_for_each(pos, head) \
194 for (pos = (head)->next, prefetch(pos->next); pos != (head); \
195 pos = pos->next, prefetch(pos->next))
196
197
198
199
200
201
202
203
204#define list_for_each_safe(pos, n, head) \
205 for (pos = (head)->next, n = pos->next; pos != (head); \
206 pos = n, n = pos->next)
207
208
209
210
211#define DT_UNKNOWN 0
212#define DT_FIFO 1
213#define DT_CHR 2
214#define DT_DIR 4
215#define DT_BLK 6
216#define DT_REG 8
217#define DT_LNK 10
218#define DT_SOCK 12
219#define DT_WHT 14
220
221#ifndef WIN32
222
223#if 0
224#include <sys/stat.h>
225#else
226#include "common.h"
227#endif
228#endif
229
230
231
232
233
234#define ATTR_MODE 1
235#define ATTR_UID 2
236#define ATTR_GID 4
237#define ATTR_SIZE 8
238#define ATTR_ATIME 16
239#define ATTR_MTIME 32
240#define ATTR_CTIME 64
241#define ATTR_ATIME_SET 128
242#define ATTR_MTIME_SET 256
243#define ATTR_FORCE 512
244#define ATTR_ATTR_FLAG 1024
245
246struct iattr {
247 unsigned int ia_valid;
248 unsigned ia_mode;
249 unsigned ia_uid;
250 unsigned ia_gid;
251 unsigned ia_size;
252 unsigned ia_atime;
253 unsigned ia_mtime;
254 unsigned ia_ctime;
255 unsigned int ia_attr_flags;
256};
257
258#define KERN_DEBUG
259
260#else
261
262#ifndef WIN32
263#include <linux/types.h>
264#include <linux/list.h>
265#include <linux/fs.h>
266#include <linux/stat.h>
267#endif
268
269#endif
270
271#if defined WIN32
272#undef new
273#endif
274
275#endif
276