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_ */ _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"