1
/*********************************************************
2
* Copyright (C) 1998 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation version 2 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* You should have received a copy of the GNU General Public License along
14
* with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
*********************************************************/
28
#include "vm_basic_types.h"
30
#define INCLUDE_ALLOW_MODULE
31
#define INCLUDE_ALLOW_USERLEVEL
32
#include "includeCheck.h"
35
#define DblLnkLst_OffsetOf(type, field) ((intptr_t)&((type *)0)->field)
37
#define DblLnkLst_Container(addr, type, field) \
38
((type *)((char *)addr - DblLnkLst_OffsetOf(type, field)))
40
#define DblLnkLst_ForEach(curr, head) \
41
for (curr = (head)->next; curr != (head); curr = (curr)->next)
43
/* Safe from list element removal within loop body. */
44
#define DblLnkLst_ForEachSafe(curr, nextElem, head) \
45
for (curr = (head)->next, nextElem = (curr)->next; \
47
curr = nextElem, nextElem = (curr)->next)
49
typedef struct DblLnkLst_Links {
50
struct DblLnkLst_Links *prev;
51
struct DblLnkLst_Links *next;
55
/* Functions for both circular and anchored lists. --hpreg */
57
void DblLnkLst_Init(DblLnkLst_Links *l);
58
void DblLnkLst_Link(DblLnkLst_Links *l1, DblLnkLst_Links *l2);
59
void DblLnkLst_Unlink(DblLnkLst_Links *l1, DblLnkLst_Links *l2);
60
void DblLnkLst_Unlink1(DblLnkLst_Links *l);
61
Bool DblLnkLst_IsLinked(DblLnkLst_Links const *l);
63
/* Functions specific to anchored lists. --hpreg */
65
void DblLnkLst_LinkFirst(DblLnkLst_Links *head, DblLnkLst_Links *l);
66
void DblLnkLst_LinkLast(DblLnkLst_Links *head, DblLnkLst_Links *l);
69
#endif /* _DBLLNKLST_H_ */