Skip to content

Instantly share code, notes, and snippets.

@trondeau
Created March 9, 2016 16:28
Show Gist options
  • Save trondeau/41f6b77c44c03bc814bf to your computer and use it in GitHub Desktop.
Save trondeau/41f6b77c44c03bc814bf to your computer and use it in GitHub Desktop.
Functions for building 64bit masks in gnuradio/math.h
#include <stdint.h>
/*!
* \param len length of the mask in bits up to 64.
* \returns A 64-bit mask aligned on the byte's MSB.
*/
static inline uint64_t
create_64bit_msb_mask(unsigned len)
{
return ((~0ULL) >> (64 - len)) << (64 - len);
}
/*!
* \param len length of the mask in bits up to 64.
* \returns A 64-bit mask aligned on the byte's LSB.
*/
static inline uint64_t
create_64bit_lsb_mask(unsigned len)
{
return ((~0ULL) >> (64 - len));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment