1*0a6a1f1dSLionel Sambuc /* $NetBSD: lstInt.h,v 1.22 2014/09/07 20:55:34 joerg Exp $ */ 22e2caf59SThomas Veerman 32e2caf59SThomas Veerman /* 42e2caf59SThomas Veerman * Copyright (c) 1988, 1989, 1990, 1993 52e2caf59SThomas Veerman * The Regents of the University of California. All rights reserved. 62e2caf59SThomas Veerman * 72e2caf59SThomas Veerman * This code is derived from software contributed to Berkeley by 82e2caf59SThomas Veerman * Adam de Boor. 92e2caf59SThomas Veerman * 102e2caf59SThomas Veerman * Redistribution and use in source and binary forms, with or without 112e2caf59SThomas Veerman * modification, are permitted provided that the following conditions 122e2caf59SThomas Veerman * are met: 132e2caf59SThomas Veerman * 1. Redistributions of source code must retain the above copyright 142e2caf59SThomas Veerman * notice, this list of conditions and the following disclaimer. 152e2caf59SThomas Veerman * 2. Redistributions in binary form must reproduce the above copyright 162e2caf59SThomas Veerman * notice, this list of conditions and the following disclaimer in the 172e2caf59SThomas Veerman * documentation and/or other materials provided with the distribution. 182e2caf59SThomas Veerman * 3. Neither the name of the University nor the names of its contributors 192e2caf59SThomas Veerman * may be used to endorse or promote products derived from this software 202e2caf59SThomas Veerman * without specific prior written permission. 212e2caf59SThomas Veerman * 222e2caf59SThomas Veerman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 232e2caf59SThomas Veerman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 242e2caf59SThomas Veerman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 252e2caf59SThomas Veerman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 262e2caf59SThomas Veerman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 272e2caf59SThomas Veerman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 282e2caf59SThomas Veerman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 292e2caf59SThomas Veerman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 302e2caf59SThomas Veerman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 312e2caf59SThomas Veerman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 322e2caf59SThomas Veerman * SUCH DAMAGE. 332e2caf59SThomas Veerman * 342e2caf59SThomas Veerman * from: @(#)lstInt.h 8.1 (Berkeley) 6/6/93 352e2caf59SThomas Veerman */ 362e2caf59SThomas Veerman 372e2caf59SThomas Veerman /*- 382e2caf59SThomas Veerman * lstInt.h -- 392e2caf59SThomas Veerman * Internals for the list library 402e2caf59SThomas Veerman */ 412e2caf59SThomas Veerman #ifndef _LSTINT_H_ 422e2caf59SThomas Veerman #define _LSTINT_H_ 432e2caf59SThomas Veerman 442e2caf59SThomas Veerman #include "../lst.h" 452e2caf59SThomas Veerman #include "../make_malloc.h" 462e2caf59SThomas Veerman 472e2caf59SThomas Veerman typedef struct ListNode { 482e2caf59SThomas Veerman struct ListNode *prevPtr; /* previous element in list */ 492e2caf59SThomas Veerman struct ListNode *nextPtr; /* next in list */ 502e2caf59SThomas Veerman unsigned int useCount:8, /* Count of functions using the node. 512e2caf59SThomas Veerman * node may not be deleted until count 522e2caf59SThomas Veerman * goes to 0 */ 532e2caf59SThomas Veerman flags:8; /* Node status flags */ 542e2caf59SThomas Veerman void *datum; /* datum associated with this element */ 552e2caf59SThomas Veerman } *ListNode; 562e2caf59SThomas Veerman /* 572e2caf59SThomas Veerman * Flags required for synchronization 582e2caf59SThomas Veerman */ 592e2caf59SThomas Veerman #define LN_DELETED 0x0001 /* List node should be removed when done */ 602e2caf59SThomas Veerman 612e2caf59SThomas Veerman typedef enum { 622e2caf59SThomas Veerman Head, Middle, Tail, Unknown 632e2caf59SThomas Veerman } Where; 642e2caf59SThomas Veerman 652e2caf59SThomas Veerman typedef struct List { 662e2caf59SThomas Veerman ListNode firstPtr; /* first node in list */ 672e2caf59SThomas Veerman ListNode lastPtr; /* last node in list */ 682e2caf59SThomas Veerman Boolean isCirc; /* true if the list should be considered 692e2caf59SThomas Veerman * circular */ 702e2caf59SThomas Veerman /* 712e2caf59SThomas Veerman * fields for sequential access 722e2caf59SThomas Veerman */ 732e2caf59SThomas Veerman Where atEnd; /* Where in the list the last access was */ 742e2caf59SThomas Veerman Boolean isOpen; /* true if list has been Lst_Open'ed */ 752e2caf59SThomas Veerman ListNode curPtr; /* current node, if open. NULL if 762e2caf59SThomas Veerman * *just* opened */ 772e2caf59SThomas Veerman ListNode prevPtr; /* Previous node, if open. Used by 782e2caf59SThomas Veerman * Lst_Remove */ 792e2caf59SThomas Veerman } *List; 802e2caf59SThomas Veerman 812e2caf59SThomas Veerman /* 822e2caf59SThomas Veerman * PAlloc (var, ptype) -- 832e2caf59SThomas Veerman * Allocate a pointer-typedef structure 'ptype' into the variable 'var' 842e2caf59SThomas Veerman */ 852e2caf59SThomas Veerman #define PAlloc(var,ptype) var = (ptype) bmake_malloc(sizeof *(var)) 862e2caf59SThomas Veerman 872e2caf59SThomas Veerman /* 882e2caf59SThomas Veerman * LstValid (l) -- 892e2caf59SThomas Veerman * Return TRUE if the list l is valid 902e2caf59SThomas Veerman */ 912e2caf59SThomas Veerman #define LstValid(l) ((Lst)(l) != NULL) 922e2caf59SThomas Veerman 932e2caf59SThomas Veerman /* 942e2caf59SThomas Veerman * LstNodeValid (ln, l) -- 952e2caf59SThomas Veerman * Return TRUE if the LstNode ln is valid with respect to l 962e2caf59SThomas Veerman */ 972e2caf59SThomas Veerman #define LstNodeValid(ln, l) ((ln) != NULL) 982e2caf59SThomas Veerman 992e2caf59SThomas Veerman /* 1002e2caf59SThomas Veerman * LstIsEmpty (l) -- 1012e2caf59SThomas Veerman * TRUE if the list l is empty. 1022e2caf59SThomas Veerman */ 1032e2caf59SThomas Veerman #define LstIsEmpty(l) (((List)(l))->firstPtr == NULL) 1042e2caf59SThomas Veerman 1052e2caf59SThomas Veerman #endif /* _LSTINT_H_ */ 106