2 * Copyright (C) 2009, Broadcom Corporation
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 $
16 typedef struct clist_head
18 struct clist_head
*next
, *prev
;
21 #define CLIST_DECL_INIT(head) clist_head_t head = { &(head), &(head) }
24 clist_init_head(clist_head_t
*head
)
26 head
->next
= head
->prev
= head
;
30 clist_add_head(clist_head_t
*head
, clist_head_t
*item
)
32 head
->next
->prev
= item
;
33 item
->next
= head
->next
;
41 clist_add_tail(clist_head_t
*head
, clist_head_t
*item
)
44 item
->prev
= head
->prev
;
45 head
->prev
->next
= item
;
52 clist_delete(clist_head_t
*item
)
54 item
->prev
->next
= item
->next
;
55 item
->next
->prev
= item
->prev
;
61 clist_walk(clist_head_t
*head
, void (*fn
)(clist_head_t
*, void *), void *arg
)
67 while (ptr
->next
!= head
)
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_ */