Subversion Repositories Kolibri OS

Rev

Rev 1970 | Rev 4065 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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