mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-27 03:47:43 +00:00
fb72014d98
We need to refactor code to be explicitely shared by the kernel and at least the tools/ userspace programs, so, till we do that, copy the bare minimum bitmap/bitops code needed by tools/perf. Reported-by: "H. Peter Anvin" <hpa@zytor.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
22 lines
482 B
C
22 lines
482 B
C
/*
|
|
* From lib/bitmap.c
|
|
* Helper functions for bitmap.h.
|
|
*
|
|
* This source code is licensed under the GNU General Public License,
|
|
* Version 2. See the file COPYING for more details.
|
|
*/
|
|
#include <linux/bitmap.h>
|
|
|
|
int __bitmap_weight(const unsigned long *bitmap, int bits)
|
|
{
|
|
int k, w = 0, lim = bits/BITS_PER_LONG;
|
|
|
|
for (k = 0; k < lim; k++)
|
|
w += hweight_long(bitmap[k]);
|
|
|
|
if (bits % BITS_PER_LONG)
|
|
w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
|
|
|
|
return w;
|
|
}
|