PERFORCE change 49914 for review

Warner Losh imp at FreeBSD.org
Mon Mar 29 13:22:24 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=49914

Change 49914 by imp at imp_pacopaco on 2004/03/29 13:21:49

	IFC @49911

Affected files ...

.. //depot/projects/power/sys/amd64/amd64/vm_machdep.c#6 integrate
.. //depot/projects/power/sys/contrib/dev/oltr/if_oltr.c#4 integrate
.. //depot/projects/power/sys/i386/i386/vm_machdep.c#7 integrate
.. //depot/projects/power/sys/kern/uipc_domain.c#2 integrate
.. //depot/projects/power/sys/kern/uipc_socket.c#6 integrate
.. //depot/projects/power/sys/net/if_tun.c#7 integrate
.. //depot/projects/power/sys/pc98/pc98/clock.c#5 integrate
.. //depot/projects/power/sys/powerpc/powerpc/vm_machdep.c#5 integrate
.. //depot/projects/power/sys/sys/tree.h#3 integrate

Differences ...

==== //depot/projects/power/sys/amd64/amd64/vm_machdep.c#6 (text+ko) ====

@@ -41,10 +41,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/vm_machdep.c,v 1.230 2004/03/25 03:39:38 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/vm_machdep.c,v 1.231 2004/03/29 19:38:05 peter Exp $");
 
 #include "opt_isa.h"
-#include "opt_kstack_pages.h"
 #include "opt_cpu.h"
 
 #include <sys/param.h>

==== //depot/projects/power/sys/contrib/dev/oltr/if_oltr.c#4 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/contrib/dev/oltr/if_oltr.c,v 1.32 2004/03/17 17:50:23 njl Exp $
+ * $FreeBSD: src/sys/contrib/dev/oltr/if_oltr.c,v 1.33 2004/03/29 21:10:05 imp Exp $
  */
 
 #include <sys/param.h>
@@ -50,11 +50,6 @@
 #include <net/if_media.h>
 #include <net/iso88025.h>
 
-#if (__FreeBSD_version < 400000)
-#include <bpfilter.h>
-#endif
-
-#if (NBPFILTER > 0) || (__FreeBSD_version > 400000)
 #include <net/bpf.h>
 
 #ifndef BPF_MTAP
@@ -63,7 +58,6 @@
 		bpf_mtap((_ifp), (_m));			\
 } while (0)
 #endif
-#endif
 
 #include <vm/vm.h>              /* for vtophys */
 #include <vm/pmap.h>            /* for vtophys */
@@ -238,8 +232,6 @@
 static int oltr_ifmedia_upd	__P((struct ifnet *));
 static void oltr_ifmedia_sts	__P((struct ifnet *, struct ifmediareq *));
 
-#if __FreeBSD_version > 400000
-
 static int oltr_pci_probe		__P((device_t));
 static int oltr_pci_attach	__P((device_t));
 static int oltr_pci_detach	__P((device_t));
@@ -488,200 +480,7 @@
 	return;
 }
 
-#else
-
-static const char *oltr_pci_probe	__P((pcici_t, pcidi_t));
-static void oltr_pci_attach		__P((pcici_t, int));
-
-static unsigned long oltr_count = 0;
-
-static struct pci_device oltr_device = {
-	"oltr",
-	oltr_pci_probe,
-	oltr_pci_attach,
-	&oltr_count,
-	NULL
-};
-
-DATA_SET(pcidevice_set, oltr_device);
-
-static const char *
-oltr_pci_probe(pcici_t config_id, pcidi_t device_id)
-{
-        int                     i, rc;
-        char                    PCIConfigHeader[64];
-        TRlldAdapterConfig_t    config;
-	
-	if (((device_id & 0xffff) == PCI_VENDOR_OLICOM) && (
-	    (((device_id >> 16) & 0xffff) == 0x0001) ||
-	    (((device_id >> 16) & 0xffff) == 0x0004) ||
-	    (((device_id >> 16) & 0xffff) == 0x0005) ||
-	    (((device_id >> 16) & 0xffff) == 0x0007) ||
-	    (((device_id >> 16) & 0xffff) == 0x0008))) {
-	
-		for (i = 0; i < 64; i++)
-			PCIConfigHeader[i] = pci_cfgread(config_id, i, /* bytes */ 1);
-
-		rc = TRlldPCIConfig(&LldDriver, &config, PCIConfigHeader);
-
-		if (rc == TRLLD_PCICONFIG_FAIL) {
-			printf("oltr: TRlldPciConfig failed!\n");
-			return(NULL);
-		}
-		if (rc == TRLLD_PCICONFIG_VERSION) {
-			printf("oltr: wrong LLD version.\n");
-			return(NULL);
-		}
-		return(AdapterName[config.type]);
-	}
-
-	return(NULL);
-}
-
 static void
-oltr_pci_attach(pcici_t config_id, int unit)
-{
-        int 			i, s, rc = 0, scratch_size;
-	int			media = IFM_TOKEN|IFM_TOK_UTP16;
-	u_long 			command;
-	char 			PCIConfigHeader[64];
-	struct oltr_softc		*sc;
-	struct ifnet		*ifp; /* = &sc->arpcom.ac_if; */
-
-        s = splimp();
-
-	sc = malloc(sizeof(struct oltr_softc), M_DEVBUF, M_NOWAIT | M_ZERO);
-	if (sc == NULL) {
-		printf("oltr%d: no memory for softc struct!\n", unit);
-		goto config_failed;
-	}
-	sc->unit = unit;
-	sc->state = OL_UNKNOWN;
-	ifp = &sc->arpcom.ac_if;
-
-	for (i = 0; i < sizeof(PCIConfigHeader); i++)
-		PCIConfigHeader[i] = pci_cfgread(config_id, i, 1);
-
-	switch(TRlldPCIConfig(&LldDriver, &sc->config, PCIConfigHeader)) {
-	case TRLLD_PCICONFIG_OK:
-		break;
-	case TRLLD_PCICONFIG_SET_COMMAND:
-		printf("oltr%d: enabling bus master mode\n", unit);
-		command = pci_conf_read(config_id, PCIR_COMMAND);
-		pci_conf_write(config_id, PCIR_COMMAND, (command | PCIM_CMD_BUSMASTEREN));
-		command = pci_conf_read(config_id, PCIR_COMMAND);
-		if (!(command & PCIM_CMD_BUSMASTEREN)) {
-			printf("oltr%d: failed to enable bus master mode\n", unit);
-			goto config_failed;
-		}
-		break;
-	case TRLLD_PCICONFIG_FAIL:
-		printf("oltr%d: TRlldPciConfig failed!\n", unit);
-		goto config_failed;
-		break;
-	case TRLLD_PCICONFIG_VERSION:
-		printf("oltr%d: wrong LLD version\n", unit);
-		goto config_failed;
-		break;
-	}
-	printf("oltr%d: MAC address %6D\n", unit, sc->config.macaddress, ":");
-
-	scratch_size = TRlldAdapterSize();
-	if (bootverbose)
-		printf("oltr%d: adapter memory block size %d bytes\n", unit, scratch_size);
-	sc->TRlldAdapter = (TRlldAdapter_t)malloc(scratch_size, M_DEVBUF, M_NOWAIT);
-	if (sc->TRlldAdapter == NULL) {
-		printf("oltr%d: couldn't allocate scratch buffer (%d bytes)\n",unit, scratch_size);
-		goto config_failed;
-	}
-
-	/*
-	 * Allocate RX/TX Pools
-	 */
-	for (i = 0; i < RING_BUFFER_LEN; i++) {
-		sc->rx_ring[i].index = i;
-		sc->rx_ring[i].data = (char *)malloc(RX_BUFFER_LEN, M_DEVBUF, M_NOWAIT);
-		sc->rx_ring[i].address = vtophys(sc->rx_ring[i].data);
-		sc->tx_ring[i].index = i;
-		sc->tx_ring[i].data = (char *)malloc(TX_BUFFER_LEN, M_DEVBUF, M_NOWAIT);
-		sc->tx_ring[i].address = vtophys(sc->tx_ring[i].data);
-		if ((!sc->rx_ring[i].data) || (!sc->tx_ring[i].data)) {
-			printf("oltr%d: unable to allocate ring buffers\n", unit);
-			while (i > 0) {
-				if (sc->rx_ring[i].data)
-					free(sc->rx_ring[i].data, M_DEVBUF);
-				if (sc->tx_ring[i].data)
-					free(sc->tx_ring[i].data, M_DEVBUF);
-				i--;
-			}
-			goto config_failed;
-		}
-	}
-	
-	/*
-	 * Allocate interrupt and DMA channel
-	 */
-	if (!pci_map_int(config_id, oltr_intr, sc, &net_imask)) {
-		printf("oltr%d: couldn't setup interrupt\n", unit);
-		goto config_failed;
-	}
-
-	/*
-	 * Do the ifnet initialization
-	 */
-	ifp->if_softc	= sc;
-	ifp->if_unit	= unit;
-	ifp->if_name	= "oltr";
-	ifp->if_output	= iso88025_output;
-	ifp->if_init	= oltr_init;
-	ifp->if_start	= oltr_start;
-	ifp->if_ioctl	= oltr_ioctl;
-	ifp->if_flags	= IFF_BROADCAST;
-	bcopy(sc->config.macaddress, sc->arpcom.ac_enaddr, sizeof(sc->config.macaddress));
-
-	/*
-	 * Do ifmedia setup.
-	 */
-	ifmedia_init(&sc->ifmedia, 0, oltr_ifmedia_upd, oltr_ifmedia_sts);
-	rc = TRlldSetSpeed(sc->TRlldAdapter, TRLLD_SPEED_16MBPS);
-	switch(sc->config.type) {
-	case TRLLD_ADAPTER_PCI7:	/* OC-3540 */
-		ifmedia_add(&sc->ifmedia, IFM_TOKEN|IFM_TOK_UTP100, 0, NULL);
-		/* FALL THROUGH */
-	case TRLLD_ADAPTER_PCI4:	/* OC-3139 */
-	case TRLLD_ADAPTER_PCI5:	/* OC-3140 */
-	case TRLLD_ADAPTER_PCI6:	/* OC-3141 */
-		ifmedia_add(&sc->ifmedia, IFM_TOKEN|IFM_AUTO, 0, NULL);
-		media = IFM_TOKEN|IFM_AUTO;
-		rc = TRlldSetSpeed(sc->TRlldAdapter, 0);
-		/* FALL THROUGH */
-	default:
-		ifmedia_add(&sc->ifmedia, IFM_TOKEN|IFM_TOK_UTP4, 0, NULL);
-		ifmedia_add(&sc->ifmedia, IFM_TOKEN|IFM_TOK_UTP16, 0, NULL);
-		break;
-	}
-	sc->ifmedia.ifm_media = media;
-	ifmedia_set(&sc->ifmedia, media);
-
-	/*
-	 * Attach the interface
-	 */
-	if_attach(ifp);
-	ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
-	iso88025_ifattach(ifp);
-
-	splx(s);
-	return;
-
-config_failed:
-        (void)splx(s);
-
-	return;
-}
-
-#endif
-
-static void
 oltr_intr(void *xsc)
 {
 	struct oltr_softc		*sc = (struct oltr_softc *)xsc;
@@ -761,9 +560,7 @@
 	sc->tx_head = RING_BUFFER((sc->tx_head + sc->frame_ring[frame].FragmentCount));
 	sc->tx_frame++;
 
-#if (NBPFILTER > 0) || (__FreeBSD_version > 400000)
 	BPF_MTAP(ifp, m0);
-#endif
 	/*ifp->if_opackets++;*/
 
 bad:

==== //depot/projects/power/sys/i386/i386/vm_machdep.c#7 (text+ko) ====

@@ -41,10 +41,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.233 2004/03/22 00:28:38 wpaul Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.234 2004/03/29 19:38:05 peter Exp $");
 
 #include "opt_isa.h"
-#include "opt_kstack_pages.h"
 #include "opt_npx.h"
 #ifdef PC98
 #include "opt_pc98.h"

==== //depot/projects/power/sys/kern/uipc_domain.c#2 (text+ko) ====

@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/uipc_domain.c,v 1.34 2003/09/02 20:59:23 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/uipc_domain.c,v 1.35 2004/03/29 17:00:05 rwatson Exp $");
 
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -134,8 +134,13 @@
 	if (max_linkhdr < 16)		/* XXX */
 		max_linkhdr = 16;
 
-	callout_init(&pffast_callout, 0);
-	callout_init(&pfslow_callout, 0);
+	if (debug_mpsafenet) {
+		callout_init(&pffast_callout, CALLOUT_MPSAFE);
+		callout_init(&pfslow_callout, CALLOUT_MPSAFE);
+	} else {
+		callout_init(&pffast_callout, 0);
+		callout_init(&pfslow_callout, 0);
+	}
 
 	callout_reset(&pffast_callout, 1, pffasttimo, NULL);
 	callout_reset(&pfslow_callout, 1, pfslowtimo, NULL);
@@ -236,6 +241,8 @@
 	register struct domain *dp;
 	register struct protosw *pr;
 
+	NET_ASSERT_GIANT();
+
 	for (dp = domains; dp; dp = dp->dom_next)
 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
 			if (pr->pr_slowtimo)
@@ -250,6 +257,8 @@
 	register struct domain *dp;
 	register struct protosw *pr;
 
+	NET_ASSERT_GIANT();
+
 	for (dp = domains; dp; dp = dp->dom_next)
 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
 			if (pr->pr_fasttimo)

==== //depot/projects/power/sys/kern/uipc_socket.c#6 (text+ko) ====

@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.165 2004/03/01 03:14:21 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.167 2004/03/29 18:06:15 rwatson Exp $");
 
 #include "opt_inet.h"
 #include "opt_mac.h"
@@ -283,14 +283,14 @@
 sofree(so)
 	struct socket *so;
 {
-	struct socket *head = so->so_head;
 	int s;
 
 	KASSERT(so->so_count == 0, ("socket %p so_count not 0", so));
 
 	if (so->so_pcb || (so->so_state & SS_NOFDREF) == 0)
 		return;
-	if (head != NULL) {
+	if (so->so_head != NULL) {
+		struct socket *head = so->so_head;
 		if (so->so_state & SS_INCOMP) {
 			TAILQ_REMOVE(&head->so_incomp, so, so_list);
 			head->so_incqlen--;
@@ -1845,18 +1845,20 @@
 filt_soread(struct knote *kn, long hint)
 {
 	struct socket *so = kn->kn_fp->f_data;
+	int result;
 
 	kn->kn_data = so->so_rcv.sb_cc - so->so_rcv.sb_ctl;
 	if (so->so_state & SS_CANTRCVMORE) {
 		kn->kn_flags |= EV_EOF;
 		kn->kn_fflags = so->so_error;
-		return (1);
-	}
-	if (so->so_error)	/* temporary udp error */
-		return (1);
-	if (kn->kn_sfflags & NOTE_LOWAT)
-		return (kn->kn_data >= kn->kn_sdata);
-	return (so->so_rcv.sb_cc >= so->so_rcv.sb_lowat);
+		result = 1;
+	} else if (so->so_error)	/* temporary udp error */
+		result = 1;
+	else if (kn->kn_sfflags & NOTE_LOWAT)
+		result = (kn->kn_data >= kn->kn_sdata);
+	else
+		result = (so->so_rcv.sb_cc >= so->so_rcv.sb_lowat);
+	return (result);
 }
 
 static void
@@ -1876,21 +1878,23 @@
 filt_sowrite(struct knote *kn, long hint)
 {
 	struct socket *so = kn->kn_fp->f_data;
+	int result;
 
 	kn->kn_data = sbspace(&so->so_snd);
 	if (so->so_state & SS_CANTSENDMORE) {
 		kn->kn_flags |= EV_EOF;
 		kn->kn_fflags = so->so_error;
-		return (1);
-	}
-	if (so->so_error)	/* temporary udp error */
-		return (1);
-	if (((so->so_state & SS_ISCONNECTED) == 0) &&
+		result = 1;
+	} else if (so->so_error)	/* temporary udp error */
+		result = 1;
+	else if (((so->so_state & SS_ISCONNECTED) == 0) &&
 	    (so->so_proto->pr_flags & PR_CONNREQUIRED))
-		return (0);
-	if (kn->kn_sfflags & NOTE_LOWAT)
-		return (kn->kn_data >= kn->kn_sdata);
-	return (kn->kn_data >= so->so_snd.sb_lowat);
+		result = 0;
+	else if (kn->kn_sfflags & NOTE_LOWAT)
+		result = (kn->kn_data >= kn->kn_sdata);
+	else
+		result = (kn->kn_data >= so->so_snd.sb_lowat);
+	return (result);
 }
 
 /*ARGSUSED*/

==== //depot/projects/power/sys/net/if_tun.c#7 (text+ko) ====

@@ -13,7 +13,7 @@
  * UCL. This driver is based much more on read/write/poll mode of
  * operation though.
  *
- * $FreeBSD: src/sys/net/if_tun.c,v 1.137 2004/03/17 01:12:09 rwatson Exp $
+ * $FreeBSD: src/sys/net/if_tun.c,v 1.138 2004/03/29 18:42:51 rwatson Exp $
  */
 
 #include "opt_atalk.h"
@@ -87,6 +87,12 @@
 #define TUNDEBUG	if (tundebug) if_printf
 #define	TUNNAME		"tun"
 
+/*
+ * All mutable global variables in if_tun are locked using tunmtx, with
+ * the exception of tundebug, which is used unlocked, and tunclones,
+ * which is static after setup.
+ */
+static struct mtx tunmtx;
 static MALLOC_DEFINE(M_TUN, TUNNAME, "Tunnel Interface");
 static int tundebug = 0;
 static struct clonedevs *tunclones;
@@ -147,15 +153,30 @@
 	}
 }
 
+static void
+tun_destroy(struct tun_softc *tp)
+{
+	dev_t dev;
+
+	KASSERT((tp->tun_flags & TUN_OPEN) == 0,
+	    ("tununits is out of sync - unit %d", tp->tun_if.if_dunit));
+
+	dev = tp->tun_dev;
+	bpfdetach(&tp->tun_if);
+	if_detach(&tp->tun_if);
+	destroy_dev(dev);
+	free(tp, M_TUN);
+}
+
 static int
 tunmodevent(module_t mod, int type, void *data)
 {
 	static eventhandler_tag tag;
 	struct tun_softc *tp;
-	dev_t dev;
 
 	switch (type) {
 	case MOD_LOAD:
+		mtx_init(&tunmtx, "tunmtx", NULL, MTX_DEF);
 		clone_setup(&tunclones);
 		tag = EVENTHANDLER_REGISTER(dev_clone, tunclone, 0, 1000);
 		if (tag == NULL)
@@ -164,19 +185,16 @@
 	case MOD_UNLOAD:
 		EVENTHANDLER_DEREGISTER(dev_clone, tag);
 
-		while (!TAILQ_EMPTY(&tunhead)) {
-			tp = TAILQ_FIRST(&tunhead);
-			KASSERT((tp->tun_flags & TUN_OPEN) == 0,
-			    ("tununits is out of sync - unit %d",
-			    tp->tun_if.if_dunit));
+		mtx_lock(&tunmtx);
+		while ((tp = TAILQ_FIRST(&tunhead)) != NULL) {
 			TAILQ_REMOVE(&tunhead, tp, tun_list);
-			dev = tp->tun_dev;
-			bpfdetach(&tp->tun_if);
-			if_detach(&tp->tun_if);
-			destroy_dev(dev);
-			free(tp, M_TUN);
+			mtx_unlock(&tunmtx);
+			tun_destroy(tp);
+			mtx_lock(&tunmtx);
 		}
+		mtx_unlock(&tunmtx);
 		clone_cleanup(&tunclones);
+		mtx_destroy(&tunmtx);
 		break;
 	}
 	return 0;
@@ -215,7 +233,9 @@
 	MALLOC(sc, struct tun_softc *, sizeof(*sc), M_TUN, M_WAITOK | M_ZERO);
 	sc->tun_flags = TUN_INITED;
 	sc->tun_dev = dev;
+	mtx_lock(&tunmtx);
 	TAILQ_INSERT_TAIL(&tunhead, sc, tun_list);
+	mtx_unlock(&tunmtx);
 
 	ifp = &sc->tun_if;
 	if_initname(ifp, TUNNAME, dev2unit(dev));

==== //depot/projects/power/sys/pc98/pc98/clock.c#5 (text+ko) ====

@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)clock.c	7.2 (Berkeley) 5/12/91
- * $FreeBSD: src/sys/pc98/pc98/clock.c,v 1.135 2004/03/15 10:39:01 imp Exp $
+ * $FreeBSD: src/sys/pc98/pc98/clock.c,v 1.136 2004/03/29 12:51:46 nyan Exp $
  */
 
 /*
@@ -593,7 +593,7 @@
 		else
 			tot_count += prev_count - count;
 		prev_count = count;
-		if ((sec == start_sec + 1200) ||
+		if ((sec == start_sec + 1200) || /* 1200 = 307.2KHz >> 8 */
 		    (sec < start_sec &&
 		        (u_int)sec + 0x10000 == (u_int)start_sec + 1200))
 			break;

==== //depot/projects/power/sys/powerpc/powerpc/vm_machdep.c#5 (text+ko) ====

@@ -38,7 +38,7 @@
  *
  *	from: @(#)vm_machdep.c	7.3 (Berkeley) 5/13/91
  *	Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $FreeBSD: src/sys/powerpc/powerpc/vm_machdep.c,v 1.98 2004/03/16 19:04:28 alc Exp $
+ * $FreeBSD: src/sys/powerpc/powerpc/vm_machdep.c,v 1.99 2004/03/29 19:38:05 peter Exp $
  */
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -67,8 +67,6 @@
  * rights to redistribute these changes.
  */
 
-#include "opt_kstack_pages.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
@@ -139,8 +137,8 @@
 
 	p1 = td1->td_proc;
 
-	pcb = (struct pcb *)((td2->td_kstack + KSTACK_PAGES * PAGE_SIZE -
-	    sizeof(struct pcb)) & ~0x2fU);
+	pcb = (struct pcb *)((td2->td_kstack +
+	    td2->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb)) & ~0x2fU);
 	td2->td_pcb = pcb;
 
 	/* Copy the pcb */
@@ -357,7 +355,7 @@
 {
 	struct pcb *pcb;
 
-	pcb = (struct pcb *)((td->td_kstack + KSTACK_PAGES * PAGE_SIZE -
+	pcb = (struct pcb *)((td->td_kstack + td2->td_kstack_pages * PAGE_SIZE -
 	    sizeof(struct pcb)) & ~0x2fU);
 	td->td_pcb = pcb;
 	td->td_frame = (struct trapframe *)pcb - 1;

==== //depot/projects/power/sys/sys/tree.h#3 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.h,v 1.7 2004/01/24 21:59:47 dbj Exp $	*/
+/*	$NetBSD: tree.h,v 1.8 2004/03/28 19:38:30 provos Exp $	*/
 /*	$OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $	*/
 /*
  * Copyright 2002 Niels Provos <provos at citi.umich.edu>
@@ -380,7 +380,7 @@
 struct type *name##_RB_REMOVE(struct name *, struct type *);		\
 struct type *name##_RB_INSERT(struct name *, struct type *);		\
 struct type *name##_RB_FIND(struct name *, struct type *);		\
-struct type *name##_RB_NEXT(struct name *, struct type *);		\
+struct type *name##_RB_NEXT(struct type *);				\
 struct type *name##_RB_MINMAX(struct name *, int);			\
 									\
 
@@ -628,7 +628,7 @@
 									\
 /* ARGSUSED */								\
 struct type *								\
-name##_RB_NEXT(struct name *head, struct type *elm)			\
+name##_RB_NEXT(struct type *elm)					\
 {									\
 	if (RB_RIGHT(elm, field)) {					\
 		elm = RB_RIGHT(elm, field);				\
@@ -669,13 +669,13 @@
 #define RB_INSERT(name, x, y)	name##_RB_INSERT(x, y)
 #define RB_REMOVE(name, x, y)	name##_RB_REMOVE(x, y)
 #define RB_FIND(name, x, y)	name##_RB_FIND(x, y)
-#define RB_NEXT(name, x, y)	name##_RB_NEXT(x, y)
+#define RB_NEXT(name, x, y)	name##_RB_NEXT(y)
 #define RB_MIN(name, x)		name##_RB_MINMAX(x, RB_NEGINF)
 #define RB_MAX(name, x)		name##_RB_MINMAX(x, RB_INF)
 
 #define RB_FOREACH(x, name, head)					\
 	for ((x) = RB_MIN(name, head);					\
 	     (x) != NULL;						\
-	     (x) = name##_RB_NEXT(head, x))
+	     (x) = name##_RB_NEXT(x))
 
 #endif	/* _SYS_TREE_H_ */


More information about the p4-projects mailing list