* [Qemu-devel] [5872] Define fls() in terms of clz32().
@ 2008-12-04 20:08 Anthony Liguori
0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2008-12-04 20:08 UTC (permalink / raw)
To: qemu-devel
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);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-12-04 20:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-04 20:08 [Qemu-devel] [5872] Define fls() in terms of clz32() Anthony Liguori
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).