replace hash.c; speedup/cleanup from Chris Torek
[unix-history] / usr / src / usr.bin / make / lst.lib / lstInt.h
CommitLineData
fc03cc72
KB
1/*
2 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
3 * All rights reserved.
d4808d39 4 *
fc03cc72
KB
5 * This code is derived from software contributed to Berkeley by
6 * Adam de Boor.
d4808d39 7 *
f15db449 8 * %sccs.include.redist.c%
d4808d39 9 *
fc46faab 10 * @(#)lstInt.h 5.4 (Berkeley) %G%
fc03cc72
KB
11 */
12
13/*-
14 * lstInt.h --
15 * Internals for the list library
d4808d39
KB
16 */
17#ifndef _LSTINT_H_
18#define _LSTINT_H_
19
20#include "lst.h"
21
22typedef struct ListNode {
23 struct ListNode *prevPtr; /* previous element in list */
24 struct ListNode *nextPtr; /* next in list */
25 short useCount:8, /* Count of functions using the node.
26 * node may not be deleted until count
27 * goes to 0 */
28 flags:8; /* Node status flags */
29 ClientData datum; /* datum associated with this element */
30} *ListNode;
31/*
32 * Flags required for synchronization
33 */
34#define LN_DELETED 0x0001 /* List node should be removed when done */
35
36#define NilListNode ((ListNode)-1)
37
38typedef enum {
39 Head, Middle, Tail, Unknown
40} Where;
41
42typedef struct {
43 ListNode firstPtr; /* first node in list */
44 ListNode lastPtr; /* last node in list */
45 Boolean isCirc; /* true if the list should be considered
46 * circular */
47/*
48 * fields for sequential access
49 */
50 Where atEnd; /* Where in the list the last access was */
51 Boolean isOpen; /* true if list has been Lst_Open'ed */
52 ListNode curPtr; /* current node, if open. NilListNode if
53 * *just* opened */
54 ListNode prevPtr; /* Previous node, if open. Used by
55 * Lst_Remove */
56} *List;
57
58#define NilList ((List)-1)
59
60/*
61 * PAlloc (var, ptype) --
62 * Allocate a pointer-typedef structure 'ptype' into the variable 'var'
63 */
fc46faab 64#define PAlloc(var,ptype) var = (ptype) malloc (sizeof (*var))
d4808d39
KB
65
66/*
67 * LstValid (l) --
68 * Return TRUE if the list l is valid
69 */
70#define LstValid(l) (((Lst)l == NILLST) ? FALSE : TRUE)
71
72/*
73 * LstNodeValid (ln, l) --
74 * Return TRUE if the LstNode ln is valid with respect to l
75 */
76#define LstNodeValid(ln, l) ((((LstNode)ln) == NILLNODE) ? FALSE : TRUE)
77
78/*
79 * LstIsEmpty (l) --
80 * TRUE if the list l is empty.
81 */
82#define LstIsEmpty(l) (((List)l)->firstPtr == NilListNode)
83
84#endif _LSTINT_H_