1 /* $NetBSD: lstInt.h,v 1.19 2009/01/24 11:59:39 dsl Exp $ */
4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * from: @(#)lstInt.h 8.1 (Berkeley) 6/6/93
39 * Internals for the list library
45 #include "../make_malloc.h"
47 typedef struct ListNode
{
48 struct ListNode
*prevPtr
; /* previous element in list */
49 struct ListNode
*nextPtr
; /* next in list */
50 unsigned int useCount
:8, /* Count of functions using the node.
51 * node may not be deleted until count
53 flags
:8; /* Node status flags */
54 void *datum
; /* datum associated with this element */
57 * Flags required for synchronization
59 #define LN_DELETED 0x0001 /* List node should be removed when done */
62 Head
, Middle
, Tail
, Unknown
66 ListNode firstPtr
; /* first node in list */
67 ListNode lastPtr
; /* last node in list */
68 Boolean isCirc
; /* true if the list should be considered
71 * fields for sequential access
73 Where atEnd
; /* Where in the list the last access was */
74 Boolean isOpen
; /* true if list has been Lst_Open'ed */
75 ListNode curPtr
; /* current node, if open. NULL if
77 ListNode prevPtr
; /* Previous node, if open. Used by
82 * PAlloc (var, ptype) --
83 * Allocate a pointer-typedef structure 'ptype' into the variable 'var'
85 #define PAlloc(var,ptype) var = (ptype) bmake_malloc(sizeof *(var))
89 * Return TRUE if the list l is valid
91 #define LstValid(l) ((Lst)(l) != NULL)
94 * LstNodeValid (ln, l) --
95 * Return TRUE if the LstNode ln is valid with respect to l
97 #define LstNodeValid(ln, l) ((ln) != NULL)
101 * TRUE if the list l is empty.
103 #define LstIsEmpty(l) (((List)(l))->firstPtr == NULL)
105 #endif /* _LSTINT_H_ */