Broadcom SDK and wireless driver: another attempt to update to ver. 5.10.147.0
[tomato.git] / release / src-rt / include / emf / emf / clist.h
blob1c21ea5e8cbe865b676e201b9188d81a40eef660
1 /*
2 * Copyright (C) 2009, Broadcom Corporation
3 * All Rights Reserved.
4 *
5 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
6 * the contents of this file may not be disclosed to third parties, copied
7 * or duplicated in any form, in whole or in part, without the prior
8 * written permission of Broadcom Corporation.
10 * $Id: clist.h,v 1.2 2008/08/12 17:50:33 Exp $
13 #ifndef _CLIST_H_
14 #define _CLIST_H_
16 typedef struct clist_head
18 struct clist_head *next, *prev;
19 } clist_head_t;
21 #define CLIST_DECL_INIT(head) clist_head_t head = { &(head), &(head) }
23 static inline void
24 clist_init_head(clist_head_t *head)
26 head->next = head->prev = head;
29 static inline void
30 clist_add_head(clist_head_t *head, clist_head_t *item)
32 head->next->prev = item;
33 item->next = head->next;
34 item->prev = head;
35 head->next = item;
37 return;
40 static inline void
41 clist_add_tail(clist_head_t *head, clist_head_t *item)
43 item->next = head;
44 item->prev = head->prev;
45 head->prev->next = item;
46 head->prev = item;
48 return;
51 static inline void
52 clist_delete(clist_head_t *item)
54 item->prev->next = item->next;
55 item->next->prev = item->prev;
57 return;
60 static inline void
61 clist_walk(clist_head_t *head, void (*fn)(clist_head_t *, void *), void *arg)
63 clist_head_t *ptr;
65 ptr = head;
67 while (ptr->next != head)
69 fn(ptr, arg);
70 ptr = ptr->next;
73 return;
76 #define clist_empty(h) ((h)->next == (h))
78 #define clist_entry(p, type, member) \
79 ((type *)((char *)(p)-(unsigned long)(&((type *)0)->member)))
81 #endif /* _CLIST_H_ */