… | |
… | |
396 | After processing the node, (part of) the next node might already be in |
396 | After processing the node, (part of) the next node might already be in |
397 | cache. |
397 | cache. |
398 | |
398 | |
399 | =back |
399 | =back |
400 | |
400 | |
401 | =head2 BIT FIDDLING / BITSTUFFS |
401 | =head2 BIT FIDDLING / BIT WIZARDRY |
402 | |
402 | |
403 | =over 4 |
403 | =over 4 |
404 | |
404 | |
405 | =item bool ecb_big_endian () |
405 | =item bool ecb_big_endian () |
406 | |
406 | |
… | |
… | |
417 | =item int ecb_ctz64 (uint64_t x) |
417 | =item int ecb_ctz64 (uint64_t x) |
418 | |
418 | |
419 | Returns the index of the least significant bit set in C<x> (or |
419 | Returns the index of the least significant bit set in C<x> (or |
420 | equivalently the number of bits set to 0 before the least significant bit |
420 | equivalently the number of bits set to 0 before the least significant bit |
421 | set), starting from 0. If C<x> is 0 the result is undefined. |
421 | set), starting from 0. If C<x> is 0 the result is undefined. |
|
|
422 | |
|
|
423 | For smaller types than C<uint32_t> you can safely use C<ecb_ctz32>. |
422 | |
424 | |
423 | For example: |
425 | For example: |
424 | |
426 | |
425 | ecb_ctz32 (3) = 0 |
427 | ecb_ctz32 (3) = 0 |
426 | ecb_ctz32 (6) = 1 |
428 | ecb_ctz32 (6) = 1 |
… | |
… | |
438 | This function is similar to the "count leading zero bits" function, except |
440 | This function is similar to the "count leading zero bits" function, except |
439 | that that one returns how many zero bits are "in front" of the number (in |
441 | that that one returns how many zero bits are "in front" of the number (in |
440 | the given data type), while C<ecb_ld> returns how many bits the number |
442 | the given data type), while C<ecb_ld> returns how many bits the number |
441 | itself requires. |
443 | itself requires. |
442 | |
444 | |
|
|
445 | For smaller types than C<uint32_t> you can safely use C<ecb_ld32>. |
|
|
446 | |
443 | =item int ecb_popcount32 (uint32_t x) |
447 | =item int ecb_popcount32 (uint32_t x) |
444 | |
448 | |
445 | =item int ecb_popcount64 (uint64_t x) |
449 | =item int ecb_popcount64 (uint64_t x) |
446 | |
450 | |
447 | Returns the number of bits set to 1 in C<x>. For example: |
451 | Returns the number of bits set to 1 in C<x>. |
|
|
452 | |
|
|
453 | For smaller types than C<uint32_t> you can safely use C<ecb_popcount32>. |
|
|
454 | |
|
|
455 | For example: |
448 | |
456 | |
449 | ecb_popcount32 (7) = 3 |
457 | ecb_popcount32 (7) = 3 |
450 | ecb_popcount32 (255) = 8 |
458 | ecb_popcount32 (255) = 8 |
451 | |
459 | |
452 | =item uint32_t ecb_bswap16 (uint32_t x) |
460 | =item uint32_t ecb_bswap16 (uint32_t x) |