Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Jul 2011 19:28:43 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r224109 - stable/8/sys/sys
Message-ID:  <201107161928.p6GJSha5041068@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sat Jul 16 19:28:43 2011
New Revision: 224109
URL: http://svn.freebsd.org/changeset/base/224109

Log:
  MFC r223884:
  Implement bitcount16.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/8/sys/sys/systm.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/sys/systm.h
==============================================================================
--- stable/8/sys/sys/systm.h	Sat Jul 16 19:25:47 2011	(r224108)
+++ stable/8/sys/sys/systm.h	Sat Jul 16 19:28:43 2011	(r224109)
@@ -380,4 +380,15 @@ bitcount32(uint32_t x)
 	return (x);
 }
 
+static __inline uint16_t
+bitcount16(uint32_t x)
+{
+
+	x = (x & 0x5555) + ((x & 0xaaaa) >> 1);
+	x = (x & 0x3333) + ((x & 0xcccc) >> 2);
+	x = (x + (x >> 4)) & 0x0f0f;
+	x = (x + (x >> 8)) & 0x00ff;
+	return (x);
+}
+
 #endif /* !_SYS_SYSTM_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107161928.p6GJSha5041068>