From c495131fe3002fa9a2fd68890902946faa1268b8 Mon Sep 17 00:00:00 2001 From: jdolecek Date: Sun, 12 Aug 2001 08:35:31 +0000 Subject: [PATCH] Move _insque()/_remque() to libkern. Once remaining uses would be converted to macros, _insque()/_remque() would be eliminated altogether. --- sys/arch/alpha/alpha/support.c | 64 ------------------------ sys/arch/alpha/conf/files.alpha | 3 +- sys/arch/arm/arm32/stubs.c | 45 +---------------- sys/arch/hpcarm/hpcarm/stubs.c | 45 +---------------- sys/arch/i386/i386/machdep.c | 41 +--------------- sys/arch/pc532/pc532/machdep.c | 41 +--------------- sys/arch/sh3/sh3/sh3_machdep.c | 40 +-------------- sys/arch/x86_64/x86_64/machdep.c | 41 +--------------- sys/lib/libkern/Makefile | 3 +- sys/lib/libkern/_que.c | 84 ++++++++++++++++++++++++++++++++ 10 files changed, 93 insertions(+), 314 deletions(-) delete mode 100644 sys/arch/alpha/alpha/support.c create mode 100644 sys/lib/libkern/_que.c diff --git a/sys/arch/alpha/alpha/support.c b/sys/arch/alpha/alpha/support.c deleted file mode 100644 index ebb2543116a4..000000000000 --- a/sys/arch/alpha/alpha/support.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: support.c,v 1.8 2001/01/03 22:15:38 thorpej Exp $ */ - -/* - * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include /* RCS ID & Copyright macro defns */ - -__KERNEL_RCSID(0, "$NetBSD: support.c,v 1.8 2001/01/03 22:15:38 thorpej Exp $"); - -/* - * Some C support functions that aren't (yet) in libkern or assembly. - */ -#include -#include -#include - -struct qelem { - struct qelem *q_forw; - struct qelem *q_back; -}; - -void -_insque(void *entry, void *pred) -{ - struct qelem *e = (struct qelem *) entry; - struct qelem *p = (struct qelem *) pred; - - e->q_forw = p->q_forw; - e->q_back = p; - p->q_forw->q_back = e; - p->q_forw = e; -} - -void -_remque(void *element) -{ - struct qelem *e = (struct qelem *) element; - e->q_forw->q_back = e->q_back; - e->q_back->q_forw = e->q_forw; -} diff --git a/sys/arch/alpha/conf/files.alpha b/sys/arch/alpha/conf/files.alpha index 8e93afce4268..643d2d5246e8 100644 --- a/sys/arch/alpha/conf/files.alpha +++ b/sys/arch/alpha/conf/files.alpha @@ -1,4 +1,4 @@ -# $NetBSD: files.alpha,v 1.140 2001/06/18 02:00:48 christos Exp $ +# $NetBSD: files.alpha,v 1.141 2001/08/12 08:35:32 jdolecek Exp $ # # alpha-specific configuration info @@ -492,7 +492,6 @@ file arch/alpha/alpha/pmap.c file arch/alpha/alpha/process_machdep.c file arch/alpha/alpha/procfs_machdep.c procfs file arch/alpha/alpha/prom.c -file arch/alpha/alpha/support.c file arch/alpha/alpha/sys_machdep.c file arch/alpha/alpha/syscall.c file arch/alpha/alpha/trap.c diff --git a/sys/arch/arm/arm32/stubs.c b/sys/arch/arm/arm32/stubs.c index 199ba827da8c..e963bdfe7445 100644 --- a/sys/arch/arm/arm32/stubs.c +++ b/sys/arch/arm/arm32/stubs.c @@ -1,4 +1,4 @@ -/* $NetBSD: stubs.c,v 1.1 2001/07/28 13:28:04 chris Exp $ */ +/* $NetBSD: stubs.c,v 1.2 2001/08/12 08:35:33 jdolecek Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -55,49 +55,6 @@ extern dev_t dumpdev; extern BootConfig bootconfig; -/* These queue functions are candiates for arm32/machdep.c */ -struct queue { - struct queue *q_next, *q_prev; -}; - -/* - * insert an element into a queue - */ - -void -_insque(v1, v2) - void *v1; - void *v2; -{ - struct queue *elem = v1, *head = v2; - struct queue *next; - - next = head->q_next; - elem->q_next = next; - head->q_next = elem; - elem->q_prev = head; - next->q_prev = elem; -} - -/* - * remove an element from a queue - */ - -void -_remque(v) - void *v; -{ - struct queue *elem = v; - struct queue *next, *prev; - - next = elem->q_next; - prev = elem->q_prev; - next->q_prev = prev; - prev->q_next = next; - elem->q_prev = 0; -} - - /* * These variables are needed by /sbin/savecore */ diff --git a/sys/arch/hpcarm/hpcarm/stubs.c b/sys/arch/hpcarm/hpcarm/stubs.c index 7aec0c0b7ca5..7b07129fff8b 100644 --- a/sys/arch/hpcarm/hpcarm/stubs.c +++ b/sys/arch/hpcarm/hpcarm/stubs.c @@ -1,4 +1,4 @@ -/* $NetBSD: stubs.c,v 1.6 2001/06/29 02:40:28 toshii Exp $ */ +/* $NetBSD: stubs.c,v 1.7 2001/08/12 08:35:32 jdolecek Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -55,49 +55,6 @@ extern dev_t dumpdev; extern BootConfig bootconfig; -/* These queue functions are candiates for arm32/machdep.c */ -struct queue { - struct queue *q_next, *q_prev; -}; - -/* - * insert an element into a queue - */ - -void -_insque(v1, v2) - void *v1; - void *v2; -{ - struct queue *elem = v1, *head = v2; - struct queue *next; - - next = head->q_next; - elem->q_next = next; - head->q_next = elem; - elem->q_prev = head; - next->q_prev = elem; -} - -/* - * remove an element from a queue - */ - -void -_remque(v) - void *v; -{ - struct queue *elem = v; - struct queue *next, *prev; - - next = elem->q_next; - prev = elem->q_prev; - next->q_prev = prev; - prev->q_next = next; - elem->q_prev = 0; -} - - /* * These variables are needed by /sbin/savecore */ diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index cc6588c274fc..490dab017b80 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.452 2001/08/03 01:24:40 thorpej Exp $ */ +/* $NetBSD: machdep.c,v 1.453 2001/08/12 08:35:31 jdolecek Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc. @@ -2833,45 +2833,6 @@ init386(first_avail) identifycpu(curcpu()); } -struct queue { - struct queue *q_next, *q_prev; -}; - -/* - * insert an element into a queue - */ -void -_insque(v1, v2) - void *v1; - void *v2; -{ - struct queue *elem = v1, *head = v2; - struct queue *next; - - next = head->q_next; - elem->q_next = next; - head->q_next = elem; - elem->q_prev = head; - next->q_prev = elem; -} - -/* - * remove an element from a queue - */ -void -_remque(v) - void *v; -{ - struct queue *elem = v; - struct queue *next, *prev; - - next = elem->q_next; - prev = elem->q_prev; - next->q_prev = prev; - prev->q_next = next; - elem->q_prev = 0; -} - #ifdef COMPAT_NOMID static int exec_nomid(p, epp) diff --git a/sys/arch/pc532/pc532/machdep.c b/sys/arch/pc532/pc532/machdep.c index d8551c7b9e24..69b36f294ef1 100644 --- a/sys/arch/pc532/pc532/machdep.c +++ b/sys/arch/pc532/pc532/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.123 2001/06/02 18:09:18 chs Exp $ */ +/* $NetBSD: machdep.c,v 1.124 2001/08/12 08:35:33 jdolecek Exp $ */ /*- * Copyright (c) 1996 Matthias Pfaller. @@ -1019,45 +1019,6 @@ init532() panic("main returned to init532\n"); } -struct queue { - struct queue *q_next, *q_prev; -}; - -/* - * insert an element into a queue - */ -void -_insque(v1, v2) - void *v1; - void *v2; -{ - register struct queue *elem = v1, *head = v2; - register struct queue *next; - - next = head->q_next; - elem->q_next = next; - head->q_next = elem; - elem->q_prev = head; - next->q_prev = elem; -} - -/* - * remove an element from a queue - */ -void -_remque(v) - void *v; -{ - register struct queue *elem = v; - register struct queue *next, *prev; - - next = elem->q_next; - prev = elem->q_prev; - next->q_prev = prev; - prev->q_next = next; - elem->q_prev = 0; -} - /* * cpu_exec_aout_makecmds(): * cpu-dependent a.out format hook for execve(). diff --git a/sys/arch/sh3/sh3/sh3_machdep.c b/sys/arch/sh3/sh3/sh3_machdep.c index 9dd141d017bc..252adb1bd759 100644 --- a/sys/arch/sh3/sh3/sh3_machdep.c +++ b/sys/arch/sh3/sh3/sh3_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: sh3_machdep.c,v 1.15 2001/06/02 18:09:20 chs Exp $ */ +/* $NetBSD: sh3_machdep.c,v 1.16 2001/08/12 08:35:33 jdolecek Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -428,41 +428,3 @@ setregs(p, pack, stack) #endif } -struct queue { - struct queue *q_next, *q_prev; -}; - -/* - * insert an element into a queue - */ -void -_insque(v1, v2) - void *v1; - void *v2; -{ - struct queue *elem = v1, *head = v2; - struct queue *next; - - next = head->q_next; - elem->q_next = next; - head->q_next = elem; - elem->q_prev = head; - next->q_prev = elem; -} - -/* - * remove an element from a queue - */ -void -_remque(v) - void *v; -{ - struct queue *elem = v; - struct queue *next, *prev; - - next = elem->q_next; - prev = elem->q_prev; - next->q_prev = prev; - prev->q_next = next; - elem->q_prev = 0; -} diff --git a/sys/arch/x86_64/x86_64/machdep.c b/sys/arch/x86_64/x86_64/machdep.c index 2f6afeae3844..56ed0814b8e0 100644 --- a/sys/arch/x86_64/x86_64/machdep.c +++ b/sys/arch/x86_64/x86_64/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.1 2001/06/19 00:21:17 fvdl Exp $ */ +/* $NetBSD: machdep.c,v 1.2 2001/08/12 08:35:33 jdolecek Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc. @@ -1560,45 +1560,6 @@ init_x86_64(first_avail) enable_intr(); } -struct queue { - struct queue *q_next, *q_prev; -}; - -/* - * insert an element into a queue - */ -void -_insque(v1, v2) - void *v1; - void *v2; -{ - struct queue *elem = v1, *head = v2; - struct queue *next; - - next = head->q_next; - elem->q_next = next; - head->q_next = elem; - elem->q_prev = head; - next->q_prev = elem; -} - -/* - * remove an element from a queue - */ -void -_remque(v) - void *v; -{ - struct queue *elem = v; - struct queue *next, *prev; - - next = elem->q_next; - prev = elem->q_prev; - next->q_prev = prev; - prev->q_next = next; - elem->q_prev = 0; -} - void * lookup_bootinfo(type) int type; diff --git a/sys/lib/libkern/Makefile b/sys/lib/libkern/Makefile index 34be9472d48c..391a646f3b6d 100644 --- a/sys/lib/libkern/Makefile +++ b/sys/lib/libkern/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.60 2001/02/18 22:38:50 enami Exp $ +# $NetBSD: Makefile,v 1.61 2001/08/12 08:35:34 jdolecek Exp $ LIB= kern MKPIC= no @@ -37,6 +37,7 @@ SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \ # Other stuff SRCS+= __cmsg_alignbytes.c inet_addr.c intoa.c md4c.c md5c.c sha1.c pmatch.c +SRCS+= _que.c # Files to clean up CLEANFILES+= lib${LIB}.o lib${LIB}.po diff --git a/sys/lib/libkern/_que.c b/sys/lib/libkern/_que.c new file mode 100644 index 000000000000..5b92085faf53 --- /dev/null +++ b/sys/lib/libkern/_que.c @@ -0,0 +1,84 @@ +/* $NetBSD: _que.c,v 1.1 2001/08/12 08:35:34 jdolecek Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS 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 FOUNDATION OR 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. + */ + +/* + * Use macros for new code, queue functions provided here + * are obsolete. Once the remaining code using this would be converted + * to use , this would be removed. + */ + +#include +#include + +struct queue { + struct queue *q_next, *q_prev; +}; + +/* + * insert an element into a queue + */ + +void +_insque(v1, v2) + void *v1; + void *v2; +{ + struct queue *elem = v1, *head = v2; + struct queue *next; + + next = head->q_next; + elem->q_next = next; + head->q_next = elem; + elem->q_prev = head; + next->q_prev = elem; +} + +/* + * remove an element from a queue + */ + +void +_remque(v) + void *v; +{ + struct queue *elem = v; + struct queue *next, *prev; + + next = elem->q_next; + prev = elem->q_prev; + next->q_prev = prev; + prev->q_next = next; + elem->q_prev = 0; +}