svn commit: r223884 - head/sys/sys
Konstantin Belousov
kib at FreeBSD.org
Sat Jul 9 14:29:24 UTC 2011
Author: kib
Date: Sat Jul 9 14:29:23 2011
New Revision: 223884
URL: http://svn.freebsd.org/changeset/base/223884
Log:
Implement bitcount16.
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Modified:
head/sys/sys/systm.h
Modified: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h Sat Jul 9 12:20:15 2011 (r223883)
+++ head/sys/sys/systm.h Sat Jul 9 14:29:23 2011 (r223884)
@@ -392,4 +392,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-all
mailing list