… | |
… | |
234 | equivalently the number of bits set to 0 before the least significant |
234 | equivalently the number of bits set to 0 before the least significant |
235 | bit set), starting from 0. If C<x> is 0 the result is undefined. A |
235 | bit set), starting from 0. If C<x> is 0 the result is undefined. A |
236 | common use case is to compute the integer binary logarithm, i.e., |
236 | common use case is to compute the integer binary logarithm, i.e., |
237 | floor(log2(n)). For example: |
237 | floor(log2(n)). For example: |
238 | |
238 | |
239 | ecb_ctz32(3) = 1 |
239 | ecb_ctz32(3) = 0 |
240 | ecb_ctz32(6) = 2 |
240 | ecb_ctz32(6) = 1 |
241 | |
241 | |
242 | =item int ecb_popcount32 (uint32_t x) |
242 | =item int ecb_popcount32 (uint32_t x) |
243 | |
243 | |
244 | Returns the number of bits set to 1 in C<x>. For example: |
244 | Returns the number of bits set to 1 in C<x>. For example: |
245 | |
245 | |
… | |
… | |
248 | |
248 | |
249 | =item uint32_t ecb_bswap16 (uint32_t x) |
249 | =item uint32_t ecb_bswap16 (uint32_t x) |
250 | |
250 | |
251 | =item uint32_t ecb_bswap32 (uint32_t x) |
251 | =item uint32_t ecb_bswap32 (uint32_t x) |
252 | |
252 | |
|
|
253 | These two functions return the value of the 16-bit (32-bit) variable |
|
|
254 | C<x> after reversing the order of bytes. |
|
|
255 | |
253 | =item uint32_t ecb_rotr32 (uint32_t x, unsigned int count) |
256 | =item uint32_t ecb_rotr32 (uint32_t x, unsigned int count) |
254 | |
257 | |
255 | =item uint32_t ecb_rotl32 (uint32_t x, unsigned int count) |
258 | =item uint32_t ecb_rotl32 (uint32_t x, unsigned int count) |
256 | |
259 | |
257 | These two functions return the value of C<x> after shifting all the bits |
260 | These two functions return the value of C<x> after shifting all the bits |
… | |
… | |
274 | |
277 | |
275 | =over 4 |
278 | =over 4 |
276 | |
279 | |
277 | =item element_count = ecb_array_length (name) [MACRO] |
280 | =item element_count = ecb_array_length (name) [MACRO] |
278 | |
281 | |
279 | =back |
282 | Returns the number of elements in the array C<name>. For example: |
280 | |
283 | |
|
|
284 | int primes[] = { 2, 3, 5, 7, 11 }; |
|
|
285 | int sum = 0; |
281 | |
286 | |
|
|
287 | for (i = 0; i < ecb_array_length (primes); i++) |
|
|
288 | sum += primes [i]; |
|
|
289 | |
|
|
290 | =back |
|
|
291 | |
|
|
292 | |