FreeBSD/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c
/*
 * dt_popcb() is a bitmap-based version of population count that returns the
 * number of one bits in the specified bitmap 'bp' at bit positions below 'n'.
 */
dt_popcb() is a bitmap-based version of population count that returns the
number of one bits in the specified bitmap 'bp' at bit positions below 'n'.
dt_popcb () is a bitmap - based version of population count that returns the number of one bits in the specified bitmap ' bp ' at bit positions below ' n ' .
ulong_t
dt_popcb(const ulong_t *bp, ulong_t n)
{
	ulong_t maxb = n & BT_ULMASK;
	ulong_t maxw = n >> BT_ULSHIFT;
	ulong_t w, popc = 0;
	if (n == 0)
		return (0);
	for (w = 0; w < maxw; w++)
		popc += dt_popc(bp[w]);
	return (popc + dt_popc(bp[maxw] & ((1UL << maxb) - 1)));
}
ulong_t dt_popcb ( const ulong_t * bp , ulong_t n ) { ulong_t maxb = n & BT_ULMASK ; ulong_t maxw = n >> BT_ULSHIFT ; ulong_t w , popc = 0 ; if ( n == 0 ) return ( 0 ) ; for ( w = 0 ; w < maxw ; w ++ ) popc += dt_popc ( bp [ w ] ) ; return ( popc + dt_popc ( bp [ maxw ] & ( ( 1UL << maxb ) - 1 ) ) ) ; }
dt_popcb() is a bitmap-based version of population count that returns the
 number of one bits in the specified bitmap 'bp' at bit positions below 'n'.
dt_popcb () is a bitmap - based version of population count that returns the number of one bits in the specified bitmap ' bp ' at bit positions below ' n ' .