Commit c89068455d8ce6a169c9e3e0f5c94d2658933fda
1 parent
be351261
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. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5708 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
25 additions
and
24 deletions
host-utils.h
@@ -116,7 +116,7 @@ static always_inline int clo64(uint64_t val) | @@ -116,7 +116,7 @@ static always_inline int clo64(uint64_t val) | ||
116 | return clz64(~val); | 116 | return clz64(~val); |
117 | } | 117 | } |
118 | 118 | ||
119 | -static always_inline int ctz32 (uint32_t val) | 119 | +static always_inline int ctz32(uint32_t val) |
120 | { | 120 | { |
121 | #if QEMU_GNUC_PREREQ(3, 4) | 121 | #if QEMU_GNUC_PREREQ(3, 4) |
122 | if (val) | 122 | if (val) |
@@ -128,39 +128,39 @@ static always_inline int ctz32 (uint32_t val) | @@ -128,39 +128,39 @@ static always_inline int ctz32 (uint32_t val) | ||
128 | 128 | ||
129 | cnt = 0; | 129 | cnt = 0; |
130 | if (!(val & 0x0000FFFFUL)) { | 130 | if (!(val & 0x0000FFFFUL)) { |
131 | - cnt += 16; | 131 | + cnt += 16; |
132 | val >>= 16; | 132 | val >>= 16; |
133 | - } | 133 | + } |
134 | if (!(val & 0x000000FFUL)) { | 134 | if (!(val & 0x000000FFUL)) { |
135 | - cnt += 8; | 135 | + cnt += 8; |
136 | val >>= 8; | 136 | val >>= 8; |
137 | - } | 137 | + } |
138 | if (!(val & 0x0000000FUL)) { | 138 | if (!(val & 0x0000000FUL)) { |
139 | - cnt += 4; | 139 | + cnt += 4; |
140 | val >>= 4; | 140 | val >>= 4; |
141 | - } | 141 | + } |
142 | if (!(val & 0x00000003UL)) { | 142 | if (!(val & 0x00000003UL)) { |
143 | - cnt += 2; | 143 | + cnt += 2; |
144 | val >>= 2; | 144 | val >>= 2; |
145 | - } | 145 | + } |
146 | if (!(val & 0x00000001UL)) { | 146 | if (!(val & 0x00000001UL)) { |
147 | - cnt++; | 147 | + cnt++; |
148 | val >>= 1; | 148 | val >>= 1; |
149 | - } | 149 | + } |
150 | if (!(val & 0x00000001UL)) { | 150 | if (!(val & 0x00000001UL)) { |
151 | - cnt++; | ||
152 | - } | 151 | + cnt++; |
152 | + } | ||
153 | 153 | ||
154 | - return cnt; | 154 | + return cnt; |
155 | #endif | 155 | #endif |
156 | - } | ||
157 | - | ||
158 | -static always_inline int cto32 (uint32_t val) | ||
159 | - { | 156 | +} |
157 | + | ||
158 | +static always_inline int cto32(uint32_t val) | ||
159 | +{ | ||
160 | return ctz32(~val); | 160 | return ctz32(~val); |
161 | } | 161 | } |
162 | 162 | ||
163 | -static always_inline int ctz64 (uint64_t val) | 163 | +static always_inline int ctz64(uint64_t val) |
164 | { | 164 | { |
165 | #if QEMU_GNUC_PREREQ(3, 4) | 165 | #if QEMU_GNUC_PREREQ(3, 4) |
166 | if (val) | 166 | if (val) |
@@ -180,12 +180,12 @@ static always_inline int ctz64 (uint64_t val) | @@ -180,12 +180,12 @@ static always_inline int ctz64 (uint64_t val) | ||
180 | #endif | 180 | #endif |
181 | } | 181 | } |
182 | 182 | ||
183 | -static always_inline int cto64 (uint64_t val) | 183 | +static always_inline int cto64(uint64_t val) |
184 | { | 184 | { |
185 | return ctz64(~val); | 185 | return ctz64(~val); |
186 | } | 186 | } |
187 | 187 | ||
188 | -static always_inline int ctpop8 (uint8_t val) | 188 | +static always_inline int ctpop8(uint8_t val) |
189 | { | 189 | { |
190 | val = (val & 0x55) + ((val >> 1) & 0x55); | 190 | val = (val & 0x55) + ((val >> 1) & 0x55); |
191 | val = (val & 0x33) + ((val >> 2) & 0x33); | 191 | val = (val & 0x33) + ((val >> 2) & 0x33); |
@@ -194,7 +194,7 @@ static always_inline int ctpop8 (uint8_t val) | @@ -194,7 +194,7 @@ static always_inline int ctpop8 (uint8_t val) | ||
194 | return val; | 194 | return val; |
195 | } | 195 | } |
196 | 196 | ||
197 | -static always_inline int ctpop16 (uint16_t val) | 197 | +static always_inline int ctpop16(uint16_t val) |
198 | { | 198 | { |
199 | val = (val & 0x5555) + ((val >> 1) & 0x5555); | 199 | val = (val & 0x5555) + ((val >> 1) & 0x5555); |
200 | val = (val & 0x3333) + ((val >> 2) & 0x3333); | 200 | val = (val & 0x3333) + ((val >> 2) & 0x3333); |
@@ -204,7 +204,7 @@ static always_inline int ctpop16 (uint16_t val) | @@ -204,7 +204,7 @@ static always_inline int ctpop16 (uint16_t val) | ||
204 | return val; | 204 | return val; |
205 | } | 205 | } |
206 | 206 | ||
207 | -static always_inline int ctpop32 (uint32_t val) | 207 | +static always_inline int ctpop32(uint32_t val) |
208 | { | 208 | { |
209 | #if QEMU_GNUC_PREREQ(3, 4) | 209 | #if QEMU_GNUC_PREREQ(3, 4) |
210 | return __builtin_popcount(val); | 210 | return __builtin_popcount(val); |
@@ -219,7 +219,7 @@ static always_inline int ctpop32 (uint32_t val) | @@ -219,7 +219,7 @@ static always_inline int ctpop32 (uint32_t val) | ||
219 | #endif | 219 | #endif |
220 | } | 220 | } |
221 | 221 | ||
222 | -static always_inline int ctpop64 (uint64_t val) | 222 | +static always_inline int ctpop64(uint64_t val) |
223 | { | 223 | { |
224 | #if QEMU_GNUC_PREREQ(3, 4) | 224 | #if QEMU_GNUC_PREREQ(3, 4) |
225 | return __builtin_popcountll(val); | 225 | return __builtin_popcountll(val); |
qemu-common.h
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <stdarg.h> | 8 | #include <stdarg.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | +#include <strings.h> | ||
10 | #include <inttypes.h> | 11 | #include <inttypes.h> |
11 | #include <limits.h> | 12 | #include <limits.h> |
12 | #include <time.h> | 13 | #include <time.h> |