CVS commit: src/sys/arch/arm/pic

2012-07-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul  7 08:05:48 UTC 2012

Modified Files:
src/sys/arch/arm/pic: pic.c

Log Message:
Convert a KASSERT to a KASSERTMSG


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/pic/pic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.9 src/sys/arch/arm/pic/pic.c:1.10
--- src/sys/arch/arm/pic/pic.c:1.9	Wed Jul  4 13:34:24 2012
+++ src/sys/arch/arm/pic/pic.c	Sat Jul  7 08:05:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.9 2012/07/04 13:34:24 skrll Exp $	*/
+/*	$NetBSD: pic.c,v 1.10 2012/07/07 08:05:48 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.9 2012/07/04 13:34:24 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: pic.c,v 1.10 2012/07/07 08:05:48 skrll Exp $);
 
 #define _INTR_PRIVATE
 #include sys/param.h
@@ -159,7 +159,8 @@ pic_find_pending_irqs_by_ipl(struct pic_
 
 		irq_mask = __BIT(irq);
 #if 1
-		KASSERT(pic-pic_sources[irq_base + irq] != NULL);
+		KASSERTMSG(pic-pic_sources[irq_base + irq] != NULL,
+		   %s: irq_base %zu irq %d\n, __func__, irq_base, irq);
 #else
 		if (pic-pic_sources[irq_base + irq] == NULL) {
 			aprint_error(stray interrupt? irq_base=%zu irq=%d\n,



CVS commit: src/sys/arch/evbppc/mpc85xx

2012-07-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul  7 08:06:51 UTC 2012

Modified Files:
src/sys/arch/evbppc/mpc85xx: machdep.c

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/evbppc/mpc85xx/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbppc/mpc85xx/machdep.c
diff -u src/sys/arch/evbppc/mpc85xx/machdep.c:1.23 src/sys/arch/evbppc/mpc85xx/machdep.c:1.24
--- src/sys/arch/evbppc/mpc85xx/machdep.c:1.23	Thu Mar 29 15:49:08 2012
+++ src/sys/arch/evbppc/mpc85xx/machdep.c	Sat Jul  7 08:06:51 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.23 2012/03/29 15:49:08 matt Exp $	*/
+/*	$NetBSD: machdep.c,v 1.24 2012/07/07 08:06:51 skrll Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -1152,7 +1152,7 @@ initppc(vaddr_t startkernel, vaddr_t end
 	cpu_md_ops.md_cpunode_attach = pq3gpio_attach;
 #endif
 
-		printf( initppc done!\n);
+	printf( initppc done!\n);
 
 	/*
 	 * Look for the Book-E modules in the right place.



CVS commit: src/sys/kern

2012-07-07 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Jul  7 16:10:23 UTC 2012

Modified Files:
src/sys/kern: subr_disk_open.c

Log Message:
Check if secsize and numsec returned from ioctl's are sane values
and add DIAGNOSTIC messages in getdisksize().

Discussed on source-changes-d@:
http://mail-index.NetBSD.org/source-changes-d/2012/07/02/msg004989.html
and patch is reviwed by christos@ and pgoyette@.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/kern/subr_disk_open.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_disk_open.c
diff -u src/sys/kern/subr_disk_open.c:1.8 src/sys/kern/subr_disk_open.c:1.9
--- src/sys/kern/subr_disk_open.c:1.8	Fri Apr 27 18:15:55 2012
+++ src/sys/kern/subr_disk_open.c	Sat Jul  7 16:10:23 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_disk_open.c,v 1.8 2012/04/27 18:15:55 drochner Exp $	*/
+/*	$NetBSD: subr_disk_open.c,v 1.9 2012/07/07 16:10:23 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: subr_disk_open.c,v 1.8 2012/04/27 18:15:55 drochner Exp $);
+__KERNEL_RCSID(0, $NetBSD: subr_disk_open.c,v 1.9 2012/07/07 16:10:23 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/conf.h
@@ -94,23 +94,41 @@ getdisksize(struct vnode *vp, uint64_t *
 	struct partinfo dpart;
 	struct dkwedge_info dkw;
 	struct disk *pdk;
+	unsigned int secsize;
+	uint64_t numsec;
 	int error;
 
 	error = VOP_IOCTL(vp, DIOCGPART, dpart, FREAD, NOCRED);
 	if (error == 0) {
-		*secsizep = dpart.disklab-d_secsize;
-		*numsecp  = dpart.part-p_size;
-		return 0;
+		secsize = dpart.disklab-d_secsize;
+		numsec  = dpart.part-p_size;
+	} else {
+		error = VOP_IOCTL(vp, DIOCGWEDGEINFO, dkw, FREAD, NOCRED);
+		if (error == 0) {
+			pdk = disk_find(dkw.dkw_parent);
+			if (pdk != NULL) {
+secsize = DEV_BSIZE  pdk-dk_blkshift;
+numsec  = dkw.dkw_size;
+			} else
+error = ENODEV;
+		}
 	}
 
-	error = VOP_IOCTL(vp, DIOCGWEDGEINFO, dkw, FREAD, NOCRED);
+	if (error == 0 
+	(secsize == 0 || secsize  MAXBSIZE || !powerof2(secsize) ||
+	 numsec == 0)) {
+#ifdef DIAGNOSTIC
+		printf(%s: %s returns invalid disksize values
+		 (secsize = %u, numsec = % PRIu64 )\n,
+		__func__,
+		devsw_blk2name(major(vp-v_specnode-sn_rdev)),
+		secsize, numsec);
+#endif
+		error = EINVAL;
+	}
 	if (error == 0) {
-		pdk = disk_find(dkw.dkw_parent);
-		if (pdk != NULL) {
-			*secsizep = DEV_BSIZE  pdk-dk_blkshift;
-			*numsecp  = dkw.dkw_size;
-		} else
-			error = ENODEV;
+		*secsizep = secsize;
+		*numsecp  = numsec;
 	}
 
 	return error;



CVS commit: src/sys

2012-07-07 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Jul  7 16:15:21 UTC 2012

Modified Files:
src/sys/kern: subr_disk_open.c
src/sys/sys: device.h

Log Message:
unsigned - unsigned int


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/kern/subr_disk_open.c
cvs rdiff -u -r1.141 -r1.142 src/sys/sys/device.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_disk_open.c
diff -u src/sys/kern/subr_disk_open.c:1.9 src/sys/kern/subr_disk_open.c:1.10
--- src/sys/kern/subr_disk_open.c:1.9	Sat Jul  7 16:10:23 2012
+++ src/sys/kern/subr_disk_open.c	Sat Jul  7 16:15:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_disk_open.c,v 1.9 2012/07/07 16:10:23 tsutsui Exp $	*/
+/*	$NetBSD: subr_disk_open.c,v 1.10 2012/07/07 16:15:20 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: subr_disk_open.c,v 1.9 2012/07/07 16:10:23 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: subr_disk_open.c,v 1.10 2012/07/07 16:15:20 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/conf.h
@@ -89,7 +89,7 @@ opendisk(struct device *dv)
 }
 
 int
-getdisksize(struct vnode *vp, uint64_t *numsecp, unsigned *secsizep)
+getdisksize(struct vnode *vp, uint64_t *numsecp, unsigned int *secsizep)
 {
 	struct partinfo dpart;
 	struct dkwedge_info dkw;

Index: src/sys/sys/device.h
diff -u src/sys/sys/device.h:1.141 src/sys/sys/device.h:1.142
--- src/sys/sys/device.h:1.141	Sun Jun 10 17:05:18 2012
+++ src/sys/sys/device.h	Sat Jul  7 16:15:21 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.141 2012/06/10 17:05:18 mlelstv Exp $ */
+/* $NetBSD: device.h,v 1.142 2012/07/07 16:15:21 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -428,7 +428,7 @@ extern daddr_t booted_startblk;		/* or t
 extern uint64_t booted_nblks;		/* and the size of that wedge */
 
 struct vnode *opendisk(struct device *);
-int getdisksize(struct vnode *, uint64_t *, unsigned *);
+int getdisksize(struct vnode *, uint64_t *, unsigned int *);
 struct dkwedge_info;
 int getdiskinfo(struct vnode *, struct dkwedge_info *);
 



CVS commit: src/sys/fs/msdosfs

2012-07-07 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Jul  7 16:18:50 UTC 2012

Modified Files:
src/sys/fs/msdosfs: msdosfs_vfsops.c

Log Message:
Revert rev 1.95 since getdisksize() no longer returns secsize=0.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.95 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.96
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.95	Sat Jun 30 11:01:41 2012
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Sat Jul  7 16:18:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.95 2012/06/30 11:01:41 tsutsui Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.96 2012/07/07 16:18:50 tsutsui Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.95 2012/06/30 11:01:41 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.96 2012/07/07 16:18:50 tsutsui Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h
@@ -493,7 +493,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 		goto error_exit;
 
 	error = getdisksize(devvp, psize, secsize);
-	if (error || secsize == 0) {
+	if (error) {
 		if (argp-flags  MSDOSFSMNT_GEMDOSFS)
 			goto error_exit;
 



CVS commit: src/usr.bin/find

2012-07-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Jul  7 20:45:10 UTC 2012

Modified Files:
src/usr.bin/find: find.1

Log Message:
- Even if it may be obvious, actually explain what ``{}'' means
  with ``-exec ... {} +'';
- make wording more consistent;
- bump date.

From Bug Hunting.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/usr.bin/find/find.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/find/find.1
diff -u src/usr.bin/find/find.1:1.75 src/usr.bin/find/find.1:1.76
--- src/usr.bin/find/find.1:1.75	Wed Jun 27 22:57:27 2012
+++ src/usr.bin/find/find.1	Sat Jul  7 20:45:09 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: find.1,v 1.75 2012/06/27 22:57:27 jdf Exp $
+.\	$NetBSD: find.1,v 1.76 2012/07/07 20:45:09 wiz Exp $
 .\
 .\ Copyright (c) 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\
 .\	from: @(#)find.1	8.7 (Berkeley) 5/9/95
 .\
-.Dd June 17, 2012
+.Dd July 7, 2012
 .Dt FIND 1
 .Os
 .Sh NAME
@@ -296,12 +296,12 @@ into sets, and
 .Ar utility
 will be invoked once per set, similar to
 .Xr xargs 1 .
-In this case the parameter
+In this case the string
 .Dq Ic {}
 must appear, and must appear as the last item in the argument list,
 just before the
 .Dq Ic \+
-parameter.
+parameter, and is replaced by the pathnames of the current set of files.
 Each set is limited to no more than 5,000 pathnames,
 and is also limited such that the total number of bytes in the argument
 list does not exceed



CVS commit: src/share/man/man9

2012-07-07 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat Jul  7 21:26:36 UTC 2012

Modified Files:
src/share/man/man9: kcpuset.9

Log Message:
Document kcpuset_isotherset() and kcpuset_countset().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/kcpuset.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/kcpuset.9
diff -u src/share/man/man9/kcpuset.9:1.2 src/share/man/man9/kcpuset.9:1.3
--- src/share/man/man9/kcpuset.9:1.2	Thu Oct  6 08:59:01 2011
+++ src/share/man/man9/kcpuset.9	Sat Jul  7 21:26:36 2012
@@ -1,4 +1,4 @@
-.\ $NetBSD: kcpuset.9,v 1.2 2011/10/06 08:59:01 wiz Exp $ */
+.\ $NetBSD: kcpuset.9,v 1.3 2012/07/07 21:26:36 rmind Exp $ */
 .\
 .\ Copyright (c) 2011 Jukka Ruohonen jruohonen.iki.fi
 .\ All rights reserved.
@@ -25,7 +25,7 @@
 .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\ POSSIBILITY OF SUCH DAMAGE.
 .\
-.Dd October 6, 2011
+.Dd July 7, 2012
 .Dt KCPUSET 9
 .Os
 .Sh NAME
@@ -42,9 +42,11 @@
 .Nm kcpuset_set ,
 .Nm kcpuset_clear ,
 .Nm kcpuset_isset ,
+.Nm kcpuset_isotherset ,
 .Nm kcpuset_iszero ,
 .Nm kcpuset_match ,
 .Nm kcpuset_merge ,
+.Nm kcpuset_countset ,
 .Nm kcpuset_atomic_set ,
 .Nm kcpuset_atomic_clear
 .Nd dynamic kernel CPU sets
@@ -72,14 +74,18 @@
 .Fn kcpuset_set kcpuset_t *kcp cpuid_t cpu
 .Ft void
 .Fn kcpuset_clear kcpuset_t *kcp cpuid_t cpu
-.Ft int
+.Ft bool
 .Fn kcpuset_isset kcpuset_t * kcp cpuid_t cpu
 .Ft bool
+.Fn kcpuset_isotherset kcpuset_t * kcp cpuid_t cpu
+.Ft bool
 .Fn kcpuset_iszero kcpuset_t *kcp
 .Ft bool
 .Fn kcpuset_match const kcpuset_t *kcp1 const kcpuset_t *kcp2
 .Ft void
 .Fn kcpuset_merge kcpuset_t *kcp1 kcpuset_t *kcp2
+.Ft int
+.Fn kcpuset_countset kcpuset_t *kcp1
 .Ft void
 .Fn kcpuset_atomic_set kcpuset_t *kcp cpuid_t cpu
 .Ft void
@@ -177,12 +183,20 @@ Removes
 from the set
 .Fa kcp .
 .It Fn kcpuset_isset kcp cpu
-Returns 1 if
+Returns true if
 .Fa cpu
 is part of the
 .Tn CPU
 set
 .Fa kcp .
+.It Fn kcpuset_isotherset kcp cpu
+Returns true if there any CPUs
+other than
+.Fa cpu
+in the
+.Tn CPU
+set
+.Fa kcp .
 .It Fn kcpuset_iszero kcp
 Returns true if the set
 .Fa kcp
@@ -198,6 +212,9 @@ Merges the set
 .Fa kcp2
 to the set
 .Fa kcp1 .
+.It Fn kcpuset_countset kcp
+Counts how many CPUs are in the set
+.Fa kcp .
 .It Fn kcpuset_atomic_set kcp cpu
 The
 .Fn kcpuset_atomic_set



CVS commit: src/share/man/man9

2012-07-07 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat Jul  7 21:27:56 UTC 2012

Modified Files:
src/share/man/man9: mutex.9

Log Message:
mutex_owned: update about not-held test.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/share/man/man9/mutex.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/mutex.9
diff -u src/share/man/man9/mutex.9:1.24 src/share/man/man9/mutex.9:1.25
--- src/share/man/man9/mutex.9:1.24	Thu Dec  2 12:54:13 2010
+++ src/share/man/man9/mutex.9	Sat Jul  7 21:27:56 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: mutex.9,v 1.24 2010/12/02 12:54:13 wiz Exp $
+.\	$NetBSD: mutex.9,v 1.25 2012/07/07 21:27:56 rmind Exp $
 .\
 .\ Copyright (c) 2007, 2009 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -27,7 +27,7 @@
 .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\ POSSIBILITY OF SUCH DAMAGE.
 .\
-.Dd September 14, 2010
+.Dd July 7, 2012
 .Dt MUTEX 9
 .Os
 .Sh NAME
@@ -186,8 +186,8 @@ For example:
 	KASSERT(mutex_owned(\*[Am]driver_lock));
 .Ed
 .Pp
-It should not be used to make locking decisions at run time, or to
-verify that a lock is not held.
+It should not be used to make locking decisions at run time.
+For spin mutexes, it must not be used to verify that a lock is not held.
 .It Fn mutex_spin_enter mtx
 .Pp
 Equivalent to



CVS commit: src/share/man/man4

2012-07-07 Thread S.P.Zeidler
Module Name:src
Committed By:   spz
Date:   Sat Jul  7 21:29:03 UTC 2012

Modified Files:
src/share/man/man4: tpm.4

Log Message:
platfrom - platform
copyright name UTF8ified


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/tpm.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/tpm.4
diff -u src/share/man/man4/tpm.4:1.2 src/share/man/man4/tpm.4:1.3
--- src/share/man/man4/tpm.4:1.2	Sun Jan 22 11:26:48 2012
+++ src/share/man/man4/tpm.4	Sat Jul  7 21:29:03 2012
@@ -1,6 +1,6 @@
-.\	$NetBSD: tpm.4,v 1.2 2012/01/22 11:26:48 wiz Exp $
+.\	$NetBSD: tpm.4,v 1.3 2012/07/07 21:29:03 spz Exp $
 .\
-.\ Copyright (c) 2010 Hans-Jörg Höxer, hans-joerg.hoe...@genua.de
+.\ Copyright (c) 2010 Hans-Jörg Höxer, hans-joerg.hoe...@genua.de
 .\
 .\ Permission to use, copy, modify, and distribute this software for any
 .\ purpose with or without fee is hereby granted, provided that the above
@@ -26,7 +26,7 @@
 .Sh DESCRIPTION
 The
 .Nm
-driver provides support for various trusted platfrom modules (TPM) that can
+driver provides support for various trusted platform modules (TPM) that can
 store cryptographic keys.
 .Pp
 Supported modules:



CVS commit: src/tests/ipf

2012-07-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jul  7 23:29:44 UTC 2012

Modified Files:
src/tests/ipf: t_filter_exec.sh t_nat_ipf_exec.sh

Log Message:
Re-enable some of the ipf tests.  The only thing wrong with these tests
is that the tests were not re-imported with the rest of ipfilter 5.1.1

XXX There are still some more ipf test failures that need to get resolved,
XXX but at least we'll get some of them back just in case we have a
XXX regression.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/ipf/t_filter_exec.sh \
src/tests/ipf/t_nat_ipf_exec.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/ipf/t_filter_exec.sh
diff -u src/tests/ipf/t_filter_exec.sh:1.6 src/tests/ipf/t_filter_exec.sh:1.7
--- src/tests/ipf/t_filter_exec.sh:1.6	Tue Mar 27 09:27:33 2012
+++ src/tests/ipf/t_filter_exec.sh	Sat Jul  7 23:29:44 2012
@@ -1,4 +1,4 @@
-# $NetBSD: t_filter_exec.sh,v 1.6 2012/03/27 09:27:33 jruoho Exp $
+# $NetBSD: t_filter_exec.sh,v 1.7 2012/07/07 23:29:44 pgoyette Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -33,10 +33,22 @@
 dotest()
 {
 	h_copydata $1
+	infmt=$2
+	outfmt=$3
+	shift
+	shift
+	shift
+	args=$@
+
+	if [ $outfmt = hex ] ; then
+		output=-x
+	else
+		output=
+	fi
 
 	{ while read rule; do
 		atf_check -x echo \$rule\ | ipftest -F \
-$2 -Rbr - -i in $4 $5 out
+$infmt $output -Rbr - -i in $args out
 		echo  out
 	done; } reg
 
@@ -46,8 +58,21 @@ $2 -Rbr - -i in $4 $5 out
 mtest()
 {
 	h_copydata $1
+	infmt=$2
+	outfmt=$3
+	shift
+	shift
+	shift
+	args=$@
+
+	if [ $outfmt = hex ] ; then
+		output=-x
+	else
+		output=
+	fi
 
-	atf_check -o save:out ipftest -F $2 -Rbr reg -i in
+
+	atf_check -o save:out ipftest -F $infmt $output -Rbr reg -i in $args
 	echo  out
 
 	diff -u exp out || atf_fail results differ
@@ -56,13 +81,26 @@ mtest()
 dotest6()
 {
 	h_copydata $(echo ${1} | tr _ .)
+	infmt=$2
+	outfmt=$3
+	shift
+	shift
+	shift
+	args=$@
+
+	if [ $outfmt = hex ] ; then
+		output=-x
+	else
+		output=
+	fi
+
 
 	ipftest -6 -r /dev/null -i /dev/null /dev/null 21 \
 	|| atf_skip skipping IPv6 tests
 
 	{ while read rule; do
 		atf_check -o save:save -x echo \$rule\ | \
-ipftest -F $2 -6br - -i in
+ipftest -F $infmt $output -6br - -i in $args
 		cat save out
 		echo  out
 	done; } reg
@@ -87,10 +125,14 @@ test_case f14 dotest text text
 test_case f15 mtest text text
 test_case f16 mtest text text
 test_case f17 mtest hex hex
-broken_test_case f18 mtest text text
-#broken_test_case f19 dotest text text -T fr_statemax=3
+test_case f18 mtest text text -D
+test_case f19 dotest text text -T state_max=3
 test_case f20 mtest text text
 test_case f24 mtest hex text
+test_case f25 mtest hex text -D
+test_case f26 dotest text text
+test_case f27 dotest hex text
+test_case f30 dotest text text
 test_case ipv6_1 dotest6 hex hex
 test_case ipv6_2 dotest6 hex hex
 test_case ipv6_3 dotest6 hex hex
@@ -117,13 +159,17 @@ atf_init_test_cases()
 	atf_add_test_case f16
 	atf_add_test_case f17
 	atf_add_test_case f18
+	atf_add_test_case f19
 	atf_add_test_case f20
 	atf_add_test_case f24
+	atf_add_test_case f25
+	atf_add_test_case f26
+	atf_add_test_case f27
+	atf_add_test_case f30
 	atf_add_test_case ipv6_1
 	atf_add_test_case ipv6_2
 	atf_add_test_case ipv6_3
 	atf_add_test_case ipv6_5
 	atf_add_test_case ipv6_6
 
-	#atf_add_test_case f19
 }
Index: src/tests/ipf/t_nat_ipf_exec.sh
diff -u src/tests/ipf/t_nat_ipf_exec.sh:1.6 src/tests/ipf/t_nat_ipf_exec.sh:1.7
--- src/tests/ipf/t_nat_ipf_exec.sh:1.6	Tue Mar 27 09:27:33 2012
+++ src/tests/ipf/t_nat_ipf_exec.sh	Sat Jul  7 23:29:44 2012
@@ -1,4 +1,4 @@
-# $NetBSD: t_nat_ipf_exec.sh,v 1.6 2012/03/27 09:27:33 jruoho Exp $
+# $NetBSD: t_nat_ipf_exec.sh,v 1.7 2012/07/07 23:29:44 pgoyette Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -35,24 +35,32 @@ natipftest()
 	h_copydata $1
 	cp $(atf_get_srcdir)/regress/$1.nat nat
 	cp $(atf_get_srcdir)/regress/$1.ipf ipf
+	many=$2
+	infmt=$3
+	outfmt=$4
+	shift
+	shift
+	shift
+	shift
+	args=$@
 
-	if [ $4 = hex ] ; then
-		format=-xF $3
+	if [ $outfmt = hex ] ; then
+		format=-xF $infmt
 	else
-		format=-F $3
+		format=-F $infmt
 	fi
 
-	case $2 in
+	case $many in
 	single)
 		{ while read rule; do
 			atf_check -o save:save -x echo \$rule\ | \
-ipftest -R $5 $6 $format -b -r ipf -N - -i in
+ipftest -R $format -b -r ipf -N - -i in $args
 			cat save out
 			echo --- out
 		done; } nat
 		;;
 	multi)
-		atf_check -o save:out ipftest -R $5 $6 \
+		atf_check -o save:out ipftest -R $args \
 			$format -b -r ipf -N nat -i in
 		echo --- out
 		;;
@@ -61,24 +69,26 @@ ipftest -R $5 $6 $format -b -r ipf -N - 
 	diff -u exp out || atf_fail results differ
 }
 
-broken_test_case ni1 natipftest multi hex hex -T fr_update_ipid=1

CVS commit: src/tests/ipf

2012-07-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun Jul  8 00:36:46 UTC 2012

Modified Files:
src/tests/ipf: t_pools.sh

Log Message:
Restore some more of the ipfilter 5.1.1 tests.

XXX It appears that ipftest is not handling the policy {,src-,dst-}hash
XXX correctly, so these tests are still marked broken/skipped.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/ipf/t_pools.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/ipf/t_pools.sh
diff -u src/tests/ipf/t_pools.sh:1.4 src/tests/ipf/t_pools.sh:1.5
--- src/tests/ipf/t_pools.sh:1.4	Wed Feb 15 17:55:24 2012
+++ src/tests/ipf/t_pools.sh	Sun Jul  8 00:36:46 2012
@@ -1,4 +1,4 @@
-# $NetBSD: t_pools.sh,v 1.4 2012/02/15 17:55:24 riz Exp $
+# $NetBSD: t_pools.sh,v 1.5 2012/07/08 00:36:46 pgoyette Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -43,10 +43,18 @@ ptest()
 {
 	h_copydata $1
 	cp $(atf_get_srcdir)/regress/$1.pool pool 2/dev/null
-	cp $(atf_get_srcdir)/regress/$1.ipf ipf
+	if [ -f $(atf_get_srcdir)/regress/$1.nat ] ; then
+		cp $(atf_get_srcdir)/regress/$1.nat nat
+	else
+		cp $(atf_get_srcdir)/regress/$1.ipf ipf
+	fi
 
 	if [ -f pool ] ; then
-		atf_check -o save:out ipftest -RD -b -P pool -r ipf -i in
+		if [ -f nat ] ; then
+			atf_check -o save:out ipftest -RD -b -P pool -N nat -i in
+		else
+			atf_check -o save:out ipftest -RD -b -P pool -r ipf -i in
+		fi
 	else
 		atf_check -o save:out ipftest -RD -b -r ipf -i in
 	fi
@@ -55,19 +63,41 @@ ptest()
 
 }
 
+test_case f28 ptest text text
+test_case f29 ptest text text
 test_case p1 ptest text text
 test_case p2 ptest text text
 test_case p3 ptest text text
+test_case p4 ptest text text
 test_case p5 ptest text text
+test_case p6 ptest text text
+test_case p7 ptest text text
+test_case p9 ptest text text
+broken_test_case p10 ptest text text
+broken_test_case p11 ptest text text
+broken_test_case p12 ptest text text
+test_case p13 ptest text text
 test_case ip1 iptest text text
 test_case ip2 iptest text text
+test_case ip3 iptest text text
 
 atf_init_test_cases()
 {
+	atf_add_test_case f28
+	atf_add_test_case f29
 	atf_add_test_case p1
 	atf_add_test_case p2
 	atf_add_test_case p3
+	atf_add_test_case p4
 	atf_add_test_case p5
+	atf_add_test_case p6
+	atf_add_test_case p7
+	atf_add_test_case p9
+	atf_add_test_case p10
+	atf_add_test_case p11
+	atf_add_test_case p12
+	atf_add_test_case p13
 	atf_add_test_case ip1
 	atf_add_test_case ip2
+	atf_add_test_case ip3
 }



CVS commit: src/usr.bin/ldd

2012-07-07 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Jul  8 00:53:45 UTC 2012

Modified Files:
src/usr.bin/ldd: ldd.c ldd.h ldd_elfxx.c

Log Message:
Make sure stuff using Obj_Entry is compiled correctly for ELF32 or ELF64.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/ldd/ldd.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/ldd/ldd.h
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/ldd/ldd_elfxx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/ldd/ldd.c
diff -u src/usr.bin/ldd/ldd.c:1.19 src/usr.bin/ldd/ldd.c:1.20
--- src/usr.bin/ldd/ldd.c:1.19	Tue May 24 12:27:29 2011
+++ src/usr.bin/ldd/ldd.c	Sun Jul  8 00:53:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldd.c,v 1.19 2011/05/24 12:27:29 joerg Exp $	*/
+/*	$NetBSD: ldd.c,v 1.20 2012/07/08 00:53:44 matt Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: ldd.c,v 1.19 2011/05/24 12:27:29 joerg Exp $);
+__RCSID($NetBSD: ldd.c,v 1.20 2012/07/08 00:53:44 matt Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -89,6 +89,10 @@ __RCSID($NetBSD: ldd.c,v 1.19 2011/05/2
  */
 static char *error_message;	/* Message for dlopen(), or NULL */
 bool _rtld_trust;		/* False for setuid and setgid programs */
+/*
+ * This may be ELF64 or ELF32 but since they are used opaquely it doesn't
+ * really matter.
+ */
 Obj_Entry *_rtld_objlist;	/* Head of linked list of shared objects */
 Obj_Entry **_rtld_objtail = _rtld_objlist;
 /* Link field of last object in list */
@@ -200,111 +204,6 @@ dlerror()
 }
 
 void
-fmtprint(const char *libname, Obj_Entry *obj, const char *fmt1,
-const char *fmt2)
-{
-	const char *libpath = obj ? obj-path : not found;
-	char libnamebuf[200];
-	char *libmajor = NULL;
-	const char *fmt;
-	char *cp;
-	int c;
-
-	if (strncmp(libname, lib, 3) == 0 
-	(cp = strstr(libname, .so)) != NULL) {
-		size_t i = cp - (libname + 3);
-
-		if (i = sizeof(libnamebuf))
-			i = sizeof(libnamebuf) - 1;
-		(void)memcpy(libnamebuf, libname + 3, i);
-		libnamebuf[i] = '\0';
-		if (cp[3]  isdigit((unsigned char)cp[4]))
-			libmajor = cp[4];
-		libname = libnamebuf;
-	}
-
-	if (fmt1 == NULL)
-		fmt1 = libmajor != NULL ?
-		\t-l%o.%m = %p\n :
-		\t-l%o = %p\n;
-	if (fmt2 == NULL)
-		fmt2 = \t%o = %p\n;
-
-	fmt = libname == libnamebuf ? fmt1 : fmt2;
-	while ((c = *fmt++) != '\0') {
-		switch (c) {
-		default:
-			putchar(c);
-			continue;
-		case '\\':
-			switch (c = *fmt) {
-			case '\0':
-continue;
-			case 'n':
-putchar('\n');
-break;
-			case 't':
-putchar('\t');
-break;
-			}
-			break;
-		case '%':
-			switch (c = *fmt) {
-			case '\0':
-continue;
-			case '%':
-			default:
-putchar(c);
-break;
-			case 'A':
-printf(%s, main_local);
-break;
-			case 'a':
-printf(%s, main_progname);
-break;
-			case 'o':
-printf(%s, libname);
-break;
-			case 'm':
-printf(%s, libmajor);
-break;
-			case 'n':
-/* XXX: not supported for elf */
-break;
-			case 'p':
-printf(%s, libpath);
-break;
-			case 'x':
-printf(%p, obj ? obj-mapbase : 0);
-break;
-			}
-			break;
-		}
-		++fmt;
-	}
-}
-
-void
-print_needed(Obj_Entry *obj, const char *fmt1, const char *fmt2)
-{
-	const Needed_Entry *needed;
-
-	for (needed = obj-needed; needed != NULL; needed = needed-next) {
-		const char *libname = obj-strtab + needed-name;
-
-		if (needed-obj != NULL) {
-			if (!needed-obj-printed) {
-fmtprint(libname, needed-obj, fmt1, fmt2);
-needed-obj-printed = 1;
-print_needed(needed-obj, fmt1, fmt2);
-			}
-		} else {
-			fmtprint(libname, needed-obj, fmt1, fmt2);
-		}
-	}
-}
-
-void
 _rtld_die(void)
 {
 	const char *msg = dlerror();

Index: src/usr.bin/ldd/ldd.h
diff -u src/usr.bin/ldd/ldd.h:1.6 src/usr.bin/ldd/ldd.h:1.7
--- src/usr.bin/ldd/ldd.h:1.6	Tue Dec 15 04:06:43 2009
+++ src/usr.bin/ldd/ldd.h	Sun Jul  8 00:53:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldd.h,v 1.6 2009/12/15 04:06:43 mrg Exp $	*/
+/*	$NetBSD: ldd.h,v 1.7 2012/07/08 00:53:44 matt Exp $	*/
 
 /*
  * Copyright (c) 2008 Matthew R. Green
@@ -43,8 +43,5 @@ int elf64_ldd(int, char *, const char *,
 #define elf_ldd elf32_ldd
 #endif
 
-void fmtprint(const char *, Obj_Entry *, const char *, const char *);
-void print_needed(Obj_Entry *, const char *, const char *);
-
 extern char *main_local;
 extern char *main_progname;

Index: src/usr.bin/ldd/ldd_elfxx.c
diff -u src/usr.bin/ldd/ldd_elfxx.c:1.5 src/usr.bin/ldd/ldd_elfxx.c:1.6
--- src/usr.bin/ldd/ldd_elfxx.c:1.5	Thu Jun 30 20:09:41 2011
+++ src/usr.bin/ldd/ldd_elfxx.c	Sun Jul  8 00:53:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldd_elfxx.c,v 1.5 2011/06/30 20:09:41 wiz Exp $	*/
+/*	$NetBSD: ldd_elfxx.c,v 1.6 2012/07/08 00:53:44 matt Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 
 #include sys/cdefs.h
 #ifndef lint

CVS commit: src/lib/libc/arch/mips/gen

2012-07-07 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Jul  8 00:59:34 UTC 2012

Modified Files:
src/lib/libc/arch/mips/gen: _setjmp.S

Log Message:
Slight optimization.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/arch/mips/gen/_setjmp.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/arch/mips/gen/_setjmp.S
diff -u src/lib/libc/arch/mips/gen/_setjmp.S:1.23 src/lib/libc/arch/mips/gen/_setjmp.S:1.24
--- src/lib/libc/arch/mips/gen/_setjmp.S:1.23	Wed Mar  9 16:10:29 2011
+++ src/lib/libc/arch/mips/gen/_setjmp.S	Sun Jul  8 00:59:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: _setjmp.S,v 1.23 2011/03/09 16:10:29 tsutsui Exp $	*/
+/*	$NetBSD: _setjmp.S,v 1.24 2012/07/08 00:59:34 matt Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -46,7 +46,7 @@
 #if 0
 	RCSID(from: @(#)_setjmp.s	8.1 (Berkeley) 6/4/93)
 #else
-	RCSID($NetBSD: _setjmp.S,v 1.23 2011/03/09 16:10:29 tsutsui Exp $)
+	RCSID($NetBSD: _setjmp.S,v 1.24 2012/07/08 00:59:34 matt Exp $)
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -113,7 +113,7 @@ LEAF(_setjmp)
 	REG_EPILOGUE
 
 	j	ra
-	move	v0, zero
+	 move	v0, zero
 END(_setjmp)
 
 LEAF(_longjmp)
@@ -175,9 +175,8 @@ LEAF(_longjmp)
 #endif	/* SOFTFLOAT_FOR_GCC */
 
 	REG_EPILOGUE
-	move	v0, a1			# get return value in 1st arg
 	j	ra
-	nop
+	 move	v0, a1			# get return value in 1st arg
 
 botch:
 	/*



CVS commit: src

2012-07-07 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sun Jul  8 01:21:12 UTC 2012

Modified Files:
src/common/lib/libc: Makefile.inc
src/lib/libc: shlib_version
src/lib/libc/hash: Makefile.inc
Added Files:
src/common/lib/libc/hash/murmurhash: murmurhash.c

Log Message:
Add MurmurHash2 -- a non-cryptographic hash function by Austin Appleby.
The code is taken from the upstream and is in the public domain.

OK christos@


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/common/lib/libc/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/common/lib/libc/hash/murmurhash/murmurhash.c
cvs rdiff -u -r1.231 -r1.232 src/lib/libc/shlib_version
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/hash/Makefile.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/Makefile.inc
diff -u src/common/lib/libc/Makefile.inc:1.11 src/common/lib/libc/Makefile.inc:1.12
--- src/common/lib/libc/Makefile.inc:1.11	Thu Jun 16 16:39:14 2011
+++ src/common/lib/libc/Makefile.inc	Sun Jul  8 01:21:12 2012
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile.inc,v 1.11 2011/06/16 16:39:14 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.12 2012/07/08 01:21:12 rmind Exp $
 
 COMMON_DIR:=${.PARSEDIR}
 COMMON_CODEDIRS=atomic gen gmon inet md net quad stdlib string sys
-COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160
+COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160 hash/murmurhash
 
 .if defined(COMMON_MACHINE_ARCH)  !empty(COMMON_MACHINE_ARCH)  \
 exists(${COMMON_DIR}/arch/${COMMON_MACHINE_ARCH})

Index: src/lib/libc/shlib_version
diff -u src/lib/libc/shlib_version:1.231 src/lib/libc/shlib_version:1.232
--- src/lib/libc/shlib_version:1.231	Thu Mar  8 21:59:28 2012
+++ src/lib/libc/shlib_version	Sun Jul  8 01:21:11 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: shlib_version,v 1.231 2012/03/08 21:59:28 joerg Exp $
+#	$NetBSD: shlib_version,v 1.232 2012/07/08 01:21:11 rmind Exp $
 #	Remember to update distrib/sets/lists/base/shl.* when changing
 #
 # things we wish to do on next major version bump:
@@ -31,4 +31,4 @@
 # - remove gets(); it is finally dead in c11.
 # - make __cerror (spelled CERROR) hidden again
 major=12
-minor=183
+minor=184

Index: src/lib/libc/hash/Makefile.inc
diff -u src/lib/libc/hash/Makefile.inc:1.11 src/lib/libc/hash/Makefile.inc:1.12
--- src/lib/libc/hash/Makefile.inc:1.11	Fri Oct 27 18:29:21 2006
+++ src/lib/libc/hash/Makefile.inc	Sun Jul  8 01:21:12 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.11 2006/10/27 18:29:21 drochner Exp $
+#	$NetBSD: Makefile.inc,v 1.12 2012/07/08 01:21:12 rmind Exp $
 #	$OpenBSD: Makefile.inc,v 1.5 1997/07/17 06:02:42 millert Exp $
 
 # hash functions
@@ -9,3 +9,4 @@
 .include ${.CURDIR}/hash/sha1/Makefile.inc
 .include ${.CURDIR}/hash/sha2/Makefile.inc
 
+.include ${.CURDIR}/hash/murmurhash/Makefile.inc

Added files:

Index: src/common/lib/libc/hash/murmurhash/murmurhash.c
diff -u /dev/null src/common/lib/libc/hash/murmurhash/murmurhash.c:1.1
--- /dev/null	Sun Jul  8 01:21:12 2012
+++ src/common/lib/libc/hash/murmurhash/murmurhash.c	Sun Jul  8 01:21:12 2012
@@ -0,0 +1,77 @@
+/*	$NetBSD: murmurhash.c,v 1.1 2012/07/08 01:21:12 rmind Exp $	*/
+
+/*
+ * MurmurHash2 -- from the original code:
+ *
+ * MurmurHash2 was written by Austin Appleby, and is placed in the public
+ * domain. The author hereby disclaims copyright to this source code.
+ *
+ * References:
+ *	http://code.google.com/p/smhasher/
+ *	https://sites.google.com/site/murmurhash/
+ */
+
+#include sys/cdefs.h
+#include sys/types.h
+#include sys/hash.h
+
+#if defined(_KERNEL) || defined(_STANDALONE)
+__KERNEL_RCSID(0, $NetBSD: murmurhash.c,v 1.1 2012/07/08 01:21:12 rmind Exp $);
+#else
+__RCSID($NetBSD: murmurhash.c,v 1.1 2012/07/08 01:21:12 rmind Exp $);
+#endif
+
+uint32_t
+murmurhash2(const void *key, size_t len, uint32_t seed)
+{
+	/*
+	 * Note: 'm' and 'r' are mixing constants generated offline.
+	 * They're not really 'magic', they just happen to work well.
+	 * Initialize the hash to a 'random' value.
+	 */
+	const uint32_t m = 0x5bd1e995;
+	const int r = 24;
+
+	const uint8_t *data = (const uint8_t *)key;
+	uint32_t h = seed ^ len;
+
+	while (len = sizeof(uint32_t)) {
+		uint32_t k;
+
+		k  = data[0];
+		k |= data[1]  8;
+		k |= data[2]  16;
+		k |= data[3]  24;
+
+		k *= m;
+		k ^= k  r;
+		k *= m;
+
+		h *= m;
+		h ^= k;
+
+		data += sizeof(uint32_t);
+		len -= sizeof(uint32_t);
+	}
+
+	/* Handle the last few bytes of the input array. */
+	switch (len) {
+	case 3:
+		h ^= data[2]  16;
+	case 2:
+		h ^= data[1]  8;
+	case 1:
+		h ^= data[0];
+		h *= m;
+	}
+
+	/*
+	 * Do a few final mixes of the hash to ensure the last few
+	 * bytes are well-incorporated.
+	 */
+	h ^= h  13;
+	h *= m;
+	h ^= h  15;
+
+	return h;
+}



CVS commit: src/sys/sys

2012-07-07 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sun Jul  8 01:24:08 UTC 2012

Modified Files:
src/sys/sys: hash.h

Log Message:
Add murmurhash2() prototype, missed in previous commit.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/sys/hash.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/sys/hash.h
diff -u src/sys/sys/hash.h:1.6 src/sys/sys/hash.h:1.7
--- src/sys/sys/hash.h:1.6	Mon Apr 28 20:24:10 2008
+++ src/sys/sys/hash.h	Sun Jul  8 01:24:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.h,v 1.6 2008/04/28 20:24:10 martin Exp $	*/
+/*	$NetBSD: hash.h,v 1.7 2012/07/08 01:24:08 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -33,11 +33,11 @@
 #define	_SYS_HASH_H_
 
 #include sys/types.h
+
 #ifdef __HAVE_MACHINE_HASH_H
 #include machine/hash.h
 #endif
 
-
 #ifndef __HAVE_HASH32_BUF			/* not overridden by MD hash */
 
 #define	HASH32_BUF_INIT	5381
@@ -99,5 +99,8 @@ hash32_strn(const void *bf, size_t len, 
 }
 #endif	/* __HAVE_HASH32_STR */
 
+__BEGIN_DECLS
+uint32_t	murmurhash2(const void *, size_t, uint32_t);
+__END_DECLS
 
 #endif	/* !_SYS_HASH_H_ */