Commit 8d371d4bceb308c29a5db4c21c984e06c9d56371
1 parent
f46f15bc
Define fls() in terms of clz32().
As suggested by Laurent Desnogues. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5872 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
2 additions
and
7 deletions
cutils.c
| @@ -22,6 +22,7 @@ | @@ -22,6 +22,7 @@ | ||
| 22 | * THE SOFTWARE. | 22 | * THE SOFTWARE. |
| 23 | */ | 23 | */ |
| 24 | #include "qemu-common.h" | 24 | #include "qemu-common.h" |
| 25 | +#include "host-utils.h" | ||
| 25 | 26 | ||
| 26 | void pstrcpy(char *buf, int buf_size, const char *str) | 27 | void pstrcpy(char *buf, int buf_size, const char *str) |
| 27 | { | 28 | { |
| @@ -98,11 +99,5 @@ time_t mktimegm(struct tm *tm) | @@ -98,11 +99,5 @@ time_t mktimegm(struct tm *tm) | ||
| 98 | 99 | ||
| 99 | int fls(int i) | 100 | int fls(int i) |
| 100 | { | 101 | { |
| 101 | - int bit; | ||
| 102 | - | ||
| 103 | - for (bit=31; bit >= 0; bit--) | ||
| 104 | - if (i & (1 << bit)) | ||
| 105 | - return bit+1; | ||
| 106 | - | ||
| 107 | - return 0; | 102 | + return 32 - clz32(i); |
| 108 | } | 103 | } |