Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6527 serge 1
#ifndef _LINUX_LIST_H
2
#define _LINUX_LIST_H
3
 
4
 
5
/*
6
 * Simple doubly linked list implementation.
7
 *
8
 * Some of the internal functions ("__xxx") are useful when
9
 * manipulating whole lists rather than single entries, as
10
 * sometimes we already know the next/prev entries and we can
11
 * generate better code by using them directly rather than
12
 * using the generic single-entry routines.
13
 */
14
 
15
/**
16
 * container_of - cast a member of a structure out to the containing structure
17
 * @ptr:    the pointer to the member.
18
 * @type:   the type of the container struct this is embedded in.
19
 * @member: the name of the member within the struct.
20
 *
21
 */
22
#define container_of(ptr, type, member) ({          \
23
    const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
24
    (type *)( (char *)__mptr - offsetof(type,member) );})
25
 
26
#define LIST_POISON1   ((struct list_head*)0xFFFF0100)
27
#define LIST_POISON2   ((struct list_head*)0xFFFF0200)
28
 
29
#define prefetch(x) __builtin_prefetch(x)
30
 
31
struct list_head {
32
	struct list_head *next, *prev;
33
};
34
 
35
#define LIST_HEAD_INIT(name) { &(name), &(name) }
36
 
37
#define LIST_HEAD(name) \
38
	struct list_head name = LIST_HEAD_INIT(name)
39
 
40
static inline void INIT_LIST_HEAD(struct list_head *list)
41
{
42
	list->next = list;
43
	list->prev = list;
44
}
45
 
46
/*
47
 * Insert a new entry between two known consecutive entries.
48
 *
49
 * This is only for internal list manipulation where we know
50
 * the prev/next entries already!
51
 */
52
#ifndef CONFIG_DEBUG_LIST
53
static inline void __list_add(struct list_head *new,
54
			      struct list_head *prev,
55
			      struct list_head *next)
56
{
57
	next->prev = new;
58
	new->next = next;
59
	new->prev = prev;
60
	prev->next = new;
61
}
62
#else
63
extern void __list_add(struct list_head *new,
64
			      struct list_head *prev,
65
			      struct list_head *next);
66
#endif
67
 
68
/**
69
 * list_add - add a new entry
70
 * @new: new entry to be added
71
 * @head: list head to add it after
72
 *
73
 * Insert a new entry after the specified head.
74
 * This is good for implementing stacks.
75
 */
76
static inline void list_add(struct list_head *new, struct list_head *head)
77
{
78
	__list_add(new, head, head->next);
79
}
80
 
81
 
82
/**
83
 * list_add_tail - add a new entry
84
 * @new: new entry to be added
85
 * @head: list head to add it before
86
 *
87
 * Insert a new entry before the specified head.
88
 * This is useful for implementing queues.
89
 */
90
static inline void list_add_tail(struct list_head *new, struct list_head *head)
91
{
92
	__list_add(new, head->prev, head);
93
}
94
 
95
/*
96
 * Delete a list entry by making the prev/next entries
97
 * point to each other.
98
 *
99
 * This is only for internal list manipulation where we know
100
 * the prev/next entries already!
101
 */
102
static inline void __list_del(struct list_head * prev, struct list_head * next)
103
{
104
	next->prev = prev;
105
	prev->next = next;
106
}
107
 
108
/**
109
 * list_del - deletes entry from list.
110
 * @entry: the element to delete from the list.
111
 * Note: list_empty() on entry does not return true after this, the entry is
112
 * in an undefined state.
113
 */
114
#ifndef CONFIG_DEBUG_LIST
115
static inline void list_del(struct list_head *entry)
116
{
117
	__list_del(entry->prev, entry->next);
118
	entry->next = LIST_POISON1;
119
	entry->prev = LIST_POISON2;
120
}
121
#else
122
extern void list_del(struct list_head *entry);
123
#endif
124
 
125
/**
126
 * list_replace - replace old entry by new one
127
 * @old : the element to be replaced
128
 * @new : the new element to insert
129
 *
130
 * If @old was empty, it will be overwritten.
131
 */
132
static inline void list_replace(struct list_head *old,
133
				struct list_head *new)
134
{
135
	new->next = old->next;
136
	new->next->prev = new;
137
	new->prev = old->prev;
138
	new->prev->next = new;
139
}
140
 
141
static inline void list_replace_init(struct list_head *old,
142
					struct list_head *new)
143
{
144
	list_replace(old, new);
145
	INIT_LIST_HEAD(old);
146
}
147
 
148
/**
149
 * list_del_init - deletes entry from list and reinitialize it.
150
 * @entry: the element to delete from the list.
151
 */
152
static inline void list_del_init(struct list_head *entry)
153
{
154
	__list_del(entry->prev, entry->next);
155
	INIT_LIST_HEAD(entry);
156
}
157
 
158
/**
159
 * list_move - delete from one list and add as another's head
160
 * @list: the entry to move
161
 * @head: the head that will precede our entry
162
 */
163
static inline void list_move(struct list_head *list, struct list_head *head)
164
{
165
	__list_del(list->prev, list->next);
166
	list_add(list, head);
167
}
168
 
169
/**
170
 * list_move_tail - delete from one list and add as another's tail
171
 * @list: the entry to move
172
 * @head: the head that will follow our entry
173
 */
174
static inline void list_move_tail(struct list_head *list,
175
				  struct list_head *head)
176
{
177
	__list_del(list->prev, list->next);
178
	list_add_tail(list, head);
179
}
180
 
181
/**
182
 * list_is_last - tests whether @list is the last entry in list @head
183
 * @list: the entry to test
184
 * @head: the head of the list
185
 */
186
static inline int list_is_last(const struct list_head *list,
187
				const struct list_head *head)
188
{
189
	return list->next == head;
190
}
191
 
192
/**
193
 * list_empty - tests whether a list is empty
194
 * @head: the list to test.
195
 */
196
static inline int list_empty(const struct list_head *head)
197
{
198
	return head->next == head;
199
}
200
 
201
/**
202
 * list_empty_careful - tests whether a list is empty and not being modified
203
 * @head: the list to test
204
 *
205
 * Description:
206
 * tests whether a list is empty _and_ checks that no other CPU might be
207
 * in the process of modifying either member (next or prev)
208
 *
209
 * NOTE: using list_empty_careful() without synchronization
210
 * can only be safe if the only activity that can happen
211
 * to the list entry is list_del_init(). Eg. it cannot be used
212
 * if another CPU could re-list_add() it.
213
 */
214
static inline int list_empty_careful(const struct list_head *head)
215
{
216
	struct list_head *next = head->next;
217
	return (next == head) && (next == head->prev);
218
}
219
 
220
/**
221
 * list_is_singular - tests whether a list has just one entry.
222
 * @head: the list to test.
223
 */
224
static inline int list_is_singular(const struct list_head *head)
225
{
226
	return !list_empty(head) && (head->next == head->prev);
227
}
228
 
229
static inline void __list_cut_position(struct list_head *list,
230
		struct list_head *head, struct list_head *entry)
231
{
232
	struct list_head *new_first = entry->next;
233
	list->next = head->next;
234
	list->next->prev = list;
235
	list->prev = entry;
236
	entry->next = list;
237
	head->next = new_first;
238
	new_first->prev = head;
239
}
240
 
241
/**
242
 * list_cut_position - cut a list into two
243
 * @list: a new list to add all removed entries
244
 * @head: a list with entries
245
 * @entry: an entry within head, could be the head itself
246
 *	and if so we won't cut the list
247
 *
248
 * This helper moves the initial part of @head, up to and
249
 * including @entry, from @head to @list. You should
250
 * pass on @entry an element you know is on @head. @list
251
 * should be an empty list or a list you do not care about
252
 * losing its data.
253
 *
254
 */
255
static inline void list_cut_position(struct list_head *list,
256
		struct list_head *head, struct list_head *entry)
257
{
258
	if (list_empty(head))
259
		return;
260
	if (list_is_singular(head) &&
261
		(head->next != entry && head != entry))
262
		return;
263
	if (entry == head)
264
		INIT_LIST_HEAD(list);
265
	else
266
		__list_cut_position(list, head, entry);
267
}
268
 
269
static inline void __list_splice(const struct list_head *list,
270
				 struct list_head *prev,
271
				 struct list_head *next)
272
{
273
	struct list_head *first = list->next;
274
	struct list_head *last = list->prev;
275
 
276
	first->prev = prev;
277
	prev->next = first;
278
 
279
	last->next = next;
280
	next->prev = last;
281
}
282
 
283
/**
284
 * list_splice - join two lists, this is designed for stacks
285
 * @list: the new list to add.
286
 * @head: the place to add it in the first list.
287
 */
288
static inline void list_splice(const struct list_head *list,
289
				struct list_head *head)
290
{
291
	if (!list_empty(list))
292
		__list_splice(list, head, head->next);
293
}
294
 
295
/**
296
 * list_splice_tail - join two lists, each list being a queue
297
 * @list: the new list to add.
298
 * @head: the place to add it in the first list.
299
 */
300
static inline void list_splice_tail(struct list_head *list,
301
				struct list_head *head)
302
{
303
	if (!list_empty(list))
304
		__list_splice(list, head->prev, head);
305
}
306
 
307
/**
308
 * list_splice_init - join two lists and reinitialise the emptied list.
309
 * @list: the new list to add.
310
 * @head: the place to add it in the first list.
311
 *
312
 * The list at @list is reinitialised
313
 */
314
static inline void list_splice_init(struct list_head *list,
315
				    struct list_head *head)
316
{
317
	if (!list_empty(list)) {
318
		__list_splice(list, head, head->next);
319
		INIT_LIST_HEAD(list);
320
	}
321
}
322
 
323
/**
324
 * list_splice_tail_init - join two lists and reinitialise the emptied list
325
 * @list: the new list to add.
326
 * @head: the place to add it in the first list.
327
 *
328
 * Each of the lists is a queue.
329
 * The list at @list is reinitialised
330
 */
331
static inline void list_splice_tail_init(struct list_head *list,
332
					 struct list_head *head)
333
{
334
	if (!list_empty(list)) {
335
		__list_splice(list, head->prev, head);
336
		INIT_LIST_HEAD(list);
337
	}
338
}
339
 
340
/**
341
 * list_entry - get the struct for this entry
342
 * @ptr:	the &struct list_head pointer.
343
 * @type:	the type of the struct this is embedded in.
344
 * @member:	the name of the list_struct within the struct.
345
 */
346
#define list_entry(ptr, type, member) \
347
	container_of(ptr, type, member)
348
 
349
/**
350
 * list_first_entry - get the first element from a list
351
 * @ptr:	the list head to take the element from.
352
 * @type:	the type of the struct this is embedded in.
353
 * @member:	the name of the list_struct within the struct.
354
 *
355
 * Note, that list is expected to be not empty.
356
 */
357
#define list_first_entry(ptr, type, member) \
358
	list_entry((ptr)->next, type, member)
359
 
360
/**
361
 * list_for_each	-	iterate over a list
362
 * @pos:	the &struct list_head to use as a loop cursor.
363
 * @head:	the head for your list.
364
 */
365
#define list_for_each(pos, head) \
366
	for (pos = (head)->next; prefetch(pos->next), pos != (head); \
367
        	pos = pos->next)
368
 
369
/**
370
 * __list_for_each	-	iterate over a list
371
 * @pos:	the &struct list_head to use as a loop cursor.
372
 * @head:	the head for your list.
373
 *
374
 * This variant differs from list_for_each() in that it's the
375
 * simplest possible list iteration code, no prefetching is done.
376
 * Use this for code that knows the list to be very short (empty
377
 * or 1 entry) most of the time.
378
 */
379
#define __list_for_each(pos, head) \
380
	for (pos = (head)->next; pos != (head); pos = pos->next)
381
 
382
/**
383
 * list_for_each_prev	-	iterate over a list backwards
384
 * @pos:	the &struct list_head to use as a loop cursor.
385
 * @head:	the head for your list.
386
 */
387
#define list_for_each_prev(pos, head) \
388
	for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
389
        	pos = pos->prev)
390
 
391
/**
392
 * list_for_each_safe - iterate over a list safe against removal of list entry
393
 * @pos:	the &struct list_head to use as a loop cursor.
394
 * @n:		another &struct list_head to use as temporary storage
395
 * @head:	the head for your list.
396
 */
397
#define list_for_each_safe(pos, n, head) \
398
	for (pos = (head)->next, n = pos->next; pos != (head); \
399
		pos = n, n = pos->next)
400
 
401
/**
402
 * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
403
 * @pos:	the &struct list_head to use as a loop cursor.
404
 * @n:		another &struct list_head to use as temporary storage
405
 * @head:	the head for your list.
406
 */
407
#define list_for_each_prev_safe(pos, n, head) \
408
	for (pos = (head)->prev, n = pos->prev; \
409
	     prefetch(pos->prev), pos != (head); \
410
	     pos = n, n = pos->prev)
411
 
412
/**
413
 * list_for_each_entry	-	iterate over list of given type
414
 * @pos:	the type * to use as a loop cursor.
415
 * @head:	the head for your list.
416
 * @member:	the name of the list_struct within the struct.
417
 */
418
#define list_for_each_entry(pos, head, member)				\
419
	for (pos = list_entry((head)->next, typeof(*pos), member);	\
420
	     prefetch(pos->member.next), &pos->member != (head); 	\
421
	     pos = list_entry(pos->member.next, typeof(*pos), member))
422
 
423
/**
424
 * list_for_each_entry_reverse - iterate backwards over list of given type.
425
 * @pos:	the type * to use as a loop cursor.
426
 * @head:	the head for your list.
427
 * @member:	the name of the list_struct within the struct.
428
 */
429
#define list_for_each_entry_reverse(pos, head, member)			\
430
	for (pos = list_entry((head)->prev, typeof(*pos), member);	\
431
	     prefetch(pos->member.prev), &pos->member != (head); 	\
432
	     pos = list_entry(pos->member.prev, typeof(*pos), member))
433
 
434
/**
435
 * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
436
 * @pos:	the type * to use as a start point
437
 * @head:	the head of the list
438
 * @member:	the name of the list_struct within the struct.
439
 *
440
 * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
441
 */
442
#define list_prepare_entry(pos, head, member) \
443
	((pos) ? : list_entry(head, typeof(*pos), member))
444
 
445
/**
446
 * list_for_each_entry_continue - continue iteration over list of given type
447
 * @pos:	the type * to use as a loop cursor.
448
 * @head:	the head for your list.
449
 * @member:	the name of the list_struct within the struct.
450
 *
451
 * Continue to iterate over list of given type, continuing after
452
 * the current position.
453
 */
454
#define list_for_each_entry_continue(pos, head, member) 		\
455
	for (pos = list_entry(pos->member.next, typeof(*pos), member);	\
456
	     prefetch(pos->member.next), &pos->member != (head);	\
457
	     pos = list_entry(pos->member.next, typeof(*pos), member))
458
 
459
/**
460
 * list_for_each_entry_continue_reverse - iterate backwards from the given point
461
 * @pos:	the type * to use as a loop cursor.
462
 * @head:	the head for your list.
463
 * @member:	the name of the list_struct within the struct.
464
 *
465
 * Start to iterate over list of given type backwards, continuing after
466
 * the current position.
467
 */
468
#define list_for_each_entry_continue_reverse(pos, head, member)		\
469
	for (pos = list_entry(pos->member.prev, typeof(*pos), member);	\
470
	     prefetch(pos->member.prev), &pos->member != (head);	\
471
	     pos = list_entry(pos->member.prev, typeof(*pos), member))
472
 
473
/**
474
 * list_for_each_entry_from - iterate over list of given type from the current point
475
 * @pos:	the type * to use as a loop cursor.
476
 * @head:	the head for your list.
477
 * @member:	the name of the list_struct within the struct.
478
 *
479
 * Iterate over list of given type, continuing from current position.
480
 */
481
#define list_for_each_entry_from(pos, head, member) 			\
482
	for (; prefetch(pos->member.next), &pos->member != (head);	\
483
	     pos = list_entry(pos->member.next, typeof(*pos), member))
484
 
485
/**
486
 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
487
 * @pos:	the type * to use as a loop cursor.
488
 * @n:		another type * to use as temporary storage
489
 * @head:	the head for your list.
490
 * @member:	the name of the list_struct within the struct.
491
 */
492
#define list_for_each_entry_safe(pos, n, head, member)			\
493
	for (pos = list_entry((head)->next, typeof(*pos), member),	\
494
		n = list_entry(pos->member.next, typeof(*pos), member);	\
495
	     &pos->member != (head); 					\
496
	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
497
 
498
/**
499
 * list_for_each_entry_safe_continue
500
 * @pos:	the type * to use as a loop cursor.
501
 * @n:		another type * to use as temporary storage
502
 * @head:	the head for your list.
503
 * @member:	the name of the list_struct within the struct.
504
 *
505
 * Iterate over list of given type, continuing after current point,
506
 * safe against removal of list entry.
507
 */
508
#define list_for_each_entry_safe_continue(pos, n, head, member) 		\
509
	for (pos = list_entry(pos->member.next, typeof(*pos), member), 		\
510
		n = list_entry(pos->member.next, typeof(*pos), member);		\
511
	     &pos->member != (head);						\
512
	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
513
 
514
/**
515
 * list_for_each_entry_safe_from
516
 * @pos:	the type * to use as a loop cursor.
517
 * @n:		another type * to use as temporary storage
518
 * @head:	the head for your list.
519
 * @member:	the name of the list_struct within the struct.
520
 *
521
 * Iterate over list of given type from current point, safe against
522
 * removal of list entry.
523
 */
524
#define list_for_each_entry_safe_from(pos, n, head, member) 			\
525
	for (n = list_entry(pos->member.next, typeof(*pos), member);		\
526
	     &pos->member != (head);						\
527
	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
528
 
529
/**
530
 * list_for_each_entry_safe_reverse
531
 * @pos:	the type * to use as a loop cursor.
532
 * @n:		another type * to use as temporary storage
533
 * @head:	the head for your list.
534
 * @member:	the name of the list_struct within the struct.
535
 *
536
 * Iterate backwards over list of given type, safe against removal
537
 * of list entry.
538
 */
539
#define list_for_each_entry_safe_reverse(pos, n, head, member)		\
540
	for (pos = list_entry((head)->prev, typeof(*pos), member),	\
541
		n = list_entry(pos->member.prev, typeof(*pos), member);	\
542
	     &pos->member != (head); 					\
543
	     pos = n, n = list_entry(n->member.prev, typeof(*n), member))
544
 
545
/*
546
 * Double linked lists with a single pointer list head.
547
 * Mostly useful for hash tables where the two pointer list head is
548
 * too wasteful.
549
 * You lose the ability to access the tail in O(1).
550
 */
551
 
552
struct hlist_head {
553
	struct hlist_node *first;
554
};
555
 
556
struct hlist_node {
557
	struct hlist_node *next, **pprev;
558
};
559
 
560
#define HLIST_HEAD_INIT { .first = NULL }
561
#define HLIST_HEAD(name) struct hlist_head name = {  .first = NULL }
562
#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
563
static inline void INIT_HLIST_NODE(struct hlist_node *h)
564
{
565
	h->next = NULL;
566
	h->pprev = NULL;
567
}
568
 
569
static inline int hlist_unhashed(const struct hlist_node *h)
570
{
571
	return !h->pprev;
572
}
573
 
574
static inline int hlist_empty(const struct hlist_head *h)
575
{
576
	return !h->first;
577
}
578
 
579
static inline void __hlist_del(struct hlist_node *n)
580
{
581
	struct hlist_node *next = n->next;
582
	struct hlist_node **pprev = n->pprev;
583
	*pprev = next;
584
	if (next)
585
		next->pprev = pprev;
586
}
587
 
588
static inline void hlist_del(struct hlist_node *n)
589
{
590
	__hlist_del(n);
591
    n->next = (struct hlist_node*)LIST_POISON1;
592
    n->pprev = (struct hlist_node**)LIST_POISON2;
593
}
594
 
595
static inline void hlist_del_init(struct hlist_node *n)
596
{
597
	if (!hlist_unhashed(n)) {
598
		__hlist_del(n);
599
		INIT_HLIST_NODE(n);
600
	}
601
}
602
 
603
static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
604
{
605
	struct hlist_node *first = h->first;
606
	n->next = first;
607
	if (first)
608
		first->pprev = &n->next;
609
	h->first = n;
610
	n->pprev = &h->first;
611
}
612
 
613
/* next must be != NULL */
614
static inline void hlist_add_before(struct hlist_node *n,
615
					struct hlist_node *next)
616
{
617
	n->pprev = next->pprev;
618
	n->next = next;
619
	next->pprev = &n->next;
620
	*(n->pprev) = n;
621
}
622
 
623
static inline void hlist_add_after(struct hlist_node *n,
624
					struct hlist_node *next)
625
{
626
	next->next = n->next;
627
	n->next = next;
628
	next->pprev = &n->next;
629
 
630
	if(next->next)
631
		next->next->pprev  = &next->next;
632
}
633
 
634
/*
635
 * Move a list from one list head to another. Fixup the pprev
636
 * reference of the first entry if it exists.
637
 */
638
static inline void hlist_move_list(struct hlist_head *old,
639
				   struct hlist_head *new)
640
{
641
	new->first = old->first;
642
	if (new->first)
643
		new->first->pprev = &new->first;
644
	old->first = NULL;
645
}
646
 
647
#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
648
 
649
#define hlist_for_each(pos, head) \
650
	for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
651
	     pos = pos->next)
652
 
653
#define hlist_for_each_safe(pos, n, head) \
654
	for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
655
	     pos = n)
656
 
657
/**
658
 * hlist_for_each_entry	- iterate over list of given type
659
 * @tpos:	the type * to use as a loop cursor.
660
 * @pos:	the &struct hlist_node to use as a loop cursor.
661
 * @head:	the head for your list.
662
 * @member:	the name of the hlist_node within the struct.
663
 */
664
#define hlist_for_each_entry(tpos, pos, head, member)			 \
665
	for (pos = (head)->first;					 \
666
	     pos && ({ prefetch(pos->next); 1;}) &&			 \
667
		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
668
	     pos = pos->next)
669
 
670
/**
671
 * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
672
 * @tpos:	the type * to use as a loop cursor.
673
 * @pos:	the &struct hlist_node to use as a loop cursor.
674
 * @member:	the name of the hlist_node within the struct.
675
 */
676
#define hlist_for_each_entry_continue(tpos, pos, member)		 \
677
	for (pos = (pos)->next;						 \
678
	     pos && ({ prefetch(pos->next); 1;}) &&			 \
679
		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
680
	     pos = pos->next)
681
 
682
/**
683
 * hlist_for_each_entry_from - iterate over a hlist continuing from current point
684
 * @tpos:	the type * to use as a loop cursor.
685
 * @pos:	the &struct hlist_node to use as a loop cursor.
686
 * @member:	the name of the hlist_node within the struct.
687
 */
688
#define hlist_for_each_entry_from(tpos, pos, member)			 \
689
	for (; pos && ({ prefetch(pos->next); 1;}) &&			 \
690
		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
691
	     pos = pos->next)
692
 
693
/**
694
 * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
695
 * @tpos:	the type * to use as a loop cursor.
696
 * @pos:	the &struct hlist_node to use as a loop cursor.
697
 * @n:		another &struct hlist_node to use as temporary storage
698
 * @head:	the head for your list.
699
 * @member:	the name of the hlist_node within the struct.
700
 */
701
#define hlist_for_each_entry_safe(tpos, pos, n, head, member) 		 \
702
	for (pos = (head)->first;					 \
703
	     pos && ({ n = pos->next; 1; }) && 				 \
704
		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
705
	     pos = n)
706
 
707
#endif