GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LDT / dev > test_rl / sun-gcc
#include <PBI/PTR.h>
#include <PBI/FFS.ih>
Classes | |
struct | _BFU |
The return value of the BFU routines, capturing the current 32-bit word that is being used as a source and the extracted value. More... | |
Defines | |
#define | _bfu_get_pos(_bfu) _bfu.val |
Gets the current buffer bit position. | |
#define | _bfu_get_tmp(_bfu) _bfu.cur |
Gets the current temporary buffer. | |
#define | _bfu_get(_bfu, _tmp, _pos) |
Gets the current temporary buffer and buffer bit position. | |
#define | _bfu_put_tmp(_bfu, _tmp) _bfu.cur = _tmp; |
Updates the current temporary buffer. | |
#define | _bfu_put_pos(_bfu, _pos) _bfu.val = _pos; |
Gets the current buffer bit position. | |
#define | _bfu_put(_bfu, _tmp, _pos) |
Updates the current temporary buffer and buffer bit position. | |
#define | _bfu_construct(_bfu, _s, _alignment, _src, _boff) |
Constructs a BFU from an arbitrarily aligned source buffer pointer, and a bit offset _boff. Also returns a 32-bit aligned pointer to be used with _bfu_extract. | |
#define | _bfu_constructW(_bfu, _src, _boff) |
Constructs a BFU from an 32-bit (word) aligned source buffer pointer and a bit offset _boff. | |
#define | _bfu_extractBoolean(_bfu, _wrds, _position) |
Extracts the next bit, returning it as a boolean value. The justification is unspecfied. The implementation is the most efficient of _bfu_extractBL or _bfu_extractBR. Use one of those routine if the justification needs to be specified. | |
#define | _bfu_extractBR(_bfu, _wrds, _position) |
Extracts the right justified bit from the current position. | |
#define | _bfu_extractBL(_bfu, _wrds, _position) |
Extracts the left justified bit from the current position. | |
#define | _bfu_extractL(_bfu, _wrds, _position, _width) |
Extracts a left justified value from the current position. | |
#define | _bfu_extractR(_bfu, _wrds, _position, _width) |
Extracts a right justified value from the current position. | |
#define | _bfu_extract32(_bfu, _wrds, _position) |
Extracts 32 bits from the current position. | |
#define | _bfu_count1s(_bfu, _wrds, _position) |
Counts the number of 1s till the first clear bit. | |
#define | _bfu_revert(_bfu, _wrds, _position, _nwidth, _nexp) |
Counts the number of 1s till the first clear bit. | |
Typedefs | |
typedef struct _BFU | BFU |
Typedef for struct _BFU. | |
Functions | |
static __inline BFU | BFU__bitL (const unsigned int *wrds, unsigned int cur, unsigned int position) |
Unpacks the left justified bit from the current position. | |
static __inline BFU | BFU__bitR (const unsigned int *wrds, unsigned int cur, unsigned int position) |
Unpacks the right justified bit from the current position. | |
static __inline BFU | BFU__boolean (const unsigned int *wrds, unsigned int cur, unsigned int position) |
Unpacks the next bit. This is equivalent to a bit extract, but the justification (left or right) is unspecified. Rather the must efficient extraction is used, returning only 0 or non-zero. Use BFU__bitL or BFU__bitR if a specific justification is needed. | |
static __inline BFU | BFU__wordR (const unsigned int *wrds, unsigned int cur, unsigned int position, unsigned int width) |
Unpacks a right justified bit field from the current position. The width of the bit field must be less than 32 bits. | |
static __inline BFU | BFU__wordL (const unsigned int *wrds, unsigned int cur, unsigned int position, unsigned int width) |
Unpacks a left justified bit field from the current position. The width of the bit field must be less than 32 bits. | |
static __inline BFU | BFU__word (const unsigned int *wrds, unsigned int cur, unsigned int position) |
Unpacks exactly 32 bits from the current position. | |
static __inline BFU | BFU__ffc (const unsigned int *wrds, unsigned int cur, unsigned int position) |
Scans the input bit stream for the first clear bit, this effectively counts the number of set bits. |
Inline functions to (left justified) unpack bit fields.
#define _bfu_construct | ( | _bfu, | |||
_s, | |||||
_alignment, | |||||
_src, | |||||
_boff | ) |
Value:
do \ { \ /* Move to the nearest 32-bit boundary */ \ \ /* Convert to a 32-bit pointer */ \ _s = (const unsigned int *)_src; \ \ /* Calculate the number of bits that are not a multiple of 32 */ \ alignment = ((PTR_as_uint)_s & 0x3) << 3; \ \ /* Add this to the bit offset */ \ _boff += _alignment; \ \ /* Reset the pointer back to the nearest 32-bit boundary */ \ _s = (const unsigned int *)((PTR_as_uint)_s \ & ~(PTR_as_uint)0x3); \ \ /* Extract the first word */ \ _bfu.cur = _s[_boff >> 5]; \ _bfu.val = boff; \ \ } while (0)
_bfu | The BFU structure to populate | |
_s | Returned as a 32-bit aligned version of _src | |
_alignment | Returned as the alignment adjustment. This value should be subtracted off when resetting the bit offset back to a value that corresponds to the alignment associated with _src. | |
_src | The source buffer pointer | |
_boff | The original bit offset, returned as the adjusted offset to compensate for any possible alignment to _s |
#define _bfu_constructW | ( | _bfu, | |||
_src, | |||||
_boff | ) |
Value:
_bfu.cur = _src[_boff >> 5]; \ _bfu.val = _boff \
_bfu | The BFU structure to populate | |
_src | The source buffer pointer | |
_boff | The original bit offset, returned as the adjusted offset to compensate for any possible alignment to _s |
#define _bfu_count1s | ( | _bfu, | |||
_wrds, | |||||
_position | ) |
Value:
(_bfu = BFU__ffc (_wrds, _bfu_get_tmp(bfu), _position), \ _position += (_bfu.val -= _position), \ _bfu.val - 1)
_bfu | The bit field unpacking context | |
_wrds | The source word array | |
_position | The bit position of the left most bit of the field to be extracted in the source array |
#define _bfu_extract32 | ( | _bfu, | |||
_wrds, | |||||
_position | ) |
Value:
Extracts 32 bits from the current position.
_bfu | The bit field unpacking context | |
_wrds | The source word array | |
_position | The bit position of the left most bit of the field to be extracted in the source array |
#define _bfu_extractBL | ( | _bfu, | |||
_wrds, | |||||
_position | ) |
Value:
Extracts the left justified bit from the current position.
_bfu | The bit field unpacking context | |
_wrds | The source word array | |
_position | The bit position of the bit to be extracted from the source array |
#define _bfu_extractBoolean | ( | _bfu, | |||
_wrds, | |||||
_position | ) |
Value:
(_bfu = BFU__boolean (_wrds, _bfu.cur, _position), \ _position += 1, \ _bfu.val)
0,if | the bit was 0 | |
!=0,if | the bit was 1 |
_bfu | The bit field unpacking context | |
_wrds | The source word array | |
_position | The bit position of the bit to be extracted from the source array |
#define _bfu_extractBR | ( | _bfu, | |||
_wrds, | |||||
_position | ) |
Value:
Extracts the right justified bit from the current position.
_bfu | The bit field unpacking context | |
_wrds | The source word array | |
_position | The bit position of the bit to be extracted from the source array |
#define _bfu_extractL | ( | _bfu, | |||
_wrds, | |||||
_position, | |||||
_width | ) |
Value:
(_bfu = BFU__wordL (_wrds, _bfu.cur, _position, _width), \ _position += _width, \ _bfu.val)
_bfu | The bit field unpacking context | |
_wrds | The source word array | |
_position | The bit position of the left most bit of the field to be extracted in the source array | |
_width | The width of the field to be extracted; must be < 32 |
#define _bfu_extractR | ( | _bfu, | |||
_wrds, | |||||
_position, | |||||
_width | ) |
Value:
(_bfu = BFU__wordR (_wrds, _bfu.cur, _position, _width), \ _position += _width, \ _bfu.val)
_bfu | The bit field unpacking context | |
_wrds | The source word array | |
_position | The bit position of the left most bit of the field to be extracted in the source array | |
_width | The width of the field to be extracted; must be < 32 |
#define _bfu_get | ( | _bfu, | |||
_tmp, | |||||
_pos | ) |
Value:
_tmp = _bfu.cur; \ _pos = _bfu.val;
_bfu | The context to fetch the temporary buffer from | |
_tmp | Returned as the value of the temporary holding buffer | |
_pos | Returned as the value of the buffer bit position |
#define _bfu_get_pos | ( | _bfu | ) | _bfu.val |
Gets the current buffer bit position.
The | value of the current buffer bit position |
_bfu | The context to fetch the buffer bit position from |
#define _bfu_get_tmp | ( | _bfu | ) | _bfu.cur |
Gets the current temporary buffer.
The | value of the temporary buffer |
_bfu | The context to fetch the temporary buffer from |
#define _bfu_put | ( | _bfu, | |||
_tmp, | |||||
_pos | ) |
Value:
_bfu.cur = _tmp; \ _bfu.val = _pos;
_bfu | The context to update | |
_tmp | The updated value of the temporary holding buffer | |
_pos | The updated value of the buffer bit position |
#define _bfu_put_pos | ( | _bfu, | |||
_pos | ) | _bfu.val = _pos; |
Gets the current buffer bit position.
_bfu | The context to fetch the buffer bit position from | |
_pos | The updated value of the buffer bit position |
Referenced by BFU__ffc().
#define _bfu_put_tmp | ( | _bfu, | |||
_tmp | ) | _bfu.cur = _tmp; |
Updates the current temporary buffer.
_bfu | The context to fetch the temporary buffer from | |
_tmp | Returned as the updated value of the temporary holding buffer |
Referenced by BFU__ffc().
#define _bfu_revert | ( | _bfu, | |||
_wrds, | |||||
_position, | |||||
_nwidth, | |||||
_nexp | ) |
Value:
({ \ int val; \ int exp = _bfu_extractR (_bfu, _wrds, _position, _nexp) - 1; \ int nleading = (1 << _nexp) - 1; \ int ntrailing = (_nwidth - nleading > 0) ? _nwidth - nleading : 0; \ int nbits = (exp >= 0) \ ? (exp += ntrailing, val = (1 << exp), exp) \ : (val = 0, exp = ntrailing); \ \ /* printf ("Exp = %2u, Nbits = %2u\n", exp, nbits); */ \ \ /* If any more bits, get them */ \ if (nbits > 0) \ { \ /* printf ("Val = %8.8x -> ", val); */ \ val |= _bfu_extractR (_bfu, _wrds, _position, nbits); \ /* printf ("%8.8x\n", val); */ \ } \ val; \ })
_bfu | The bit field unpacking context | |
_wrds | The source word array | |
_position | The bit position of the left most bit of the field to be extracted in the source array | |
_nwidth | The bit width of the word to be reverted | |
_nexp | The number bits used to store the exponent |
static __inline BFU BFU__bitL | ( | const unsigned int * | wrds, | |
unsigned int | cur, | |||
unsigned int | position | |||
) | [static] |
static __inline BFU BFU__bitR | ( | const unsigned int * | wrds, | |
unsigned int | cur, | |||
unsigned int | position | |||
) | [static] |
static __inline BFU BFU__boolean | ( | const unsigned int * | wrds, | |
unsigned int | cur, | |||
unsigned int | position | |||
) | [static] |
Unpacks the next bit. This is equivalent to a bit extract, but the justification (left or right) is unspecified. Rather the must efficient extraction is used, returning only 0 or non-zero. Use BFU__bitL or BFU__bitR if a specific justification is needed.
0,if | bit was 0 | |
!=0,if | bit was 1 (i.e. non-zero |
wrds | The input word array | |
cur | The current set of bits one is working on | |
position | The current bit position in the output bit field |
static __inline BFU BFU__ffc | ( | const unsigned int * | wrds, | |
unsigned int | cur, | |||
unsigned int | position | |||
) | [static] |
Scans the input bit stream for the first clear bit, this effectively counts the number of set bits.
wrds | The input word array | |
cur | The current 32-bit word | |
position | The current bit position in the output bit field |
References _bfu_put_pos, and _bfu_put_tmp.
static __inline BFU BFU__word | ( | const unsigned int * | wrds, | |
unsigned int | cur, | |||
unsigned int | position | |||
) | [static] |
static __inline BFU BFU__wordL | ( | const unsigned int * | wrds, | |
unsigned int | cur, | |||
unsigned int | position, | |||
unsigned int | width | |||
) | [static] |
Unpacks a left justified bit field from the current position. The width of the bit field must be less than 32 bits.
wrds | The input word array | |
cur | The current set of bits one is working on | |
position | The current bit position in the output bit field | |
width | The width of the field to be extracted |
References BFU__wordR(), and _BFU::val.
static __inline BFU BFU__wordR | ( | const unsigned int * | wrds, | |
unsigned int | cur, | |||
unsigned int | position, | |||
unsigned int | width | |||
) | [static] |
Unpacks a right justified bit field from the current position. The width of the bit field must be less than 32 bits.
wrds | The input word array | |
cur | The current set of bits one is working on | |
position | The current bit position in the output bit field | |
width | The width of the field to be extracted |
References _BFU::cur, and _BFU::val.
Referenced by BFU__wordL().