qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [5872] Define fls() in terms of clz32().


From: Anthony Liguori
Subject: [Qemu-devel] [5872] Define fls() in terms of clz32().
Date: Thu, 04 Dec 2008 20:08:06 +0000

Revision: 5872
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5872
Author:   aliguori
Date:     2008-12-04 20:08:06 +0000 (Thu, 04 Dec 2008)

Log Message:
-----------
Define fls() in terms of clz32().

As suggested by Laurent Desnogues.

Signed-off-by: Anthony Liguori <address@hidden>

Modified Paths:
--------------
    trunk/cutils.c

Modified: trunk/cutils.c
===================================================================
--- trunk/cutils.c      2008-12-04 19:58:45 UTC (rev 5871)
+++ trunk/cutils.c      2008-12-04 20:08:06 UTC (rev 5872)
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu-common.h"
+#include "host-utils.h"
 
 void pstrcpy(char *buf, int buf_size, const char *str)
 {
@@ -98,11 +99,5 @@
 
 int fls(int i)
 {
-    int bit;
-
-    for (bit=31; bit >= 0; bit--)
-        if (i & (1 << bit))
-            return bit+1;
-
-    return 0;
+    return 32 - clz32(i);
 }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]