From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 14:29:24 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 081A3106566B; Sat, 9 Jul 2011 14:29:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ECE338FC08; Sat, 9 Jul 2011 14:29:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69ETNZo003912; Sat, 9 Jul 2011 14:29:23 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69ETNNu003910; Sat, 9 Jul 2011 14:29:23 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201107091429.p69ETNNu003910@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 9 Jul 2011 14:29:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223884 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 14:29:24 -0000 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_ */