… | |
… | |
408 | |
408 | |
409 | =item uint32_t ecb_bswap16 (uint32_t x) |
409 | =item uint32_t ecb_bswap16 (uint32_t x) |
410 | |
410 | |
411 | =item uint32_t ecb_bswap32 (uint32_t x) |
411 | =item uint32_t ecb_bswap32 (uint32_t x) |
412 | |
412 | |
413 | These two functions return the value of the 16-bit (32-bit) variable |
413 | These two functions return the value of the 16-bit (32-bit) value C<x> |
414 | C<x> after reversing the order of bytes. |
414 | after reversing the order of bytes (0x11223344 becomes 0x44332211). |
415 | |
415 | |
416 | =item uint32_t ecb_rotr32 (uint32_t x, unsigned int count) |
416 | =item uint32_t ecb_rotr32 (uint32_t x, unsigned int count) |
417 | |
417 | |
418 | =item uint32_t ecb_rotl32 (uint32_t x, unsigned int count) |
418 | =item uint32_t ecb_rotl32 (uint32_t x, unsigned int count) |
419 | |
419 | |
420 | These two functions return the value of C<x> after shifting all the bits |
420 | These two functions return the value of C<x> after rotating all the bits |
421 | by C<count> positions to the right or left respectively. |
421 | by C<count> positions to the right or left respectively. |
422 | |
422 | |
423 | Current GCC versions understand these functions and usually compile them |
423 | Current GCC versions understand these functions and usually compile them |
424 | to "optimal" code (e.g. a single C<roll> on x86). |
424 | to "optimal" code (e.g. a single C<roll> on x86). |
425 | |
425 | |
… | |
… | |
434 | Returns the positive remainder of the modulo operation between C<m> and |
434 | Returns the positive remainder of the modulo operation between C<m> and |
435 | C<n>. Unlike the C modulo operator C<%>, this function ensures that the |
435 | C<n>. Unlike the C modulo operator C<%>, this function ensures that the |
436 | return value is always positive - ISO C guarantees very little when |
436 | return value is always positive - ISO C guarantees very little when |
437 | negative numbers are used with C<%>. |
437 | negative numbers are used with C<%>. |
438 | |
438 | |
439 | C<n> must be strictly positive (i.e. C<< >1 >>), while C<m> must be |
439 | C<n> must be strictly positive (i.e. C<< >= 1 >>), while C<m> must be |
440 | negatable, that is, both C<m> and C<-m> must be representable in its |
440 | negatable, that is, both C<m> and C<-m> must be representable in its |
441 | type. |
441 | type. |
442 | |
442 | |
443 | =back |
443 | =back |
444 | |
444 | |
445 | =head2 UTILITY |
445 | =head2 UTILITY |
446 | |
446 | |
447 | =over 4 |
447 | =over 4 |
448 | |
448 | |
449 | =item element_count = ecb_array_length (name) [MACRO] |
449 | =item element_count = ecb_array_length (name) |
450 | |
450 | |
451 | Returns the number of elements in the array C<name>. For example: |
451 | Returns the number of elements in the array C<name>. For example: |
452 | |
452 | |
453 | int primes[] = { 2, 3, 5, 7, 11 }; |
453 | int primes[] = { 2, 3, 5, 7, 11 }; |
454 | int sum = 0; |
454 | int sum = 0; |