Files | |
file | hqbitops.h |
Common byte and bitwise operations with optimised versions for various architectures. | |
file | hqbitvector.h |
Macros implementing bit vectors. | |
Macros | |
#define | BYTE_LOAD16_UNSIGNED_LE(ptr_) (uint16)(((uint8 *)(ptr_))[0] | (((uint8 *)(ptr_))[1] << 8)) |
#define | BYTE_LOAD16_UNSIGNED_BE(ptr_) (uint16)(((uint8 *)(ptr_))[1] | (((uint8 *)(ptr_))[0] << 8)) |
#define | BYTE_LOAD16_UNSIGNED_PLATFORM BYTE_LOAD16_UNSIGNED_LE |
#define | BYTE_LOAD16_SIGNED_LE(ptr_) (int16)BYTE_LOAD16_UNSIGNED_LE(ptr_) |
#define | BYTE_LOAD16_SIGNED_BE(ptr_) (int16)BYTE_LOAD16_UNSIGNED_BE(ptr_) |
#define | BYTE_LOAD16_SIGNED_PLATFORM BYTE_LOAD16_SIGNED_LE |
#define | BYTE_LOAD32_UNSIGNED_LE(ptr_) |
#define | BYTE_LOAD32_UNSIGNED_BE(ptr_) |
#define | BYTE_LOAD32_UNSIGNED_PLATFORM BYTE_LOAD32_UNSIGNED_LE |
#define | BYTE_LOAD32_SIGNED_LE(ptr_) (int32)BYTE_LOAD32_UNSIGNED_LE(ptr_) |
#define | BYTE_LOAD32_SIGNED_BE(ptr_) (int32)BYTE_LOAD32_UNSIGNED_BE(ptr_) |
#define | BYTE_LOAD32_SIGNED_PLATFORM BYTE_LOAD32_SIGNED_LE |
#define | BYTE_LOAD64_UNSIGNED_LE(ptr_) |
#define | BYTE_LOAD64_UNSIGNED_BE(ptr_) |
#define | BYTE_LOAD64_UNSIGNED_PLATFORM BYTE_LOAD64_UNSIGNED_LE |
#define | BYTE_LOAD64_SIGNED_LE(ptr_) (int64)BYTE_LOAD64_UNSIGNED_LE(ptr_) |
#define | BYTE_LOAD64_SIGNED_BE(ptr_) (int64)BYTE_LOAD64_UNSIGNED_BE(ptr_) |
#define | BYTE_LOAD64_SIGNED_PLATFORM BYTE_LOAD64_SIGNED_LE |
#define | BYTE_STORE16_LE(ptr_, val_) |
#define | BYTE_STORE16_BE(ptr_, val_) |
#define | BYTE_STORE16_PLATFORM BYTE_STORE16_LE |
#define | BYTE_STORE32_LE(ptr_, val_) |
#define | BYTE_STORE32_BE(ptr_, val_) |
#define | BYTE_STORE32_PLATFORM BYTE_STORE32_LE |
#define | BYTE_STORE64_LE(ptr_, val_) |
#define | BYTE_STORE64_BE(ptr_, val_) |
#define | BYTE_STORE64_PLATFORM BYTE_STORE64_LE |
#define | MASK_BYTES_1(type_) (type_)(~(type_)0 / 0xffu) |
#define | MASK_SHORTS_1(type_) (type_)(~(type_)0 / 0xffffu) |
#define | MASK_WORDS_1(type_) (type_)(~(type_)0 / 0xffffffffu) |
#define | MASK_ALTERNATE_BYTES(type_) (type_)(MASK_SHORTS_1(type_) * 0xffu) |
#define | MASK_ALTERNATE_SHORTS(type_) (type_)(MASK_WORDS_1(type_) * 0xffffu) |
#define | BYTE_SWAP16_UNSIGNED(val_) (uint16)((uint8)(val_) << 8 | (uint16)(val_) >> 8) |
#define | BYTE_SWAP16_UNSIGNED(val_) _byteswap_ushort((unsigned short)(val_)) |
#define | BYTE_SWAP16_UNSIGNED(val_) __builtin_bswap16((unsigned short)(val_)) |
#define | BYTE_SWAP16_SIGNED(val_) (int16)BYTE_SWAP16_UNSIGNED(val_) |
#define | BYTE_SWAP16_PTR(ptr_) |
#define | BYTE_SWAP16_PTR(ptr_) _swab((char *)(ptr_), (char *)(ptr_), 2) |
#define | BYTE_SWAP16_UNSIGNED_VAR(to_, from_) |
#define | BYTE_SWAP16_BUFFER(to_, from_, bytes_) |
#define | BYTE_SWAP16_BUFFER(to_, from_, bytes_) _swab((char *)(from_), (char *)(to_), (int)(bytes_)) |
#define | BYTE_SWAP32_UNSIGNED(val_) |
#define | BYTE_SWAP32_UNSIGNED(val_) _byteswap_ulong((unsigned long)(val_)) |
#define | BYTE_SWAP32_UNSIGNED(val_) __builtin_bswap32((unsigned long)(val_)) |
#define | BYTE_SWAP32_SIGNED(val_) (int32)BYTE_SWAP32_UNSIGNED(val_) |
#define | BYTE_SWAP32_PTR(ptr_) |
#define | BYTE_SWAP32_PTR(ptr_) |
#define | BYTE_SWAP32_UNSIGNED_VAR(to_, from_) |
#define | BYTE_SWAP32_BUFFER(to_, from_, bytes_) |
#define | BYTE_SWAP32_BUFFER_UNALIGNED(to_, from_, bytes_) |
#define | BYTE_SWAP32_BUFFER_UNALIGNED BYTE_SWAP32_BUFFER |
#define | BYTE_SWAP64_UNSIGNED(val_) |
#define | BYTE_SWAP64_UNSIGNED(val_) _byteswap_uint64((unsigned __int64)(val_)) |
#define | BYTE_SWAP64_UNSIGNED(val_) __builtin_bswap64((unsigned long long)(val_)) |
#define | BYTE_SWAP64_SIGNED(val_) (int64)BYTE_SWAP64_UNSIGNED(val_) |
#define | BYTE_SWAP64_PTR(ptr_) |
#define | BYTE_SWAP64_PTR(ptr_) |
#define | BYTE_SWAP64_UNSIGNED_VAR(to_, from_) |
#define | BYTE_SWAP64_BUFFER(to_, from_, bytes_) |
#define | BYTE_SWAP64_BUFFER_UNALIGNED(to_, from_, bytes_) |
#define | BYTE_SWAP64_BUFFER_UNALIGNED BYTE_SWAP64_BUFFER |
#define | SIGN32_NEG(x) -(int32)((uint32)((int32)(x)) >> 31) |
#define | SIGN32_NEG(x) ((int32)(x) >> 31) |
#define | SIGN64_NEG(x) -(int64)((uint64)((int64)(x)) >> 63) |
#define | SIGN64_NEG(x) ((int64)(x) >> 63) |
#define | SIGN32(x) (SIGN32_NEG(x) - SIGN32_NEG(-(x))) |
#define | SIGN64(x) (SIGN64_NEG(x) - SIGN64_NEG(-(x))) |
#define | BIT_ROTATE32_LEFT(to_, from_, shift_) |
#define | BIT_ROTATE32_LEFT(to_, from_, shift_) |
#define | BIT_ROTATE32_RIGHT(to_, from_, shift_) |
#define | BIT_ROTATE32_RIGHT(to_, from_, shift_) |
#define | BIT_ROTATE32_LEFT_SAFE(to_, from_, shift_) |
#define | BIT_ROTATE32_LEFT_SAFE(to_, from_, shift_) |
#define | BIT_ROTATE32_RIGHT_SAFE(to_, from_, shift_) |
#define | BIT_ROTATE32_RIGHT_SAFE(to_, from_, shift_) |
#define | BIT_ROTATE64_LEFT(to_, from_, shift_) |
#define | BIT_ROTATE64_LEFT(to_, from_, shift_) |
#define | BIT_ROTATE64_RIGHT(to_, from_, shift_) |
#define | BIT_ROTATE64_RIGHT(to_, from_, shift_) |
#define | BIT_ROTATE64_LEFT_SAFE(to_, from_, shift_) |
#define | BIT_ROTATE64_LEFT_SAFE(to_, from_, shift_) |
#define | BIT_ROTATE64_RIGHT_SAFE(to_, from_, shift_) |
#define | BIT_ROTATE64_RIGHT_SAFE(to_, from_, shift_) |
#define | BIT_SHIFT32_SIGNED_RIGHT_EXPR(val_, shift_) ((int32)((uint32)(val_) >> (shift_)) | (SIGN32_NEG(val_) << (31 ^ (shift_)))) |
#define | BIT_SHIFT32_SIGNED_RIGHT_EXPR(val_, shift_) ((int32)(val_) >> (shift_)) |
#define | BIT_SHIFT32_SIGNED_RIGHT(to_, from_, shift_) |
#define | BIT_SHIFT64_SIGNED_RIGHT_EXPR(val_, shift_) ((int64)((uint64)(val_) >> (shift_)) | (SIGN64_NEG(val_) << (63 ^ (shift_)))) |
#define | BIT_SHIFT64_SIGNED_RIGHT_EXPR(val_, shift_) ((int64)(val_) >> (shift_)) |
#define | BIT_SHIFT64_SIGNED_RIGHT(to_, from_, shift_) |
#define | INLINE_MIN32(min_, a_, b_) |
#define | INLINE_MAX32(max_, a_, b_) |
#define | INLINE_MINMAX32(min_, max_, a_, b_) |
#define | INLINE_ABS32(abs_, val_) |
#define | INLINE_RANGE32(to_, from_, min_, max_) |
#define | INLINE_RANGE32_0(to_, from_, max_) |
#define | INLINE_MIN64(min_, a_, b_) |
#define | INLINE_MAX64(max_, a_, b_) |
#define | INLINE_MINMAX64(min_, max_, a_, b_) |
#define | INLINE_ABS64(abs_, val_) |
#define | INLINE_RANGE64(to_, from_, min_, max_) |
#define | INLINE_RANGE64_0(to_, from_, max_) |
#define | BIT_LOWEST_SET_32(_n_) ((uint32)(_n_) & -(int32)(_n_)) |
#define | BIT_LOWEST_CLEAR_32(_n_) BIT_LOWEST_SET_32(~(uint32)(_n_)) |
#define | BIT_AT_MOST_ONE_SET_32(_n_) ((_n_) == BIT_LOWEST_SET_32(_n_)) |
#define | BIT_EXACTLY_ONE_SET_32(_n_) ((_n_) != 0 && BIT_AT_MOST_ONE_SET_32(_n_)) |
#define | BIT_LOWEST_SET_64(_n_) ((uint64)(_n_) & -(int64)(_n_)) |
#define | BIT_LOWEST_CLEAR_64(_n_) BIT_LOWEST_SET_64(~(uint64)(_n_)) |
#define | BIT_AT_MOST_ONE_SET_64(_n_) ((_n_) == BIT_LOWEST_SET_64(_n_)) |
#define | BIT_EXACTLY_ONE_SET_64(_n_) ((_n_) != 0 && BIT_AT_MOST_ONE_SET_64(_n_)) |
#define | BIT_COUNT_TRAILING_ZEROS_32(n_, i_) |
#define | BIT_COUNT_TRAILING_ZEROS_32(n_, i_) |
#define | BIT_COUNT_TRAILING_ZEROS_32(n_, i_) |
#define | BIT_LOWEST_SET_INDEX_32(n_, i_) |
#define | BIT_LOWEST_SET_INDEX_32(n_, i_) |
#define | BIT_LOWEST_SET_INDEX_32(n_, i_) |
#define | BIT_COUNT_LEADING_ZEROS_32(n_, i_) |
#define | BIT_COUNT_LEADING_ZEROS_32(n_, i_) |
#define | BIT_COUNT_LEADING_ZEROS_32(n_, i_) |
#define | BIT_HIGHEST_SET_INDEX_32(n_, i_) |
#define | BIT_HIGHEST_SET_INDEX_32(n_, i_) |
#define | BIT_COUNT_TRAILING_ZEROS_64(n_, i_) |
#define | BIT_COUNT_TRAILING_ZEROS_64(n_, i_) |
#define | BIT_COUNT_TRAILING_ZEROS_64(n_, i_) |
#define | BIT_LOWEST_SET_INDEX_64(n_, i_) |
#define | BIT_LOWEST_SET_INDEX_64(n_, i_) |
#define | BIT_LOWEST_SET_INDEX_64(n_, i_) |
#define | BIT_COUNT_LEADING_ZEROS_64(n_, i_) |
#define | BIT_COUNT_LEADING_ZEROS_64(n_, i_) |
#define | BIT_COUNT_LEADING_ZEROS_64(n_, i_) |
#define | BIT_HIGHEST_SET_INDEX_64(n_, i_) |
#define | BIT_HIGHEST_SET_INDEX_64(n_, i_) |
#define BIT_AT_MOST_ONE_SET_32 | ( | _n_ | ) | ((_n_) == BIT_LOWEST_SET_32(_n_)) |
Predicate to determine if zero or one bits are set in a 32-bit integer.
#define BIT_AT_MOST_ONE_SET_64 | ( | _n_ | ) | ((_n_) == BIT_LOWEST_SET_64(_n_)) |
Predicate to determine if zero or one bits are set in a 64-bit integer.
#define BIT_COUNT_LEADING_ZEROS_32 | ( | n_, | |
i_ | |||
) |
The number of leading zeros in a 32-bit integer. The count is set to 32 if there are no bits set on input. This is equivalent to 31-BIT_HIGHEST_SET_INDEX_32().
#define BIT_COUNT_LEADING_ZEROS_32 | ( | n_, | |
i_ | |||
) |
The number of leading zeros in a 32-bit integer. The count is set to 32 if there are no bits set on input. This is equivalent to 31-BIT_HIGHEST_SET_INDEX_32().
#define BIT_COUNT_LEADING_ZEROS_32 | ( | n_, | |
i_ | |||
) |
The number of leading zeros in a 32-bit integer. The count is set to 32 if there are no bits set on input. This is equivalent to 31-BIT_HIGHEST_SET_INDEX_32().
#define BIT_COUNT_LEADING_ZEROS_64 | ( | n_, | |
i_ | |||
) |
The number of leading zeros in a 64-bit integer. The count is set to 64 if there are no bits set on input. This is equivalent to 63-BIT_HIGHEST_SET_INDEX_64().
#define BIT_COUNT_LEADING_ZEROS_64 | ( | n_, | |
i_ | |||
) |
The number of leading zeros in a 64-bit integer. The count is set to 64 if there are no bits set on input. This is equivalent to 63-BIT_HIGHEST_SET_INDEX_64().
#define BIT_COUNT_LEADING_ZEROS_64 | ( | n_, | |
i_ | |||
) |
The number of leading zeros in a 64-bit integer. The count is set to 64 if there are no bits set on input. This is equivalent to 63-BIT_HIGHEST_SET_INDEX_64().
#define BIT_COUNT_TRAILING_ZEROS_32 | ( | n_, | |
i_ | |||
) |
The number of trailing zeros in a 32-bit integer. The count is set to 32 if there are no bits set on input. Apart from the zero case, this is the same as BIT_LOWEST_SET_INDEX_32().
#define BIT_COUNT_TRAILING_ZEROS_32 | ( | n_, | |
i_ | |||
) |
The number of trailing zeros in a 32-bit integer. The count is set to 32 if there are no bits set on input. Apart from the zero case, this is the same as BIT_LOWEST_SET_INDEX_32().
#define BIT_COUNT_TRAILING_ZEROS_32 | ( | n_, | |
i_ | |||
) |
The number of trailing zeros in a 32-bit integer. The count is set to 32 if there are no bits set on input. Apart from the zero case, this is the same as BIT_LOWEST_SET_INDEX_32().
#define BIT_COUNT_TRAILING_ZEROS_64 | ( | n_, | |
i_ | |||
) |
The number of trailing zeros in a 64-bit integer. The count is set to 64 if there are no bits set on input. Apart from the zero case, this is the same as BIT_LOWEST_SET_INDEX_64().
#define BIT_COUNT_TRAILING_ZEROS_64 | ( | n_, | |
i_ | |||
) |
The number of trailing zeros in a 64-bit integer. The count is set to 64 if there are no bits set on input. Apart from the zero case, this is the same as BIT_LOWEST_SET_INDEX_64().
#define BIT_COUNT_TRAILING_ZEROS_64 | ( | n_, | |
i_ | |||
) |
The number of trailing zeros in a 64-bit integer. The count is set to 64 if there are no bits set on input. Apart from the zero case, this is the same as BIT_LOWEST_SET_INDEX_64().
#define BIT_EXACTLY_ONE_SET_32 | ( | _n_ | ) | ((_n_) != 0 && BIT_AT_MOST_ONE_SET_32(_n_)) |
Predicate to determine if one bit is set in a 32-bit integer.
#define BIT_EXACTLY_ONE_SET_64 | ( | _n_ | ) | ((_n_) != 0 && BIT_AT_MOST_ONE_SET_64(_n_)) |
Predicate to determine if one bit is set in a 64-bit integer.
#define BIT_HIGHEST_SET_INDEX_32 | ( | n_, | |
i_ | |||
) |
Index of most significant bit set of a 32-bit integer. The index is set to -1 if there are no bits set on input. This is equivalent to 31-BIT_COUNT_LEADING_ZEROS_32().
#define BIT_HIGHEST_SET_INDEX_32 | ( | n_, | |
i_ | |||
) |
Index of most significant bit set of a 32-bit integer. The index is set to -1 if there are no bits set on input. This is equivalent to 31-BIT_COUNT_LEADING_ZEROS_32().
#define BIT_HIGHEST_SET_INDEX_64 | ( | n_, | |
i_ | |||
) |
Index of most significant bit set of a 64-bit integer. The index is set to -1 if there are no bits set on input. This is equivalent to 63-BIT_COUNT_LEADING_ZEROS_64().
#define BIT_HIGHEST_SET_INDEX_64 | ( | n_, | |
i_ | |||
) |
Index of most significant bit set of a 64-bit integer. The index is set to -1 if there are no bits set on input. This is equivalent to 63-BIT_COUNT_LEADING_ZEROS_64().
#define BIT_LOWEST_CLEAR_32 | ( | _n_ | ) | BIT_LOWEST_SET_32(~(uint32)(_n_)) |
Masks to the least significant bit clear for 32-bit integers.
#define BIT_LOWEST_CLEAR_64 | ( | _n_ | ) | BIT_LOWEST_SET_64(~(uint64)(_n_)) |
Masks to the least significant bit clear for 64-bit integers.
Masks to the least significant bit set for 32-bit integers.
Masks to the least significant bit set for 64-bit integers.
#define BIT_LOWEST_SET_INDEX_32 | ( | n_, | |
i_ | |||
) |
Index of least significant bit set of a 32 bit integer. The index is set to -1 if there are no bits set on input. Apart from the zero case, this is the same as BIT_COUNT_TRAILING_ZEROS_32().
#define BIT_LOWEST_SET_INDEX_32 | ( | n_, | |
i_ | |||
) |
Index of least significant bit set of a 32 bit integer. The index is set to -1 if there are no bits set on input. Apart from the zero case, this is the same as BIT_COUNT_TRAILING_ZEROS_32().
#define BIT_LOWEST_SET_INDEX_32 | ( | n_, | |
i_ | |||
) |
Index of least significant bit set of a 32 bit integer. The index is set to -1 if there are no bits set on input. Apart from the zero case, this is the same as BIT_COUNT_TRAILING_ZEROS_32().
#define BIT_LOWEST_SET_INDEX_64 | ( | n_, | |
i_ | |||
) |
Index of least significant bit set of a 64 bit integer. The index is set to -1 if there are no bits set on input. Apart from the zero case, this is the same as BIT_COUNT_TRAILING_ZEROS_64().
#define BIT_LOWEST_SET_INDEX_64 | ( | n_, | |
i_ | |||
) |
Index of least significant bit set of a 64 bit integer. The index is set to -1 if there are no bits set on input. Apart from the zero case, this is the same as BIT_COUNT_TRAILING_ZEROS_64().
#define BIT_LOWEST_SET_INDEX_64 | ( | n_, | |
i_ | |||
) |
Index of least significant bit set of a 64 bit integer. The index is set to -1 if there are no bits set on input. Apart from the zero case, this is the same as BIT_COUNT_TRAILING_ZEROS_64().
#define BIT_ROTATE32_LEFT | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 32-bit value. This is NOT safe for zero shifts.
#define BIT_ROTATE32_LEFT | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 32-bit value. This is NOT safe for zero shifts.
#define BIT_ROTATE32_LEFT_SAFE | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 32-bit value. This IS safe for zero shifts.
#define BIT_ROTATE32_LEFT_SAFE | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 32-bit value. This IS safe for zero shifts.
#define BIT_ROTATE32_RIGHT | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits right in a 32-bit value. This is NOT safe for zero shifts.
#define BIT_ROTATE32_RIGHT | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits right in a 32-bit value. This is NOT safe for zero shifts.
#define BIT_ROTATE32_RIGHT_SAFE | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 32-bit value. This IS safe for zero shifts.
#define BIT_ROTATE32_RIGHT_SAFE | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 32-bit value. This IS safe for zero shifts.
#define BIT_ROTATE64_LEFT | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 64-bit value. This is NOT safe for zero shifts.
#define BIT_ROTATE64_LEFT | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 64-bit value. This is NOT safe for zero shifts.
#define BIT_ROTATE64_LEFT_SAFE | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 64-bit value. This IS safe for zero shifts.
#define BIT_ROTATE64_LEFT_SAFE | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 64-bit value. This IS safe for zero shifts.
#define BIT_ROTATE64_RIGHT | ( | to_, | |
from_, | |||
shift_ | |||
) |
#define BIT_ROTATE64_RIGHT | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits right in a 64-bit value. This is NOT safe for zero shifts.
#define BIT_ROTATE64_RIGHT_SAFE | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 64-bit value. This IS safe for zero shifts.
#define BIT_ROTATE64_RIGHT_SAFE | ( | to_, | |
from_, | |||
shift_ | |||
) |
Rotate bits left in a 64-bit value. This IS safe for zero shifts.
#define BIT_SHIFT32_SIGNED_RIGHT | ( | to_, | |
from_, | |||
shift_ | |||
) |
Arithmetic shift right in a 32-bit value. This is safe for zero shifts (because the left shift of the negative sign by 31 ^ shift will set the same sign bit as is currently set).
#define BIT_SHIFT32_SIGNED_RIGHT_EXPR | ( | val_, | |
shift_ | |||
) | ((int32)((uint32)(val_) >> (shift_)) | (SIGN32_NEG(val_) << (31 ^ (shift_)))) |
Arithmetic shift right in a 32-bit value, suitable for use in an expression. This is safe for zero shifts (because the left shift of the negative sign by 31 ^ shift will set the same sign bit as is currently set).
#define BIT_SHIFT32_SIGNED_RIGHT_EXPR | ( | val_, | |
shift_ | |||
) | ((int32)(val_) >> (shift_)) |
Arithmetic shift right in a 32-bit value, suitable for use in an expression. This is safe for zero shifts (because the left shift of the negative sign by 31 ^ shift will set the same sign bit as is currently set).
#define BIT_SHIFT64_SIGNED_RIGHT | ( | to_, | |
from_, | |||
shift_ | |||
) |
Arithmetic shift right in a 64-bit value. This is safe for zero shifts (because the left shift of the negative sign by 63 ^ shift will set the same sign bit as is currently set).
#define BIT_SHIFT64_SIGNED_RIGHT_EXPR | ( | val_, | |
shift_ | |||
) | ((int64)((uint64)(val_) >> (shift_)) | (SIGN64_NEG(val_) << (63 ^ (shift_)))) |
Arithmetic shift right in a 64-bit value, suitable for use in an expression. This is safe for zero shifts (because the left shift of the negative sign by 63 ^ shift will set the same sign bit as is currently set).
#define BIT_SHIFT64_SIGNED_RIGHT_EXPR | ( | val_, | |
shift_ | |||
) | ((int64)(val_) >> (shift_)) |
Arithmetic shift right in a 64-bit value, suitable for use in an expression. This is safe for zero shifts (because the left shift of the negative sign by 63 ^ shift will set the same sign bit as is currently set).
#define BYTE_LOAD16_SIGNED_BE | ( | ptr_ | ) | (int16)BYTE_LOAD16_UNSIGNED_BE(ptr_) |
Load a 16-bit signed big-endian number from memory.
#define BYTE_LOAD16_SIGNED_LE | ( | ptr_ | ) | (int16)BYTE_LOAD16_UNSIGNED_LE(ptr_) |
Load a 16-bit signed little-endian number from memory.
#define BYTE_LOAD16_SIGNED_PLATFORM BYTE_LOAD16_SIGNED_LE |
Load a 16-bit signed platform-endian number from memory.
#define BYTE_LOAD16_UNSIGNED_BE | ( | ptr_ | ) | (uint16)(((uint8 *)(ptr_))[1] | (((uint8 *)(ptr_))[0] << 8)) |
Load a 16-bit unsigned big-endian number from memory.
#define BYTE_LOAD16_UNSIGNED_LE | ( | ptr_ | ) | (uint16)(((uint8 *)(ptr_))[0] | (((uint8 *)(ptr_))[1] << 8)) |
Load a 16-bit unsigned little-endian number from memory.
#define BYTE_LOAD16_UNSIGNED_PLATFORM BYTE_LOAD16_UNSIGNED_LE |
Load a 16-bit unsigned platform-endian number from memory.
#define BYTE_LOAD32_SIGNED_BE | ( | ptr_ | ) | (int32)BYTE_LOAD32_UNSIGNED_BE(ptr_) |
Load a 32-bit signed big-endian number from memory.
#define BYTE_LOAD32_SIGNED_LE | ( | ptr_ | ) | (int32)BYTE_LOAD32_UNSIGNED_LE(ptr_) |
Load a 32-bit signed little-endian number from memory.
#define BYTE_LOAD32_SIGNED_PLATFORM BYTE_LOAD32_SIGNED_LE |
Load a 32-bit signed platform-endian number from memory.
#define BYTE_LOAD32_UNSIGNED_BE | ( | ptr_ | ) |
#define BYTE_LOAD32_UNSIGNED_LE | ( | ptr_ | ) |
#define BYTE_LOAD32_UNSIGNED_PLATFORM BYTE_LOAD32_UNSIGNED_LE |
Load a 32-bit unsigned platform-endian number from memory.
#define BYTE_LOAD64_SIGNED_BE | ( | ptr_ | ) | (int64)BYTE_LOAD64_UNSIGNED_BE(ptr_) |
Load a 64-bit signed big-endian number from memory.
#define BYTE_LOAD64_SIGNED_LE | ( | ptr_ | ) | (int64)BYTE_LOAD64_UNSIGNED_LE(ptr_) |
Load a 64-bit signed little-endian number from memory.
#define BYTE_LOAD64_SIGNED_PLATFORM BYTE_LOAD64_SIGNED_LE |
Load a 64-bit signed platform-endian number from memory.
#define BYTE_LOAD64_UNSIGNED_BE | ( | ptr_ | ) |
Load a 64-bit unsigned big-endian number from memory.
#define BYTE_LOAD64_UNSIGNED_LE | ( | ptr_ | ) |
Load a 64-bit unsigned little-endian number from memory.
#define BYTE_LOAD64_UNSIGNED_PLATFORM BYTE_LOAD64_UNSIGNED_LE |
Load a 64-bit unsigned platform-endian number from memory.
#define BYTE_STORE16_BE | ( | ptr_, | |
val_ | |||
) |
#define BYTE_STORE16_LE | ( | ptr_, | |
val_ | |||
) |
#define BYTE_STORE16_PLATFORM BYTE_STORE16_LE |
Store a 16-bit platform-endian number to memory.
#define BYTE_STORE32_BE | ( | ptr_, | |
val_ | |||
) |
#define BYTE_STORE32_LE | ( | ptr_, | |
val_ | |||
) |
#define BYTE_STORE32_PLATFORM BYTE_STORE32_LE |
Store a 32-bit platform-endian number to memory.
#define BYTE_STORE64_BE | ( | ptr_, | |
val_ | |||
) |
Store a 64-bit big-endian number to memory.
#define BYTE_STORE64_LE | ( | ptr_, | |
val_ | |||
) |
Store a 64-bit little-endian number to memory.
#define BYTE_STORE64_PLATFORM BYTE_STORE64_LE |
Store a 64-bit platform-endian number to memory.
#define BYTE_SWAP16_BUFFER | ( | to_, | |
from_, | |||
bytes_ | |||
) |
Swap multiple 16-bit values in a buffer. Source and destination buffers can be the same.
#define BYTE_SWAP16_BUFFER | ( | to_, | |
from_, | |||
bytes_ | |||
) | _swab((char *)(from_), (char *)(to_), (int)(bytes_)) |
Swap multiple 16-bit values in a buffer. Source and destination buffers can be the same.
#define BYTE_SWAP16_PTR | ( | ptr_ | ) |
Swap bytes in a 16-bit value in memory.
#define BYTE_SWAP16_PTR | ( | ptr_ | ) | _swab((char *)(ptr_), (char *)(ptr_), 2) |
Swap bytes in a 16-bit value in memory.
#define BYTE_SWAP16_SIGNED | ( | val_ | ) | (int16)BYTE_SWAP16_UNSIGNED(val_) |
Swap bytes in a 16-bit value, returning a signed 16-bit value.
Swap bytes in a 16-bit value, returning an unsigned 16-bit value.
#define BYTE_SWAP16_UNSIGNED | ( | val_ | ) | _byteswap_ushort((unsigned short)(val_)) |
Swap bytes in a 16-bit value, returning an unsigned 16-bit value.
#define BYTE_SWAP16_UNSIGNED | ( | val_ | ) | __builtin_bswap16((unsigned short)(val_)) |
Swap bytes in a 16-bit value, returning an unsigned 16-bit value.
#define BYTE_SWAP16_UNSIGNED_VAR | ( | to_, | |
from_ | |||
) |
#define BYTE_SWAP32_BUFFER | ( | to_, | |
from_, | |||
bytes_ | |||
) |
Swap multiple 32-bit values in a buffer. Source and destination buffers can be the same.
#define BYTE_SWAP32_BUFFER_UNALIGNED | ( | to_, | |
from_, | |||
bytes_ | |||
) |
Swap multiple 32-bit values in a buffer, which may be unaligned. Source and destination buffers can be the same.
#define BYTE_SWAP32_BUFFER_UNALIGNED BYTE_SWAP32_BUFFER |
Swap multiple 32-bit values in a buffer, which may be unaligned. Source and destination buffers can be the same.
#define BYTE_SWAP32_PTR | ( | ptr_ | ) |
Swap bytes in a 32-bit value in memory.
#define BYTE_SWAP32_PTR | ( | ptr_ | ) |
Swap bytes in a 32-bit value in memory.
#define BYTE_SWAP32_SIGNED | ( | val_ | ) | (int32)BYTE_SWAP32_UNSIGNED(val_) |
Swap bytes in a 32-bit value, returning a signed 32-bit value.
#define BYTE_SWAP32_UNSIGNED | ( | val_ | ) |
#define BYTE_SWAP32_UNSIGNED | ( | val_ | ) | _byteswap_ulong((unsigned long)(val_)) |
Swap bytes in a 32-bit value, returning an unsigned 32-bit value.
#define BYTE_SWAP32_UNSIGNED | ( | val_ | ) | __builtin_bswap32((unsigned long)(val_)) |
Swap bytes in a 32-bit value, returning an unsigned 32-bit value.
#define BYTE_SWAP32_UNSIGNED_VAR | ( | to_, | |
from_ | |||
) |
Swap bytes in a 32-bit value in a variable.
#define BYTE_SWAP64_BUFFER | ( | to_, | |
from_, | |||
bytes_ | |||
) |
Swap multiple 64-bit values in a buffer. Source and destination buffers can be the same.
#define BYTE_SWAP64_BUFFER_UNALIGNED | ( | to_, | |
from_, | |||
bytes_ | |||
) |
Swap multiple 64-bit values in a buffer, which may be unaligned. Source and destination buffers can be the same.
#define BYTE_SWAP64_BUFFER_UNALIGNED BYTE_SWAP64_BUFFER |
Swap multiple 64-bit values in a buffer, which may be unaligned. Source and destination buffers can be the same.
#define BYTE_SWAP64_PTR | ( | ptr_ | ) |
Swap bytes in a 64-bit value in memory.
#define BYTE_SWAP64_PTR | ( | ptr_ | ) |
Swap bytes in a 64-bit value in memory.
#define BYTE_SWAP64_SIGNED | ( | val_ | ) | (int64)BYTE_SWAP64_UNSIGNED(val_) |
Swap bytes in a 64-bit value, returning a signed 64-bit value.
#define BYTE_SWAP64_UNSIGNED | ( | val_ | ) |
Swap bytes in a 64-bit value, returning an unsigned 64-bit value.
#define BYTE_SWAP64_UNSIGNED | ( | val_ | ) | _byteswap_uint64((unsigned __int64)(val_)) |
Swap bytes in a 64-bit value, returning an unsigned 64-bit value.
#define BYTE_SWAP64_UNSIGNED | ( | val_ | ) | __builtin_bswap64((unsigned long long)(val_)) |
Swap bytes in a 64-bit value, returning an unsigned 64-bit value.
#define BYTE_SWAP64_UNSIGNED_VAR | ( | to_, | |
from_ | |||
) |
Swap bytes in a 64-bit value in a variable.
#define INLINE_ABS32 | ( | abs_, | |
val_ | |||
) |
Get the absolute value of a 32-bit integer without branches.
#define INLINE_ABS64 | ( | abs_, | |
val_ | |||
) |
Get the absolute value of a 64-bit integer without branches.
#define INLINE_MAX32 | ( | max_, | |
a_, | |||
b_ | |||
) |
Get the maximum of two 32-bit integers without branches. This only works when the absolute difference between the values is less than MAXINT32.
#define INLINE_MAX64 | ( | max_, | |
a_, | |||
b_ | |||
) |
Get the maximum of two 64-bit integers without branches. This only works when the absolute difference between the values is less than MAXINT64.
#define INLINE_MIN32 | ( | min_, | |
a_, | |||
b_ | |||
) |
Get the minimum of two 32-bit integers without branches. This only works when the absolute difference between the values is less than MAXINT32.
#define INLINE_MIN64 | ( | min_, | |
a_, | |||
b_ | |||
) |
Get the minimum of two 64-bit integers without branches. This only works when the absolute difference between the values is less than MAXINT64.
#define INLINE_MINMAX32 | ( | min_, | |
max_, | |||
a_, | |||
b_ | |||
) |
Get the minimum and maximum of two 32-bit integers without branches. This only works when the absolute difference between the values is less than MAXINT32.
#define INLINE_MINMAX64 | ( | min_, | |
max_, | |||
a_, | |||
b_ | |||
) |
Get the minimum and maximum of two 64-bit integers without branches. This only works when the absolute difference between the values is less than MAXINT64.
#define INLINE_RANGE32 | ( | to_, | |
from_, | |||
min_, | |||
max_ | |||
) |
Range clip a 32-bit integer to minimum and maximum limits. This only works when the absolute difference between the values is less than MAXINT32.
#define INLINE_RANGE32_0 | ( | to_, | |
from_, | |||
max_ | |||
) |
#define INLINE_RANGE64 | ( | to_, | |
from_, | |||
min_, | |||
max_ | |||
) |
Range clip a 64-bit integer to minimum and maximum limits. This only works when the absolute difference between the values is less than MAXINT64.
#define INLINE_RANGE64_0 | ( | to_, | |
from_, | |||
max_ | |||
) |
#define MASK_ALTERNATE_BYTES | ( | type_ | ) | (type_)(MASK_SHORTS_1(type_) * 0xffu) |
Alternating bytes in an unsigned type set to 0x00,0xff.
#define MASK_ALTERNATE_SHORTS | ( | type_ | ) | (type_)(MASK_WORDS_1(type_) * 0xffffu) |
Alternating shorts in an unsigned type set to 0x0000,0xffff.
#define MASK_BYTES_1 | ( | type_ | ) | (type_)(~(type_)0 / 0xffu) |
All bytes in an unsigned type set to 0x01.
#define MASK_SHORTS_1 | ( | type_ | ) | (type_)(~(type_)0 / 0xffffu) |
All shorts in an unsigned type set to 0x0001.
#define MASK_WORDS_1 | ( | type_ | ) | (type_)(~(type_)0 / 0xffffffffu) |
All words in an unsigned type set to 0x00000001.
#define SIGN32 | ( | x | ) | (SIGN32_NEG(x) - SIGN32_NEG(-(x))) |
Extract the sign of a 32-bit integer as -1, 0, or +1.
Extract the sign bit, returning 0 for non-negative 32-bit numbers and -1 for negative numbers. This is useful as a mask. The casts around the macro parameter are to ensure sign extension from any supplied integer.
#define SIGN32_NEG | ( | x | ) | ((int32)(x) >> 31) |
Extract the sign bit, returning 0 for non-negative 32-bit numbers and -1 for negative numbers. This is useful as a mask. The casts around the macro parameter are to ensure sign extension from any supplied integer.
#define SIGN64 | ( | x | ) | (SIGN64_NEG(x) - SIGN64_NEG(-(x))) |
Extract the sign of a 64-bit integer as -1, 0, or +1.
Extract the sign bit, returning 0 for non-negative 64-bit numbers and -1 for negative numbers. This is useful as a mask. The casts around the macro parameter are to ensure sign extension from any supplied integer.
#define SIGN64_NEG | ( | x | ) | ((int64)(x) >> 63) |
Extract the sign bit, returning 0 for non-negative 64-bit numbers and -1 for negative numbers. This is useful as a mask. The casts around the macro parameter are to ensure sign extension from any supplied integer.