Commit 69622293 authored by Michal Wasiak's avatar Michal Wasiak Committed by Adam Wujek

userspace/libwr: add bitCount function

Signed-off-by: 's avatarMichal Wasiak <michal.wasiak@gmail.com>
parent 8c6ffa1c
......@@ -27,4 +27,7 @@ void strncpy_e(char *d, char *s, int len);
/* Create map */
void *create_map(unsigned long address, unsigned long size);
/* Count bits in a unsigned int */
unsigned int bitCount (unsigned int value);
#endif /* __LIBWR_HW_UTIL_H */
......@@ -133,3 +133,14 @@ void *create_map(unsigned long address, unsigned long size)
return NULL;
return mapaddr + fragment;
}
unsigned int bitCount (unsigned int value) {
unsigned int count = 0;
while (value > 0) {
if ((value & 1) == 1)
count++;
value >>= 1;
}
return count;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment