|
XZ Utils 5.1.0alpha
|
Various integer and bit operations. More...
#include "tuklib_common.h"Various integer and bit operations.
This file provides macros or functions to do some basic integer and bit operations.
Endianness related integer operations (XX = 16, 32, or 64; Y = b or l):
Since they can macros, the arguments should have no side effects since they may be evaluated more than once.
Bit scan operations for non-zero 32-bit integers:
The above bit scan operations return 0-31. If num is zero, the result is undefined.
| #define bswap32 | ( | num | ) |
( (((uint32_t)(num) << 24) ) \
| (((uint32_t)(num) << 8) & UINT32_C(0x00FF0000)) \
| (((uint32_t)(num) >> 8) & UINT32_C(0x0000FF00)) \
| (((uint32_t)(num) >> 24) ) )
| #define bswap64 | ( | num | ) |
( (((uint64_t)(num) << 56) ) \
| (((uint64_t)(num) << 40) & UINT64_C(0x00FF000000000000)) \
| (((uint64_t)(num) << 24) & UINT64_C(0x0000FF0000000000)) \
| (((uint64_t)(num) << 8) & UINT64_C(0x000000FF00000000)) \
| (((uint64_t)(num) >> 8) & UINT64_C(0x00000000FF000000)) \
| (((uint64_t)(num) >> 24) & UINT64_C(0x0000000000FF0000)) \
| (((uint64_t)(num) >> 40) & UINT64_C(0x000000000000FF00)) \
| (((uint64_t)(num) >> 56) ) )
1.7.4