[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [5708] Include <strings.h> for ffs().
From: |
Andrzej Zaborowski |
Subject: |
[Qemu-devel] [5708] Include <strings.h> for ffs(). |
Date: |
Wed, 12 Nov 2008 17:18:42 +0000 |
Revision: 5708
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5708
Author: balrog
Date: 2008-11-12 17:18:41 +0000 (Wed, 12 Nov 2008)
Log Message:
-----------
Include <strings.h> for ffs().
ffs() is in <strings.h> although bsd compatible systems have it in
<string.h> already. ffs() is used in omap1.c, omap2.c, omap_i2c.c,
bt-sdp.c. These uses can be replaced with clz32() but ffs is more
available. Problem was spotted by malc.
Make host-utils.h formatting more consistent.
Modified Paths:
--------------
trunk/host-utils.h
trunk/qemu-common.h
Modified: trunk/host-utils.h
===================================================================
--- trunk/host-utils.h 2008-11-12 16:50:36 UTC (rev 5707)
+++ trunk/host-utils.h 2008-11-12 17:18:41 UTC (rev 5708)
@@ -116,7 +116,7 @@
return clz64(~val);
}
-static always_inline int ctz32 (uint32_t val)
+static always_inline int ctz32(uint32_t val)
{
#if QEMU_GNUC_PREREQ(3, 4)
if (val)
@@ -128,39 +128,39 @@
cnt = 0;
if (!(val & 0x0000FFFFUL)) {
- cnt += 16;
+ cnt += 16;
val >>= 16;
- }
+ }
if (!(val & 0x000000FFUL)) {
- cnt += 8;
+ cnt += 8;
val >>= 8;
- }
+ }
if (!(val & 0x0000000FUL)) {
- cnt += 4;
+ cnt += 4;
val >>= 4;
- }
+ }
if (!(val & 0x00000003UL)) {
- cnt += 2;
+ cnt += 2;
val >>= 2;
- }
+ }
if (!(val & 0x00000001UL)) {
- cnt++;
+ cnt++;
val >>= 1;
- }
+ }
if (!(val & 0x00000001UL)) {
- cnt++;
- }
+ cnt++;
+ }
- return cnt;
+ return cnt;
#endif
- }
-
-static always_inline int cto32 (uint32_t val)
- {
+}
+
+static always_inline int cto32(uint32_t val)
+{
return ctz32(~val);
}
-static always_inline int ctz64 (uint64_t val)
+static always_inline int ctz64(uint64_t val)
{
#if QEMU_GNUC_PREREQ(3, 4)
if (val)
@@ -180,12 +180,12 @@
#endif
}
-static always_inline int cto64 (uint64_t val)
+static always_inline int cto64(uint64_t val)
{
return ctz64(~val);
}
-static always_inline int ctpop8 (uint8_t val)
+static always_inline int ctpop8(uint8_t val)
{
val = (val & 0x55) + ((val >> 1) & 0x55);
val = (val & 0x33) + ((val >> 2) & 0x33);
@@ -194,7 +194,7 @@
return val;
}
-static always_inline int ctpop16 (uint16_t val)
+static always_inline int ctpop16(uint16_t val)
{
val = (val & 0x5555) + ((val >> 1) & 0x5555);
val = (val & 0x3333) + ((val >> 2) & 0x3333);
@@ -204,7 +204,7 @@
return val;
}
-static always_inline int ctpop32 (uint32_t val)
+static always_inline int ctpop32(uint32_t val)
{
#if QEMU_GNUC_PREREQ(3, 4)
return __builtin_popcount(val);
@@ -219,7 +219,7 @@
#endif
}
-static always_inline int ctpop64 (uint64_t val)
+static always_inline int ctpop64(uint64_t val)
{
#if QEMU_GNUC_PREREQ(3, 4)
return __builtin_popcountll(val);
Modified: trunk/qemu-common.h
===================================================================
--- trunk/qemu-common.h 2008-11-12 16:50:36 UTC (rev 5707)
+++ trunk/qemu-common.h 2008-11-12 17:18:41 UTC (rev 5708)
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
+#include <strings.h>
#include <inttypes.h>
#include <limits.h>
#include <time.h>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [5708] Include <strings.h> for ffs().,
Andrzej Zaborowski <=