projects
/
qemu
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Introduce fls() helper
[qemu]
/
cutils.c
diff --git
a/cutils.c
b/cutils.c
index
142347d
..
9f124f5
100644
(file)
--- a/
cutils.c
+++ b/
cutils.c
@@
-95,3
+95,14
@@
time_t mktimegm(struct tm *tm)
t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
return t;
}
+
+int fls(int i)
+{
+ int bit;
+
+ for (bit=31; bit >= 0; bit--)
+ if (i & (1 << bit))
+ return bit+1;
+
+ return 0;
+}