1 /* 2 * From lib/bitmap.c 3 * Helper functions for bitmap.h. 4 * 5 * This source code is licensed under the GNU General Public License, 6 * Version 2. See the file COPYING for more details. 7 */ 8 /* ANDROID_CHANGE_BEGIN */ 9 #if 0 10 #include <linux/bitmap.h> 11 #else 12 #include "include/linux/bitmap.h" 13 #endif 14 /* ANDROID_CHANGE_END */ 15 __bitmap_weight(const unsigned long * bitmap,int bits)16int __bitmap_weight(const unsigned long *bitmap, int bits) 17 { 18 int k, w = 0, lim = bits/BITS_PER_LONG; 19 20 for (k = 0; k < lim; k++) 21 w += hweight_long(bitmap[k]); 22 23 if (bits % BITS_PER_LONG) 24 w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); 25 26 return w; 27 } 28