head 1.8;
access;
symbols
SIO_0_9_3:1.8
SIO_0_9_2:1.7
SIO_0_9_1:1.7
SIO_0_9_0:1.7;
locks; strict;
comment @ * @;
1.8
date 2005.10.03.09.06.11; author rse; state Exp;
branches;
next 1.7;
1.7
date 2003.01.06.19.04.56; author rse; state Exp;
branches;
next 1.6;
1.6
date 2002.12.18.14.58.29; author mlelstv; state Exp;
branches;
next 1.5;
1.5
date 2002.12.18.14.41.04; author rse; state Exp;
branches;
next 1.4;
1.4
date 2002.12.18.08.50.28; author mlelstv; state Exp;
branches;
next 1.3;
1.3
date 2002.10.25.13.29.02; author mlelstv; state Exp;
branches;
next 1.2;
1.2
date 2002.10.18.10.21.41; author rse; state Exp;
branches;
next 1.1;
1.1
date 2002.10.18.08.57.34; author mlelstv; state Exp;
branches;
next ;
desc
@@
1.8
log
@adjust copyright messages
@
text
@/*
** OSSP sio - Stream I/O
** Copyright (c) 2002-2005 Cable & Wireless
** Copyright (c) 2002-2005 The OSSP Project
** Copyright (c) 2002-2005 Ralf S. Engelschall
**
** This file is part of OSSP sio, a layered stream I/O library
** which can be found at http://www.ossp.org/pkg/lib/sio/.
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** list.h: generic double-linked list macros
*/
#ifndef __LIST_H__
#define __LIST_H__
#define LIST(elem) \
struct { elem *head, *tail; }
#define NODE(elem) \
struct { elem *next, *prev; }
#define HEAD(q,l) ((q)->l.head)
#define TAIL(q,l) ((q)->l.tail)
#define NEXT(n,l) ((n)->l.next)
#define PREV(n,l) ((n)->l.prev)
#define ISEMPTY(q,l) (HEAD(q,l) == NULL)
#define LISTINIT(q,l) \
do { \
HEAD(q,l) = NULL; \
TAIL(q,l) = NULL; \
} while(0)
#define NODEINIT(n,l) \
do { \
NEXT(n,l) = NULL; \
PREV(n,l) = NULL; \
} while(0)
#define ADDTAIL2(q,l,n1,n2) \
do { \
if (TAIL(q,l)) { \
NEXT(TAIL(q,l),l) = (n1); \
PREV(n1,l) = TAIL(q,l); \
} else { \
HEAD(q,l) = (n1); \
PREV(n1,l) = NULL; \
} \
TAIL(q,l) = (n2); \
NEXT(n2,l) = NULL; \
} while (0)
#define ADDTAIL(q,l,n) ADDTAIL2(q,l,n,n)
#define ADDHEAD2(q,l,n1,n2) \
do { \
if (HEAD(q,l)) { \
PREV(HEAD(q,l),l) = (n2); \
NEXT(n2,l) = HEAD(q,l); \
} else { \
TAIL(q,l) = (n2); \
NEXT(n2,l) = NULL; \
} \
HEAD(q,l) = (n1); \
PREV(n1,l) = NULL; \
} while (0)
#define ADDHEAD(q,l,n) ADDHEAD2(q,l,n,n)
#define REMHEAD(q,l,n) \
do { \
(n) = HEAD(q,l); \
if (n) { \
HEAD(q,l) = NEXT(n,l); \
if (HEAD(q,l)) \
PREV(HEAD(q,l),l) = NULL; \
else \
TAIL(q,l) = NULL; \
} \
} while(0)
#define REMTAIL(q,l,n) \
do { \
(n) = TAIL(q,l); \
if (n) { \
TAIL(q,l) = PREV(n,l); \
if (TAIL(q,l)) \
NEXT(TAIL(q,l),l) = NULL; \
else \
HEAD(q,l) = NULL; \
} \
} while(0)
#define REMOVE2(q,l,n1,n2) \
do { \
if (PREV(n1,l)) \
NEXT(PREV(n1,l),l) = NEXT(n2,l); \
else \
HEAD(q,l) = NEXT(n2,l); \
if (NEXT(n2,l)) \
PREV(NEXT(n2,l),l) = PREV(n1,l); \
else \
TAIL(q,l) = PREV(n1,l); \
NEXT(n2,l) = NULL; \
PREV(n1,l) = NULL; \
} while (0)
#define REMOVE(q,l,n) REMOVE2(q,l,n,n)
#define INSERT2(q,l,i,n1,n2) \
do { \
if (PREV(i,l)) { \
NEXT(PREV(i,l),l) = (n1); \
} else { \
HEAD(q,l) = (n1); \
} \
PREV(n1,l) = PREV(i,l); \
PREV(i,l) = (n2); \
NEXT(n2,l) = (i); \
} while (0)
#define INSERT(q,l,i,n) INSERT2(q,l,i,n,n)
#define APPENDLIST(q1,l,q2) \
do { \
if (TAIL(q1,l)) { \
NEXT(TAIL(q1,l),l) = HEAD(q2,l); \
PREV(HEAD(q2,l),l) = TAIL(q1,l); \
} else { \
HEAD(q1,l) = HEAD(q2,l); \
} \
TAIL(q1,l) = TAIL(q2,l); \
LISTINIT(q2,l); \
} while(0)
#define INSERTLIST(q1,l,i,q2) \
do { \
if (PREV(i,l)) { \
NEXT(PREV(i,l),l) = HEAD(q2,l); \
} else { \
HEAD(q1,l) = HEAD(q2,l); \
} \
PREV(HEAD(q2,l),l) = PREV(i,l); \
NEXT(TAIL(q2,l),l) = (i); \
PREV(i,l) = TAIL(q2,l); \
LISTINIT(q2,l); \
} while(0)
#define FOREACH(q,l,n) for (n = HEAD(q,l); n; n = NEXT(n,l))
#define FOREACHR(q,l,n) for (n = TAIL(q,l); n; n = PREV(n,l))
#define FOREACHD(q,l,n,r) for (n = TAIL(q,l); n && (r = PREV(n,l), 1); n = r)
#endif /* __LIST_H__ */
@
1.7
log
@- consistently use standard OSSP copyright message everywhere
- strip trailing whitespaces
@
text
@d3 3
a5 3
** Copyright (c) 2002-2003 Cable & Wireless Deutschland
** Copyright (c) 2002-2003 The OSSP Project
** Copyright (c) 2002-2003 Ralf S. Engelschall
@
1.6
log
@snapshot
PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
@
text
@d2 4
a5 5
** OSSP sio -- Stream I/O
** Copyright (c) 2002 The OSSP Project
** Copyright (c) 2002 Cable & Wireless Deutschland
** Copyright (c) 2002 Ralf S. Engelschall
** Copyright (c) 2002 Michael van Elst
d7 2
a8 3
** This file is part of OSSP sio, an abstract data type of
** a pair of half-duplex data pipes which can be found at
** http://www.ossp.org/pkg/lib/sio/.
@
1.5
log
@fix this myself now
@
text
@d8 1
a8 1
** This file is part of OSSP sio, an abstract datatype of
@
1.4
log
@make this copy "part of sio"
PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
@
text
@d8 3
a10 3
## This file is part of OSSP sio, an abstract datatype of
## a pair of half-duplex data pipes which can be found at
## http://www.ossp.org/pkg/lib/sio/.
@
1.3
log
@optimize al_splice to unlink/relink several chunks in a single step
added necessary list macros to list.h
PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
@
text
@d2 1
a2 1
** OSSP al -- Assembly Line
d8 3
a10 2
** This file is part of OSSP al, an abstract datatype of a data buffer
** that can assemble, move and truncate data but avoids actual copying.
@
1.2
log
@add standard protect to avoid double-inclusions
@
text
@d59 1
a59 1
#define ADDTAIL(q,l,n) \
d62 2
a63 2
NEXT(TAIL(q,l),l) = (n); \
PREV(n,l) = TAIL(q,l); \
d65 2
a66 2
PREV(n,l) = NULL; \
HEAD(q,l) = (n); \
d68 2
a69 2
TAIL(q,l) = (n); \
NEXT(n,l) = NULL; \
d71 1
d73 1
a73 1
#define ADDHEAD(q,l,n) \
d76 2
a77 2
PREV(HEAD(q,l),l) = (n); \
NEXT(n,l) = HEAD(q,l); \
d79 2
a80 2
NEXT(n,l) = NULL; \
TAIL(q,l) = (n); \
d82 2
a83 2
HEAD(q,l) = (n); \
PREV(n,l) = NULL; \
d85 1
d111 1
a111 1
#define REMOVE(q,l,n) \
d113 2
a114 2
if (PREV(n,l)) \
NEXT(PREV(n,l),l) = NEXT(n,l); \
d116 3
a118 3
HEAD(q,l) = NEXT(n,l); \
if (NEXT(n,l)) \
PREV(NEXT(n,l),l) = PREV(n,l); \
d120 3
a122 3
TAIL(q,l) = PREV(n,l); \
NEXT(n,l) = NULL; \
PREV(n,l) = NULL; \
d124 1
d126 1
a126 1
#define INSERT(q,l,i,n) \
d129 1
a129 1
NEXT(PREV(i,l),l) = (n); \
d131 1
a131 1
HEAD(q,l) = (n); \
d133 3
a135 3
PREV(n,l) = PREV(i,l); \
PREV(i,l) = (n); \
NEXT(n,l) = (i); \
d137 1
@
1.1
log
@extracted generic list macros from al.c
PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
@
text
@d32 3
d163 2
@