qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [5872] Define fls() in terms of clz32().
Date: Thu, 04 Dec 2008 20:08:06 +0000	[thread overview]
Message-ID: <E1L8KUY-000758-DN@cvs.savannah.gnu.org> (raw)

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 <aliguori@us.ibm.com>

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	other threads:[~2008-12-04 20:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1L8KUY-000758-DN@cvs.savannah.gnu.org \
    --to=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).