svn commit: r224109 - stable/8/sys/sys
Konstantin Belousov
kib at FreeBSD.org
Sat Jul 16 19:28:43 UTC 2011
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_ */
More information about the svn-src-stable-8
mailing list