host-utils header¶
The documentation of QEMU’s qemu/host-utils.h
header.
-
int
clz32
(uint32_t val)¶ count leading zeros in a 32-bit value.
Parameters
uint32_t val
- The value to search
Description
Returns 32 if the value is zero. Note that the GCC builtin is undefined if the value is zero.
-
int
clo32
(uint32_t val)¶ count leading ones in a 32-bit value.
Parameters
uint32_t val
- The value to search
Description
Returns 32 if the value is -1.
-
int
clz64
(uint64_t val)¶ count leading zeros in a 64-bit value.
Parameters
uint64_t val
- The value to search
Description
Returns 64 if the value is zero. Note that the GCC builtin is undefined if the value is zero.
-
int
clo64
(uint64_t val)¶ count leading ones in a 64-bit value.
Parameters
uint64_t val
- The value to search
Description
Returns 64 if the value is -1.
-
int
ctz32
(uint32_t val)¶ count trailing zeros in a 32-bit value.
Parameters
uint32_t val
- The value to search
Description
Returns 32 if the value is zero. Note that the GCC builtin is undefined if the value is zero.
-
int
cto32
(uint32_t val)¶ count trailing ones in a 32-bit value.
Parameters
uint32_t val
- The value to search
Description
Returns 32 if the value is -1.
-
int
ctz64
(uint64_t val)¶ count trailing zeros in a 64-bit value.
Parameters
uint64_t val
- The value to search
Description
Returns 64 if the value is zero. Note that the GCC builtin is undefined if the value is zero.
-
int
cto64
(uint64_t val)¶ count trailing ones in a 64-bit value.
Parameters
uint64_t val
- The value to search
Description
Returns 64 if the value is -1.
-
int
clrsb32
(uint32_t val)¶ count leading redundant sign bits in a 32-bit value.
Parameters
uint32_t val
- The value to search
Description
Returns the number of bits following the sign bit that are equal to it. No special cases; output range is [0-31].
-
int
clrsb64
(uint64_t val)¶ count leading redundant sign bits in a 64-bit value.
Parameters
uint64_t val
- The value to search
Description
Returns the number of bits following the sign bit that are equal to it. No special cases; output range is [0-63].
-
int
ctpop8
(uint8_t val)¶ count the population of one bits in an 8-bit value.
Parameters
uint8_t val
- The value to search
-
int
ctpop16
(uint16_t val)¶ count the population of one bits in a 16-bit value.
Parameters
uint16_t val
- The value to search
-
int
ctpop32
(uint32_t val)¶ count the population of one bits in a 32-bit value.
Parameters
uint32_t val
- The value to search
-
int
ctpop64
(uint64_t val)¶ count the population of one bits in a 64-bit value.
Parameters
uint64_t val
- The value to search
-
uint8_t
revbit8
(uint8_t x)¶ reverse the bits in an 8-bit value.
Parameters
uint8_t x
- The value to modify.
-
uint16_t
revbit16
(uint16_t x)¶ reverse the bits in a 16-bit value.
Parameters
uint16_t x
- The value to modify.
-
uint32_t
revbit32
(uint32_t x)¶ reverse the bits in a 32-bit value.
Parameters
uint32_t x
- The value to modify.
-
uint64_t
revbit64
(uint64_t x)¶ reverse the bits in a 64-bit value.
Parameters
uint64_t x
- The value to modify.
-
uint64_t
pow2floor
(uint64_t value)¶
Parameters
uint64_t value
- undescribed
-
void
urshift
(uint64_t * plow, uint64_t * phigh, int32_t shift)¶ 128-bit Unsigned Right Shift.
Parameters
uint64_t * plow
- in/out - lower 64-bit integer.
uint64_t * phigh
- in/out - higher 64-bit integer.
int32_t shift
- in - bytes to shift, between 0 and 127.
Description
Result is zero-extended and stored in plow/phigh, which are input/output variables. Shift values outside the range will be mod to 128. In other words, the caller is responsible to verify/assert both the shift range and plow/phigh pointers.
-
void
ulshift
(uint64_t * plow, uint64_t * phigh, int32_t shift, bool * overflow)¶ 128-bit Unsigned Left Shift.
Parameters
uint64_t * plow
- in/out - lower 64-bit integer.
uint64_t * phigh
- in/out - higher 64-bit integer.
int32_t shift
- in - bytes to shift, between 0 and 127.
bool * overflow
- out - true if any 1-bit is shifted out.
Description
Result is zero-extended and stored in plow/phigh, which are input/output variables. Shift values outside the range will be mod to 128. In other words, the caller is responsible to verify/assert both the shift range and plow/phigh pointers.