Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
69622293
Commit
69622293
authored
Oct 08, 2020
by
Michal Wasiak
Committed by
Adam Wujek
Oct 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/libwr: add bitCount function
Signed-off-by:
Michal Wasiak
<
michal.wasiak@gmail.com
>
parent
8c6ffa1c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
util.h
userspace/libwr/include/libwr/util.h
+3
-0
util.c
userspace/libwr/util.c
+11
-0
No files found.
userspace/libwr/include/libwr/util.h
View file @
69622293
...
...
@@ -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 */
userspace/libwr/util.c
View file @
69622293
...
...
@@ -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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment