\hypertarget{BFU_8h}{
\section{BFU.h File Reference}
\label{BFU_8h}\index{BFU.h@{BFU.h}}
}
Bit Field Unpack Routines. 

{\tt \#include \char`\"{}PBS/FFS.ih\char`\"{}}\par


Include dependency graph for BFU.h:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=97pt]{BFU_8h__incl}
\end{center}
\end{figure}


This graph shows which files directly or indirectly include this file:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=89pt]{BFU_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__BFU}{\_\-BFU}
\begin{CompactList}\small\item\em The return value of the BFU routines, capturing the current 32-bit word that is being used as a source and the extracted value. \item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define \hyperlink{BFU_8h_a0}{\_\-bfu\_\-get\_\-pos}(\_\-bfu)~\_\-bfu.val
\begin{CompactList}\small\item\em Gets the current buffer bit position. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a1}{\_\-bfu\_\-get\_\-tmp}(\_\-bfu)~\_\-bfu.cur
\begin{CompactList}\small\item\em Gets the current temporary buffer. \item\end{CompactList}\item 
\#define {\bf \_\-bfu\_\-get}(\_\-bfu, \_\-tmp, \_\-pos)
\item 
\#define \hyperlink{BFU_8h_a3}{\_\-bfu\_\-put\_\-tmp}(\_\-bfu, \_\-tmp)~\_\-bfu.cur = \_\-tmp;
\begin{CompactList}\small\item\em Updates the current temporary buffer. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a4}{\_\-bfu\_\-put\_\-pos}(\_\-bfu, \_\-pos)~\_\-bfu.val = \_\-pos;
\begin{CompactList}\small\item\em Gets the current buffer bit position. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a5}{\_\-bfu\_\-put}(\_\-bfu, \_\-tmp, \_\-pos)
\begin{CompactList}\small\item\em Updates the current temporary buffer and buffer bit position. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a6}{\_\-bfu\_\-construct}(\_\-bfu, \_\-s, \_\-alignment, \_\-src, \_\-boff)
\begin{CompactList}\small\item\em Constructs a BFU from an arbitrarily aligned source buffer pointer, and a bit offset {\em \_\-boff\/}. Also returns a 32-bit aligned pointer to be used with \_\-bfu\_\-extract. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a7}{\_\-bfu\_\-construct\-W}(\_\-bfu, \_\-src, \_\-boff)
\begin{CompactList}\small\item\em Constructs a BFU from an 32-bit (word) aligned source buffer pointer and a bit offset {\em \_\-boff\/}. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a8}{\_\-bfu\_\-extract\-Boolean}(\_\-bfu, \_\-wrds, \_\-position)
\begin{CompactList}\small\item\em Extracts the next bit, returning it as a boolean value. The justification is unspecfied. The implementation is the most efficient of \_\-bfu\_\-extract\-BL or \_\-bfu\_\-extract\-BR. Use one of those routine if the justification needs to be specified. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a9}{\_\-bfu\_\-extract\-BR}(\_\-bfu, \_\-wrds, \_\-position)
\begin{CompactList}\small\item\em Extracts the right justified bit from the current position. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a10}{\_\-bfu\_\-extract\-BL}(\_\-bfu, \_\-wrds, \_\-position)
\begin{CompactList}\small\item\em Extracts the left justified bit from the current position. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a11}{\_\-bfu\_\-extract\-L}(\_\-bfu, \_\-wrds, \_\-position, \_\-width)
\begin{CompactList}\small\item\em Extracts a left justified value from the current position. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a12}{\_\-bfu\_\-extract\-R}(\_\-bfu, \_\-wrds, \_\-position, \_\-width)
\begin{CompactList}\small\item\em Extracts a right justified value from the current position. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a13}{\_\-bfu\_\-extract32}(\_\-bfu, \_\-wrds, \_\-position)
\begin{CompactList}\small\item\em Extracts 32 bits from the current position. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a14}{\_\-bfu\_\-count1s}(\_\-bfu, \_\-wrds, \_\-position)
\begin{CompactList}\small\item\em Counts the number of 1s till the first clear bit. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_a15}{\_\-bfu\_\-revert}(\_\-bfu, \_\-wrds, \_\-position, \_\-nwidth, \_\-nexp)
\begin{CompactList}\small\item\em Counts the number of 1s till the first clear bit. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{BFU_8h_a16}{
typedef \hyperlink{struct__BFU}{\_\-BFU} \hyperlink{BFU_8h_a16}{BFU}}
\label{BFU_8h_a16}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__BFU}{\_\-BFU}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} \hyperlink{BFU_8h_a17}{BFU\_\-\_\-bit\-L} (const unsigned int $\ast$wrds, unsigned int cur, unsigned int position)
\begin{CompactList}\small\item\em Unpacks the left justified bit from the current position. \item\end{CompactList}\item 
static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} \hyperlink{BFU_8h_a18}{BFU\_\-\_\-bit\-R} (const unsigned int $\ast$wrds, unsigned int cur, unsigned int position)
\begin{CompactList}\small\item\em Unpacks the right justified bit from the current position. \item\end{CompactList}\item 
static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} \hyperlink{BFU_8h_a19}{BFU\_\-\_\-boolean} (const unsigned int $\ast$wrds, unsigned int cur, unsigned int position)
\begin{CompactList}\small\item\em 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\_\-\_\-bit\-L or BFU\_\-\_\-bit\-R if a specific justification is needed. \item\end{CompactList}\item 
static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} \hyperlink{BFU_8h_a20}{BFU\_\-\_\-word\-R} (const unsigned int $\ast$wrds, unsigned int cur, unsigned int position, unsigned int width)
\begin{CompactList}\small\item\em Unpacks a right justified bit field from the current position. The width of the bit field must be less than 32 bits. \item\end{CompactList}\item 
static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} \hyperlink{BFU_8h_a21}{BFU\_\-\_\-word\-L} (const unsigned int $\ast$wrds, unsigned int cur, unsigned int position, unsigned int width)
\begin{CompactList}\small\item\em Unpacks a left justified bit field from the current position. The width of the bit field must be less than 32 bits. \item\end{CompactList}\item 
static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} \hyperlink{BFU_8h_a22}{BFU\_\-\_\-word} (const unsigned int $\ast$wrds, unsigned int cur, unsigned int position)
\begin{CompactList}\small\item\em Unpacks exactly 32 bits from the current position. \item\end{CompactList}\item 
static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} \hyperlink{BFU_8h_a23}{BFU\_\-\_\-ffc} (const unsigned int $\ast$wrds, unsigned int cur, unsigned int position)
\begin{CompactList}\small\item\em Scans the input bit stream for the first clear bit, this effectively counts the number of set bits. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Bit Field Unpack Routines. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}
Inline functions to (left justified) unpack bit fields.

\subsection{Define Documentation}
\hypertarget{BFU_8h_a6}{
\index{BFU.h@{BFU.h}!_bfu_construct@{\_\-bfu\_\-construct}}
\index{_bfu_construct@{\_\-bfu\_\-construct}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-construct]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-construct(\_\-bfu, \_\-s, \_\-alignment, \_\-src, \_\-boff)}}
\label{BFU_8h_a6}


{\bf Value:}

\footnotesize\begin{verbatim}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 = ((int)_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 *)((int)_s & ~0x3);                           \
                                                                           \
    /* Extract the first word */                                           \
    _bfu.cur = _s[_boff >> 5];                                             \
    _bfu.val = boff;                                                       \
                                                                           \
} while (0)
\end{verbatim}\normalsize 
Constructs a BFU from an arbitrarily aligned source buffer pointer, and a bit offset {\em \_\-boff\/}. Also returns a 32-bit aligned pointer to be used with \_\-bfu\_\-extract. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The BFU structure to populate \item[{\em \_\-s}]Returned as a 32-bit aligned version of {\em \_\-src\/} \item[{\em \_\-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 {\em \_\-src\/}. \item[{\em \_\-src}]The source buffer pointer \item[{\em \_\-boff}]The original bit offset, returned as the adjusted offset to compensate for any possible alignment to {\em \_\-s\/} \end{description}
\end{Desc}
\hypertarget{BFU_8h_a7}{
\index{BFU.h@{BFU.h}!_bfu_constructW@{\_\-bfu\_\-constructW}}
\index{_bfu_constructW@{\_\-bfu\_\-constructW}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-constructW]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-construct\-W(\_\-bfu, \_\-src, \_\-boff)}}
\label{BFU_8h_a7}


{\bf Value:}

\footnotesize\begin{verbatim}_bfu.cur = _src[_boff >> 5];                                           \
    _bfu.val = _boff                                                       \
\end{verbatim}\normalsize 
Constructs a BFU from an 32-bit (word) aligned source buffer pointer and a bit offset {\em \_\-boff\/}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The BFU structure to populate \item[{\em \_\-src}]The source buffer pointer \item[{\em \_\-boff}]The original bit offset, returned as the adjusted offset to compensate for any possible alignment to {\em \_\-s\/} \end{description}
\end{Desc}
\hypertarget{BFU_8h_a14}{
\index{BFU.h@{BFU.h}!_bfu_count1s@{\_\-bfu\_\-count1s}}
\index{_bfu_count1s@{\_\-bfu\_\-count1s}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-count1s]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-count1s(\_\-bfu, \_\-wrds, \_\-position)}}
\label{BFU_8h_a14}


{\bf Value:}

\footnotesize\begin{verbatim}(_bfu      = BFU__ffc (_wrds, _bfu_get_tmp(bfu), _position),       \
         _position += (_bfu.val -= _position),                             \
         _bfu.val - 1)
\end{verbatim}\normalsize 
Counts the number of 1s till the first clear bit. 

\begin{Desc}
\item[Returns:]The number of bits to the first clear bit\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The bit field unpacking context \item[{\em \_\-wrds}]The source word array \item[{\em \_\-position}]The bit position of the left most bit of the field to be extracted in the source array\end{description}
\end{Desc}
\hypertarget{BFU_8h_a13}{
\index{BFU.h@{BFU.h}!_bfu_extract32@{\_\-bfu\_\-extract32}}
\index{_bfu_extract32@{\_\-bfu\_\-extract32}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-extract32]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extract32(\_\-bfu, \_\-wrds, \_\-position)}}
\label{BFU_8h_a13}


{\bf Value:}

\footnotesize\begin{verbatim}(_bfu       = BFU__word (_wrds, _bfu.cur, _position),               \
        _position += 32,                                                   \
        _bfu.val)
\end{verbatim}\normalsize 
Extracts 32 bits from the current position. 

\begin{Desc}
\item[Returns:]The extract value\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The bit field unpacking context \item[{\em \_\-wrds}]The source word array \item[{\em \_\-position}]The bit position of the left most bit of the field to be extracted in the source array\end{description}
\end{Desc}
\hypertarget{BFU_8h_a10}{
\index{BFU.h@{BFU.h}!_bfu_extractBL@{\_\-bfu\_\-extractBL}}
\index{_bfu_extractBL@{\_\-bfu\_\-extractBL}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-extractBL]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extract\-BL(\_\-bfu, \_\-wrds, \_\-position)}}
\label{BFU_8h_a10}


{\bf Value:}

\footnotesize\begin{verbatim}(_bfu       = BFU__bitL (_wrds, _bfu.cur, _position),               \
        _position += 1,                                                    \
        _bfu.val)
\end{verbatim}\normalsize 
Extracts the left justified bit from the current position. 

\begin{Desc}
\item[Returns:]The left justified bit\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The bit field unpacking context \item[{\em \_\-wrds}]The source word array \item[{\em \_\-position}]The bit position of the bit to be extracted from the source array\end{description}
\end{Desc}
\hypertarget{BFU_8h_a8}{
\index{BFU.h@{BFU.h}!_bfu_extractBoolean@{\_\-bfu\_\-extractBoolean}}
\index{_bfu_extractBoolean@{\_\-bfu\_\-extractBoolean}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-extractBoolean]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extract\-Boolean(\_\-bfu, \_\-wrds, \_\-position)}}
\label{BFU_8h_a8}


{\bf Value:}

\footnotesize\begin{verbatim}(_bfu       = BFU__boolean (_wrds, _bfu.cur, _position),            \
        _position += 1,                                                    \
        _bfu.val)
\end{verbatim}\normalsize 
Extracts the next bit, returning it as a boolean value. The justification is unspecfied. The implementation is the most efficient of \_\-bfu\_\-extract\-BL or \_\-bfu\_\-extract\-BR. Use one of those routine if the justification needs to be specified. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0,if}]the bit was 0 \item[{\em !=0,if}]the bit was 1\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The bit field unpacking context \item[{\em \_\-wrds}]The source word array \item[{\em \_\-position}]The bit position of the bit to be extracted from the source array\end{description}
\end{Desc}
\hypertarget{BFU_8h_a9}{
\index{BFU.h@{BFU.h}!_bfu_extractBR@{\_\-bfu\_\-extractBR}}
\index{_bfu_extractBR@{\_\-bfu\_\-extractBR}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-extractBR]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extract\-BR(\_\-bfu, \_\-wrds, \_\-position)}}
\label{BFU_8h_a9}


{\bf Value:}

\footnotesize\begin{verbatim}(_bfu       = BFU__bitR (_wrds, _bfu.cur, _position),               \
        _position += 1,                                                    \
        _bfu.val)
\end{verbatim}\normalsize 
Extracts the right justified bit from the current position. 

\begin{Desc}
\item[Returns:]The right justified bit\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The bit field unpacking context \item[{\em \_\-wrds}]The source word array \item[{\em \_\-position}]The bit position of the bit to be extracted from the source array\end{description}
\end{Desc}
\hypertarget{BFU_8h_a11}{
\index{BFU.h@{BFU.h}!_bfu_extractL@{\_\-bfu\_\-extractL}}
\index{_bfu_extractL@{\_\-bfu\_\-extractL}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-extractL]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extract\-L(\_\-bfu, \_\-wrds, \_\-position, \_\-width)}}
\label{BFU_8h_a11}


{\bf Value:}

\footnotesize\begin{verbatim}(_bfu       = BFU__wordL (_wrds, _bfu.cur, _position, _width),     \
        _position += _width,                                              \
        _bfu.val)
\end{verbatim}\normalsize 
Extracts a left justified value from the current position. 

\begin{Desc}
\item[Returns:]The left justified value\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The bit field unpacking context \item[{\em \_\-wrds}]The source word array \item[{\em \_\-position}]The bit position of the left most bit of the field to be extracted in the source array \item[{\em \_\-width}]The width of the field to be extracted; must be $<$ 32\end{description}
\end{Desc}
\hypertarget{BFU_8h_a12}{
\index{BFU.h@{BFU.h}!_bfu_extractR@{\_\-bfu\_\-extractR}}
\index{_bfu_extractR@{\_\-bfu\_\-extractR}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-extractR]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extract\-R(\_\-bfu, \_\-wrds, \_\-position, \_\-width)}}
\label{BFU_8h_a12}


{\bf Value:}

\footnotesize\begin{verbatim}(_bfu       = BFU__wordR (_wrds, _bfu.cur, _position, _width),     \
        _position += _width,                                              \
        _bfu.val)
\end{verbatim}\normalsize 
Extracts a right justified value from the current position. 

\begin{Desc}
\item[Returns:]The right justified value\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The bit field unpacking context \item[{\em \_\-wrds}]The source word array \item[{\em \_\-position}]The bit position of the left most bit of the field to be extracted in the source array \item[{\em \_\-width}]The width of the field to be extracted; must be $<$ 32\end{description}
\end{Desc}
\hypertarget{BFU_8h_a2}{
\index{BFU.h@{BFU.h}!_bfu_get@{\_\-bfu\_\-get}}
\index{_bfu_get@{\_\-bfu\_\-get}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-get]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-get(\_\-bfu, \_\-tmp, \_\-pos)}}
\label{BFU_8h_a2}


{\bf Value:}

\footnotesize\begin{verbatim}_tmp = _bfu.cur;           \
                      _pos = _bfu.val;
\end{verbatim}\normalsize 
\hypertarget{BFU_8h_a0}{
\index{BFU.h@{BFU.h}!_bfu_get_pos@{\_\-bfu\_\-get\_\-pos}}
\index{_bfu_get_pos@{\_\-bfu\_\-get\_\-pos}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-get\_\-pos]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-get\_\-pos(\_\-bfu)~\_\-bfu.val}}
\label{BFU_8h_a0}


Gets the current buffer bit position. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em The}]value of the current buffer bit position \end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The context to fetch the buffer bit position from\end{description}
\end{Desc}
\hypertarget{BFU_8h_a1}{
\index{BFU.h@{BFU.h}!_bfu_get_tmp@{\_\-bfu\_\-get\_\-tmp}}
\index{_bfu_get_tmp@{\_\-bfu\_\-get\_\-tmp}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-get\_\-tmp]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-get\_\-tmp(\_\-bfu)~\_\-bfu.cur}}
\label{BFU_8h_a1}


Gets the current temporary buffer. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em The}]value of the temporary buffer \end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The context to fetch the temporary buffer from\end{description}
\end{Desc}
\hypertarget{BFU_8h_a5}{
\index{BFU.h@{BFU.h}!_bfu_put@{\_\-bfu\_\-put}}
\index{_bfu_put@{\_\-bfu\_\-put}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-put]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-put(\_\-bfu, \_\-tmp, \_\-pos)}}
\label{BFU_8h_a5}


{\bf Value:}

\footnotesize\begin{verbatim}_bfu.cur = _tmp;           \
                                       _bfu.val = _pos;
\end{verbatim}\normalsize 
Updates the current temporary buffer and buffer bit position. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The context to update \item[{\em \_\-tmp}]The updated value of the temporary holding buffer \item[{\em \_\-pos}]The updated value of the buffer bit position\end{description}
\end{Desc}
\hypertarget{BFU_8h_a4}{
\index{BFU.h@{BFU.h}!_bfu_put_pos@{\_\-bfu\_\-put\_\-pos}}
\index{_bfu_put_pos@{\_\-bfu\_\-put\_\-pos}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-put\_\-pos]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-put\_\-pos(\_\-bfu, \_\-pos)~\_\-bfu.val = \_\-pos;}}
\label{BFU_8h_a4}


Gets the current buffer bit position. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The context to fetch the buffer bit position from \item[{\em \_\-pos}]The updated value of the buffer bit position\end{description}
\end{Desc}
\hypertarget{BFU_8h_a3}{
\index{BFU.h@{BFU.h}!_bfu_put_tmp@{\_\-bfu\_\-put\_\-tmp}}
\index{_bfu_put_tmp@{\_\-bfu\_\-put\_\-tmp}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-put\_\-tmp]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-put\_\-tmp(\_\-bfu, \_\-tmp)~\_\-bfu.cur = \_\-tmp;}}
\label{BFU_8h_a3}


Updates the current temporary buffer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The context to fetch the temporary buffer from \item[{\em \_\-tmp}]Returned as the updated value of the temporary holding buffer\end{description}
\end{Desc}
\hypertarget{BFU_8h_a15}{
\index{BFU.h@{BFU.h}!_bfu_revert@{\_\-bfu\_\-revert}}
\index{_bfu_revert@{\_\-bfu\_\-revert}!BFU.h@{BFU.h}}
\subsubsection[\_\-bfu\_\-revert]{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-revert(\_\-bfu, \_\-wrds, \_\-position, \_\-nwidth, \_\-nexp)}}
\label{BFU_8h_a15}


{\bf Value:}

\footnotesize\begin{verbatim}({                                                                         \
   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;                                                                    \
})
\end{verbatim}\normalsize 
Counts the number of 1s till the first clear bit. 

\begin{Desc}
\item[Returns:]The number of bits to the first clear bit\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The bit field unpacking context \item[{\em \_\-wrds}]The source word array \item[{\em \_\-position}]The bit position of the left most bit of the field to be extracted in the source array \item[{\em \_\-nwidth}]The bit width of the word to be reverted \item[{\em \_\-nexp}]The number bits used to store the exponent\end{description}
\end{Desc}
\begin{Desc}
\item[Warning:]This macro uses a GCC enhancement to the preprocessor and is likely not portable.\end{Desc}


\subsection{Function Documentation}
\hypertarget{BFU_8h_a17}{
\index{BFU.h@{BFU.h}!BFU__bitL@{BFU\_\-\_\-bitL}}
\index{BFU__bitL@{BFU\_\-\_\-bitL}!BFU.h@{BFU.h}}
\subsubsection[BFU\_\-\_\-bitL]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} BFU\_\-\_\-bit\-L (const unsigned int $\ast$ {\em wrds}, unsigned int {\em cur}, unsigned int {\em position})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFU_8h_a17}


Unpacks the left justified bit from the current position. 

\begin{Desc}
\item[Returns:]The extracted bit, right justified\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wrds}]The input word array \item[{\em cur}]The current set of bits one is working on \item[{\em position}]The current bit position in the output bit field\end{description}
\end{Desc}
\hypertarget{BFU_8h_a18}{
\index{BFU.h@{BFU.h}!BFU__bitR@{BFU\_\-\_\-bitR}}
\index{BFU__bitR@{BFU\_\-\_\-bitR}!BFU.h@{BFU.h}}
\subsubsection[BFU\_\-\_\-bitR]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} BFU\_\-\_\-bit\-R (const unsigned int $\ast$ {\em wrds}, unsigned int {\em cur}, unsigned int {\em position})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFU_8h_a18}


Unpacks the right justified bit from the current position. 

\begin{Desc}
\item[Returns:]The extracted bit, right justified\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wrds}]The input word array \item[{\em cur}]The current set of bits one is working on \item[{\em position}]The current bit position in the output bit field\end{description}
\end{Desc}
\hypertarget{BFU_8h_a19}{
\index{BFU.h@{BFU.h}!BFU__boolean@{BFU\_\-\_\-boolean}}
\index{BFU__boolean@{BFU\_\-\_\-boolean}!BFU.h@{BFU.h}}
\subsubsection[BFU\_\-\_\-boolean]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} BFU\_\-\_\-boolean (const unsigned int $\ast$ {\em wrds}, unsigned int {\em cur}, unsigned int {\em position})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFU_8h_a19}


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\_\-\_\-bit\-L or BFU\_\-\_\-bit\-R if a specific justification is needed. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0,if}]bit was 0 \item[{\em !=0,if}]bit was 1 (i.e. non-zero\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wrds}]The input word array \item[{\em cur}]The current set of bits one is working on \item[{\em position}]The current bit position in the output bit field\end{description}
\end{Desc}
\hypertarget{BFU_8h_a23}{
\index{BFU.h@{BFU.h}!BFU__ffc@{BFU\_\-\_\-ffc}}
\index{BFU__ffc@{BFU\_\-\_\-ffc}!BFU.h@{BFU.h}}
\subsubsection[BFU\_\-\_\-ffc]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} BFU\_\-\_\-ffc (const unsigned int $\ast$ {\em wrds}, unsigned int {\em cur}, unsigned int {\em position})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFU_8h_a23}


Scans the input bit stream for the first clear bit, this effectively counts the number of set bits. 

\begin{Desc}
\item[Returns:]The updated BFU past the first clear bit.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wrds}]The input word array \item[{\em cur}]The current 32-bit word \item[{\em position}]The current bit position in the output bit field\end{description}
\end{Desc}
\hypertarget{BFU_8h_a22}{
\index{BFU.h@{BFU.h}!BFU__word@{BFU\_\-\_\-word}}
\index{BFU__word@{BFU\_\-\_\-word}!BFU.h@{BFU.h}}
\subsubsection[BFU\_\-\_\-word]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} BFU\_\-\_\-word (const unsigned int $\ast$ {\em wrds}, unsigned int {\em cur}, unsigned int {\em position})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFU_8h_a22}


Unpacks exactly 32 bits from the current position. 

\begin{Desc}
\item[Returns:]The extracted field, right justified\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wrds}]The input word array \item[{\em cur}]The current set of bits one is working on \item[{\em position}]The current bit position in the output bit field\end{description}
\end{Desc}
\hypertarget{BFU_8h_a21}{
\index{BFU.h@{BFU.h}!BFU__wordL@{BFU\_\-\_\-wordL}}
\index{BFU__wordL@{BFU\_\-\_\-wordL}!BFU.h@{BFU.h}}
\subsubsection[BFU\_\-\_\-wordL]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} BFU\_\-\_\-word\-L (const unsigned int $\ast$ {\em wrds}, unsigned int {\em cur}, unsigned int {\em position}, unsigned int {\em width})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFU_8h_a21}


Unpacks a left justified bit field from the current position. The width of the bit field must be less than 32 bits. 

\begin{Desc}
\item[Returns:]The extracted field, left justified + the current buffered word\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wrds}]The input word array \item[{\em cur}]The current set of bits one is working on \item[{\em position}]The current bit position in the output bit field \item[{\em width}]The width of the field to be extracted\end{description}
\end{Desc}
\hypertarget{BFU_8h_a20}{
\index{BFU.h@{BFU.h}!BFU__wordR@{BFU\_\-\_\-wordR}}
\index{BFU__wordR@{BFU\_\-\_\-wordR}!BFU.h@{BFU.h}}
\subsubsection[BFU\_\-\_\-wordR]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} BFU\_\-\_\-word\-R (const unsigned int $\ast$ {\em wrds}, unsigned int {\em cur}, unsigned int {\em position}, unsigned int {\em width})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFU_8h_a20}


Unpacks a right justified bit field from the current position. The width of the bit field must be less than 32 bits. 

\begin{Desc}
\item[Returns:]The extracted field, right justified\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wrds}]The input word array \item[{\em cur}]The current set of bits one is working on \item[{\em position}]The current bit position in the output bit field \item[{\em width}]The width of the field to be extracted\end{description}
\end{Desc}
