remove the netfilter time patch from 2.6.28 as it duplicates functionality that is...
[openwrt.git] / target / linux / generic-2.6 / files / fs / yaffs2 / devextras.h
1 /*
2 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
3 *
4 * Copyright (C) 2002-2007 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
6 *
7 * Created by Charles Manning <charles@aleph1.co.uk>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License version 2.1 as
11 * published by the Free Software Foundation.
12 *
13 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
14 */
15
16 /*
17 * This file is just holds extra declarations used during development.
18 * Most of these are from kernel includes placed here so we can use them in
19 * applications.
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 #if !(defined __KERNEL__) || (defined WIN32)
32
33 /* User space defines */
34
35 typedef unsigned char __u8;
36 typedef unsigned short __u16;
37 typedef unsigned __u32;
38
39 /*
40 * Simple doubly linked list implementation.
41 *
42 * Some of the internal functions ("__xxx") are useful when
43 * manipulating whole lists rather than single entries, as
44 * sometimes we already know the next/prev entries and we can
45 * generate better code by using them directly rather than
46 * using the generic single-entry routines.
47 */
48
49 #define prefetch(x) 1
50
51 struct list_head {
52 struct list_head *next, *prev;
53 };
54
55 #define LIST_HEAD_INIT(name) { &(name), &(name) }
56
57 #define LIST_HEAD(name) \
58 struct list_head name = LIST_HEAD_INIT(name)
59
60 #define INIT_LIST_HEAD(ptr) do { \
61 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
62 } while (0)
63
64 /*
65 * Insert a new entry between two known consecutive entries.
66 *
67 * This is only for internal list manipulation where we know
68 * the prev/next entries already!
69 */
70 static __inline__ void __list_add(struct list_head *new,
71 struct list_head *prev,
72 struct list_head *next)
73 {
74 next->prev = new;
75 new->next = next;
76 new->prev = prev;
77 prev->next = new;
78 }
79
80 /**
81 * list_add - add a new entry
82 * @new: new entry to be added
83 * @head: list head to add it after
84 *
85 * Insert a new entry after the specified head.
86 * This is good for implementing stacks.
87 */
88 static __inline__ void list_add(struct list_head *new, struct list_head *head)
89 {
90 __list_add(new, head, head->next);
91 }
92
93 /**
94 * list_add_tail - add a new entry
95 * @new: new entry to be added
96 * @head: list head to add it before
97 *
98 * Insert a new entry before the specified head.
99 * This is useful for implementing queues.
100 */
101 static __inline__ void list_add_tail(struct list_head *new,
102 struct list_head *head)
103 {
104 __list_add(new, head->prev, head);
105 }
106
107 /*
108 * Delete a list entry by making the prev/next entries
109 * point to each other.
110 *
111 * This is only for internal list manipulation where we know
112 * the prev/next entries already!
113 */
114 static __inline__ void __list_del(struct list_head *prev,
115 struct list_head *next)
116 {
117 next->prev = prev;
118 prev->next = next;
119 }
120
121 /**
122 * list_del - deletes entry from list.
123 * @entry: the element to delete from the list.
124 * Note: list_empty on entry does not return true after this, the entry is
125 * in an undefined state.
126 */
127 static __inline__ void list_del(struct list_head *entry)
128 {
129 __list_del(entry->prev, entry->next);
130 }
131
132 /**
133 * list_del_init - deletes entry from list and reinitialize it.
134 * @entry: the element to delete from the list.
135 */
136 static __inline__ void list_del_init(struct list_head *entry)
137 {
138 __list_del(entry->prev, entry->next);
139 INIT_LIST_HEAD(entry);
140 }
141
142 /**
143 * list_empty - tests whether a list is empty
144 * @head: the list to test.
145 */
146 static __inline__ int list_empty(struct list_head *head)
147 {
148 return head->next == head;
149 }
150
151 /**
152 * list_splice - join two lists
153 * @list: the new list to add.
154 * @head: the place to add it in the first list.
155 */
156 static __inline__ void list_splice(struct list_head *list,
157 struct list_head *head)
158 {
159 struct list_head *first = list->next;
160
161 if (first != list) {
162 struct list_head *last = list->prev;
163 struct list_head *at = head->next;
164
165 first->prev = head;
166 head->next = first;
167
168 last->next = at;
169 at->prev = last;
170 }
171 }
172
173 /**
174 * list_entry - get the struct for this entry
175 * @ptr: the &struct list_head pointer.
176 * @type: the type of the struct this is embedded in.
177 * @member: the name of the list_struct within the struct.
178 */
179 #define list_entry(ptr, type, member) \
180 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
181
182 /**
183 * list_for_each - iterate over a list
184 * @pos: the &struct list_head to use as a loop counter.
185 * @head: the head for your list.
186 */
187 #define list_for_each(pos, head) \
188 for (pos = (head)->next, prefetch(pos->next); pos != (head); \
189 pos = pos->next, prefetch(pos->next))
190
191 /**
192 * list_for_each_safe - iterate over a list safe against removal
193 * of list entry
194 * @pos: the &struct list_head to use as a loop counter.
195 * @n: another &struct list_head to use as temporary storage
196 * @head: the head for your list.
197 */
198 #define list_for_each_safe(pos, n, head) \
199 for (pos = (head)->next, n = pos->next; pos != (head); \
200 pos = n, n = pos->next)
201
202 /*
203 * File types
204 */
205 #define DT_UNKNOWN 0
206 #define DT_FIFO 1
207 #define DT_CHR 2
208 #define DT_DIR 4
209 #define DT_BLK 6
210 #define DT_REG 8
211 #define DT_LNK 10
212 #define DT_SOCK 12
213 #define DT_WHT 14
214
215 #ifndef WIN32
216 #include <sys/stat.h>
217 #endif
218
219 /*
220 * Attribute flags. These should be or-ed together to figure out what
221 * has been changed!
222 */
223 #define ATTR_MODE 1
224 #define ATTR_UID 2
225 #define ATTR_GID 4
226 #define ATTR_SIZE 8
227 #define ATTR_ATIME 16
228 #define ATTR_MTIME 32
229 #define ATTR_CTIME 64
230 #define ATTR_ATIME_SET 128
231 #define ATTR_MTIME_SET 256
232 #define ATTR_FORCE 512 /* Not a change, but a change it */
233 #define ATTR_ATTR_FLAG 1024
234
235 struct iattr {
236 unsigned int ia_valid;
237 unsigned ia_mode;
238 unsigned ia_uid;
239 unsigned ia_gid;
240 unsigned ia_size;
241 unsigned ia_atime;
242 unsigned ia_mtime;
243 unsigned ia_ctime;
244 unsigned int ia_attr_flags;
245 };
246
247 #define KERN_DEBUG
248
249 #else
250
251 #ifndef WIN32
252 #include <linux/types.h>
253 #include <linux/list.h>
254 #include <linux/fs.h>
255 #include <linux/stat.h>
256 #endif
257
258 #endif
259
260 #if defined WIN32
261 #undef new
262 #endif
263
264 #endif
This page took 0.07473 seconds and 5 git commands to generate.