* greater than 64 is given, it is truncated to 64.
*
* @param nbits The number of bits set in the mask.
+ *
+ * @ingroup api_bitfield
*/
inline uint64_t
mask(int nbits)
/**
* Extract the bitfield from position 'first' to 'last' (inclusive)
* from 'val' and right justify it. MSB is numbered 63, LSB is 0.
+ *
+ * @ingroup api_bitfield
*/
template <class T>
inline
/**
* Extract the bit from this position from 'val' and right justify it.
+ *
+ * @ingroup api_bitfield
*/
template <class T>
inline
/**
* Mask off the given bits in place like bits() but without shifting.
* msb = 63, lsb = 0
+ *
+ * @ingroup api_bitfield
*/
template <class T>
inline
return val & (mask(first+1) & ~mask(last));
}
+/**
+ * @ingroup api_bitfield
+ */
inline uint64_t
mask(int first, int last)
{
/**
* Sign-extend an N-bit value to 64 bits.
+ *
+ * @ingroup api_bitfield
*/
template <int N>
inline
* val: 0xFFFF
* bit_val: 0x0000
* returned: 0xFF0F
+ *
+ * @ingroup api_bitfield
*/
template <class T, class B>
inline
/**
* Overloaded for access to only one bit in value
+ *
+ * @ingroup api_bitfield
*/
template <class T, class B>
inline
* in place. It is functionally equivalent to insertBits.
*
* \note "first" is the MSB and "last" is the LSB. "first" >= "last"
+ *
+ * @ingroup api_bitfield
*/
template <class T, class B>
inline
val = insertBits(val, first, last, bit_val);
}
-/** Overloaded function to allow to access only 1 bit*/
+/**
+ * Overloaded function to allow to access only 1 bit
+ *
+ * @ingroup api_bitfield
+ */
template <class T, class B>
inline
void
* @param val: variable lenght word
* @param size: number of bytes to mirror
* @return mirrored word
+ *
+ * @ingroup api_bitfield
*/
template <class T>
T
/**
* Returns the bit position of the MSB that is set in the input
+ *
+ * @ingroup api_bitfield
*/
inline
int
/**
* Returns the bit position of the LSB that is set in the input
+ *
+ * @ingroup api_bitfield
*/
inline int
findLsbSet(uint64_t val) {
/**
* Checks if a number is a power of two, or zero.
+ *
+ * @ingroup api_bitfield
*/
template <class T>
inline bool
* Returns the number of set ones in the provided value.
* PD algorithm from
* http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
+ *
+ * @ingroup api_bitfield
*/
inline int
popCount(uint64_t val) {
*
* This code has been modified from the following:
* http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
+ *
+ * @ingroup api_bitfield
*/
inline uint64_t alignToPowerOfTwo(uint64_t val)
{
*
* @param An input value
* @return The number of trailing zeros or 32 if the value is zero.
+ *
+ * @ingroup api_bitfield
*/
inline int ctz32(uint32_t value)
{
*
* @param An input value
* @return The number of trailing zeros or 64 if the value is zero.
+ *
+ * @ingroup api_bitfield
*/
inline int ctz64(uint64_t value)
{