insque.c revision 1.1 1 1.1 drochner /*
2 1.1 drochner * Copyright (c) 1993 John Brezak
3 1.1 drochner * All rights reserved.
4 1.1 drochner *
5 1.1 drochner * Redistribution and use in source and binary forms, with or without
6 1.1 drochner * modification, are permitted provided that the following conditions
7 1.1 drochner * are met:
8 1.1 drochner * 1. Redistributions of source code must retain the above copyright
9 1.1 drochner * notice, this list of conditions and the following disclaimer.
10 1.1 drochner * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 drochner * notice, this list of conditions and the following disclaimer in the
12 1.1 drochner * documentation and/or other materials provided with the distribution.
13 1.1 drochner * 3. The name of the author may be used to endorse or promote products
14 1.1 drochner * derived from this software without specific prior written permission.
15 1.1 drochner *
16 1.1 drochner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
17 1.1 drochner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 1.1 drochner * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 1.1 drochner * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 1.1 drochner * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 1.1 drochner * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 1.1 drochner * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1 drochner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 1.1 drochner * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 1.1 drochner * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 drochner * POSSIBILITY OF SUCH DAMAGE.
27 1.1 drochner */
28 1.1 drochner
29 1.1 drochner #include <sys/cdefs.h>
30 1.1 drochner #if defined(LIBC_SCCS) && !defined(lint)
31 1.1 drochner __RCSID("$NetBSD: insque.c,v 1.1 2005/07/06 14:43:24 drochner Exp $");
32 1.1 drochner #endif /* LIBC_SCCS and not lint */
33 1.1 drochner
34 1.1 drochner #include <assert.h>
35 1.1 drochner #include <search.h>
36 1.1 drochner
37 1.1 drochner struct qelem {
38 1.1 drochner struct qelem *q_forw;
39 1.1 drochner struct qelem *q_back;
40 1.1 drochner };
41 1.1 drochner
42 1.1 drochner void
43 1.1 drochner insque(entry, pred)
44 1.1 drochner void *entry;
45 1.1 drochner void *pred;
46 1.1 drochner {
47 1.1 drochner struct qelem *e = (struct qelem *) entry;
48 1.1 drochner struct qelem *p = (struct qelem *) pred;
49 1.1 drochner
50 1.1 drochner _DIAGASSERT(e != 0);
51 1.1 drochner _DIAGASSERT(p != 0);
52 1.1 drochner
53 1.1 drochner e->q_forw = p->q_forw;
54 1.1 drochner e->q_back = p;
55 1.1 drochner p->q_forw->q_back = e;
56 1.1 drochner p->q_forw = e;
57 1.1 drochner }
58