diff options
author | 2008-12-04 19:19:45 +0000 | |
---|---|---|
committer | 2008-12-04 19:19:45 +0000 | |
commit | b39ade83c2eafc231d239c2083b65c84a79bb134 (patch) | |
tree | 32932ea5a3d30a4f04580c88f936a91d972aad3f /cutils.c | |
parent | Clarify -soundhw documentation as to avoid hda confusion (diff) | |
download | qemu-kvm-b39ade83c2eafc231d239c2083b65c84a79bb134.tar.gz qemu-kvm-b39ade83c2eafc231d239c2083b65c84a79bb134.tar.bz2 qemu-kvm-b39ade83c2eafc231d239c2083b65c84a79bb134.zip |
Introduce fls() helper
This is needed for virtio. The implementation is originally from
Marcelo Tosatti.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5868 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'cutils.c')
-rw-r--r-- | cutils.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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; +} |