\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:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=54pt]{BFU_8h__incl}
\end{center}
\end{figure}


This graph shows which files directly or indirectly include this file:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=126pt]{BFU_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Classes}
\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_e2c092f97bc0816eb41d3741f8b8a2e6}{\_\-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_c9c88e7358823510aa34ad447ec1b502}{\_\-bfu\_\-get\_\-tmp}(\_\-bfu)~\_\-bfu.cur
\begin{CompactList}\small\item\em Gets the current temporary buffer. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_0e7bd3a040cbd2717c3957b5cabd4f29}{\_\-bfu\_\-get}(\_\-bfu, \_\-tmp, \_\-pos)
\begin{CompactList}\small\item\em Gets the current temporary buffer and buffer bit position. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_f884be036af51a6f59ab86424285ae85}{\_\-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_0dc85961ae8dc79214ae83b3bdaf2858}{\_\-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_02c55893e9c99d47f393ff9579d891d4}{\_\-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_68569197506916936201aea356c53bf2}{\_\-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_7911e2a20de285183355339ae4837a78}{\_\-bfu\_\-constructW}(\_\-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_68b873b156beea9602cfb37910e34e16}{\_\-bfu\_\-extractBoolean}(\_\-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\_\-extractBL or \_\-bfu\_\-extractBR. Use one of those routine if the justification needs to be specified. \item\end{CompactList}\item 
\#define \hyperlink{BFU_8h_f56d894891f70f8b758654af301255f3}{\_\-bfu\_\-extractBR}(\_\-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_ab903df862f44aac8e9b1edbb5687982}{\_\-bfu\_\-extractBL}(\_\-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_541bc98d9f9825cc8fc7dfd450d6d203}{\_\-bfu\_\-extractL}(\_\-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_cd5032ffb884546de61c52b2816a18c1}{\_\-bfu\_\-extractR}(\_\-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_dfa834913575520de7979fe37ec0142c}{\_\-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_4ea485e1fbf6a487b02d95c3c07d5440}{\_\-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_669620cfd23b2f5e5d361cd64c964c1d}{\_\-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_9efa731a7f64e5e6da9edc0e9cc1578e}{
typedef struct \hyperlink{struct__BFU}{\_\-BFU} \hyperlink{BFU_8h_9efa731a7f64e5e6da9edc0e9cc1578e}{BFU}}
\label{BFU_8h_9efa731a7f64e5e6da9edc0e9cc1578e}

\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_265005120bd79c214ae86673ef1544b6}{BFU\_\-\_\-bitL} (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_1fd56f4890f8c6bc085690303acff620}{BFU\_\-\_\-bitR} (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_c6f930ba0ad57fb6fb420dfca18406ee}{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\_\-\_\-bitL or BFU\_\-\_\-bitR if a specific justification is needed. \item\end{CompactList}\item 
static \_\-\_\-inline \hyperlink{struct__BFU}{BFU} \hyperlink{BFU_8h_5d168b754b816b151f779200a5ad054b}{BFU\_\-\_\-wordR} (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_b6a8dea95e392a7831cd4e4b7a271323}{BFU\_\-\_\-wordL} (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_f0ee34e1462983e8414808bc767a4c41}{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_be855020cb758a9783b8a0e717182fe5}{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_68569197506916936201aea356c53bf2}{
\index{BFU.h@{BFU.h}!_bfu_construct@{\_\-bfu\_\-construct}}
\index{_bfu_construct@{\_\-bfu\_\-construct}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-construct(\_\-bfu, \_\-s, \_\-alignment, \_\-src, \_\-boff)}}
\label{BFU_8h_68569197506916936201aea356c53bf2}


\textbf{Value:}

\begin{Code}\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}
\end{Code}
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_7911e2a20de285183355339ae4837a78}{
\index{BFU.h@{BFU.h}!_bfu_constructW@{\_\-bfu\_\-constructW}}
\index{_bfu_constructW@{\_\-bfu\_\-constructW}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-constructW(\_\-bfu, \_\-src, \_\-boff)}}
\label{BFU_8h_7911e2a20de285183355339ae4837a78}


\textbf{Value:}

\begin{Code}\begin{verbatim}_bfu.cur = _src[_boff >> 5];                                           \
    _bfu.val = _boff                                                       \
\end{verbatim}
\end{Code}
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_4ea485e1fbf6a487b02d95c3c07d5440}{
\index{BFU.h@{BFU.h}!_bfu_count1s@{\_\-bfu\_\-count1s}}
\index{_bfu_count1s@{\_\-bfu\_\-count1s}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-count1s(\_\-bfu, \_\-wrds, \_\-position)}}
\label{BFU_8h_4ea485e1fbf6a487b02d95c3c07d5440}


\textbf{Value:}

\begin{Code}\begin{verbatim}(_bfu      = BFU__ffc (_wrds, _bfu_get_tmp(bfu), _position),       \
         _position += (_bfu.val -= _position),                             \
         _bfu.val - 1)
\end{verbatim}
\end{Code}
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_dfa834913575520de7979fe37ec0142c}{
\index{BFU.h@{BFU.h}!_bfu_extract32@{\_\-bfu\_\-extract32}}
\index{_bfu_extract32@{\_\-bfu\_\-extract32}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extract32(\_\-bfu, \_\-wrds, \_\-position)}}
\label{BFU_8h_dfa834913575520de7979fe37ec0142c}


\textbf{Value:}

\begin{Code}\begin{verbatim}(_bfu       = BFU__word (_wrds, _bfu.cur, _position),               \
        _position += 32,                                                   \
        _bfu.val)
\end{verbatim}
\end{Code}
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_ab903df862f44aac8e9b1edbb5687982}{
\index{BFU.h@{BFU.h}!_bfu_extractBL@{\_\-bfu\_\-extractBL}}
\index{_bfu_extractBL@{\_\-bfu\_\-extractBL}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extractBL(\_\-bfu, \_\-wrds, \_\-position)}}
\label{BFU_8h_ab903df862f44aac8e9b1edbb5687982}


\textbf{Value:}

\begin{Code}\begin{verbatim}(_bfu       = BFU__bitL (_wrds, _bfu.cur, _position),               \
        _position += 1,                                                    \
        _bfu.val)
\end{verbatim}
\end{Code}
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_68b873b156beea9602cfb37910e34e16}{
\index{BFU.h@{BFU.h}!_bfu_extractBoolean@{\_\-bfu\_\-extractBoolean}}
\index{_bfu_extractBoolean@{\_\-bfu\_\-extractBoolean}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extractBoolean(\_\-bfu, \_\-wrds, \_\-position)}}
\label{BFU_8h_68b873b156beea9602cfb37910e34e16}


\textbf{Value:}

\begin{Code}\begin{verbatim}(_bfu       = BFU__boolean (_wrds, _bfu.cur, _position),            \
        _position += 1,                                                    \
        _bfu.val)
\end{verbatim}
\end{Code}
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. 

\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_f56d894891f70f8b758654af301255f3}{
\index{BFU.h@{BFU.h}!_bfu_extractBR@{\_\-bfu\_\-extractBR}}
\index{_bfu_extractBR@{\_\-bfu\_\-extractBR}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extractBR(\_\-bfu, \_\-wrds, \_\-position)}}
\label{BFU_8h_f56d894891f70f8b758654af301255f3}


\textbf{Value:}

\begin{Code}\begin{verbatim}(_bfu       = BFU__bitR (_wrds, _bfu.cur, _position),               \
        _position += 1,                                                    \
        _bfu.val)
\end{verbatim}
\end{Code}
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_541bc98d9f9825cc8fc7dfd450d6d203}{
\index{BFU.h@{BFU.h}!_bfu_extractL@{\_\-bfu\_\-extractL}}
\index{_bfu_extractL@{\_\-bfu\_\-extractL}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extractL(\_\-bfu, \_\-wrds, \_\-position, \_\-width)}}
\label{BFU_8h_541bc98d9f9825cc8fc7dfd450d6d203}


\textbf{Value:}

\begin{Code}\begin{verbatim}(_bfu       = BFU__wordL (_wrds, _bfu.cur, _position, _width),     \
        _position += _width,                                              \
        _bfu.val)
\end{verbatim}
\end{Code}
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_cd5032ffb884546de61c52b2816a18c1}{
\index{BFU.h@{BFU.h}!_bfu_extractR@{\_\-bfu\_\-extractR}}
\index{_bfu_extractR@{\_\-bfu\_\-extractR}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-extractR(\_\-bfu, \_\-wrds, \_\-position, \_\-width)}}
\label{BFU_8h_cd5032ffb884546de61c52b2816a18c1}


\textbf{Value:}

\begin{Code}\begin{verbatim}(_bfu       = BFU__wordR (_wrds, _bfu.cur, _position, _width),     \
        _position += _width,                                              \
        _bfu.val)
\end{verbatim}
\end{Code}
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_0e7bd3a040cbd2717c3957b5cabd4f29}{
\index{BFU.h@{BFU.h}!_bfu_get@{\_\-bfu\_\-get}}
\index{_bfu_get@{\_\-bfu\_\-get}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-get(\_\-bfu, \_\-tmp, \_\-pos)}}
\label{BFU_8h_0e7bd3a040cbd2717c3957b5cabd4f29}


\textbf{Value:}

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

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-bfu}]The context to fetch the temporary buffer from \item[{\em \_\-tmp}]Returned as the value of the temporary holding buffer \item[{\em \_\-pos}]Returned as the value of the buffer bit position \end{description}
\end{Desc}
\hypertarget{BFU_8h_e2c092f97bc0816eb41d3741f8b8a2e6}{
\index{BFU.h@{BFU.h}!_bfu_get_pos@{\_\-bfu\_\-get\_\-pos}}
\index{_bfu_get_pos@{\_\-bfu\_\-get\_\-pos}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-get\_\-pos(\_\-bfu)~\_\-bfu.val}}
\label{BFU_8h_e2c092f97bc0816eb41d3741f8b8a2e6}


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_c9c88e7358823510aa34ad447ec1b502}{
\index{BFU.h@{BFU.h}!_bfu_get_tmp@{\_\-bfu\_\-get\_\-tmp}}
\index{_bfu_get_tmp@{\_\-bfu\_\-get\_\-tmp}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-get\_\-tmp(\_\-bfu)~\_\-bfu.cur}}
\label{BFU_8h_c9c88e7358823510aa34ad447ec1b502}


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_02c55893e9c99d47f393ff9579d891d4}{
\index{BFU.h@{BFU.h}!_bfu_put@{\_\-bfu\_\-put}}
\index{_bfu_put@{\_\-bfu\_\-put}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-put(\_\-bfu, \_\-tmp, \_\-pos)}}
\label{BFU_8h_02c55893e9c99d47f393ff9579d891d4}


\textbf{Value:}

\begin{Code}\begin{verbatim}_bfu.cur = _tmp;           \
                                       _bfu.val = _pos;
\end{verbatim}
\end{Code}
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_0dc85961ae8dc79214ae83b3bdaf2858}{
\index{BFU.h@{BFU.h}!_bfu_put_pos@{\_\-bfu\_\-put\_\-pos}}
\index{_bfu_put_pos@{\_\-bfu\_\-put\_\-pos}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-put\_\-pos(\_\-bfu, \_\-pos)~\_\-bfu.val = \_\-pos;}}
\label{BFU_8h_0dc85961ae8dc79214ae83b3bdaf2858}


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_f884be036af51a6f59ab86424285ae85}{
\index{BFU.h@{BFU.h}!_bfu_put_tmp@{\_\-bfu\_\-put\_\-tmp}}
\index{_bfu_put_tmp@{\_\-bfu\_\-put\_\-tmp}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-put\_\-tmp(\_\-bfu, \_\-tmp)~\_\-bfu.cur = \_\-tmp;}}
\label{BFU_8h_f884be036af51a6f59ab86424285ae85}


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_669620cfd23b2f5e5d361cd64c964c1d}{
\index{BFU.h@{BFU.h}!_bfu_revert@{\_\-bfu\_\-revert}}
\index{_bfu_revert@{\_\-bfu\_\-revert}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-bfu\_\-revert(\_\-bfu, \_\-wrds, \_\-position, \_\-nwidth, \_\-nexp)}}
\label{BFU_8h_669620cfd23b2f5e5d361cd64c964c1d}


\textbf{Value:}

\begin{Code}\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}
\end{Code}
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_265005120bd79c214ae86673ef1544b6}{
\index{BFU.h@{BFU.h}!BFU__bitL@{BFU\_\-\_\-bitL}}
\index{BFU__bitL@{BFU\_\-\_\-bitL}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline {\bf BFU} BFU\_\-\_\-bitL (const unsigned int $\ast$ {\em wrds}, unsigned int {\em cur}, unsigned int {\em position})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFU_8h_265005120bd79c214ae86673ef1544b6}


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_1fd56f4890f8c6bc085690303acff620}{
\index{BFU.h@{BFU.h}!BFU__bitR@{BFU\_\-\_\-bitR}}
\index{BFU__bitR@{BFU\_\-\_\-bitR}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline {\bf BFU} BFU\_\-\_\-bitR (const unsigned int $\ast$ {\em wrds}, unsigned int {\em cur}, unsigned int {\em position})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFU_8h_1fd56f4890f8c6bc085690303acff620}


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_c6f930ba0ad57fb6fb420dfca18406ee}{
\index{BFU.h@{BFU.h}!BFU__boolean@{BFU\_\-\_\-boolean}}
\index{BFU__boolean@{BFU\_\-\_\-boolean}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline {\bf 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_c6f930ba0ad57fb6fb420dfca18406ee}


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. 

\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_be855020cb758a9783b8a0e717182fe5}{
\index{BFU.h@{BFU.h}!BFU__ffc@{BFU\_\-\_\-ffc}}
\index{BFU__ffc@{BFU\_\-\_\-ffc}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline {\bf 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_be855020cb758a9783b8a0e717182fe5}


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_f0ee34e1462983e8414808bc767a4c41}{
\index{BFU.h@{BFU.h}!BFU__word@{BFU\_\-\_\-word}}
\index{BFU__word@{BFU\_\-\_\-word}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline {\bf 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_f0ee34e1462983e8414808bc767a4c41}


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_b6a8dea95e392a7831cd4e4b7a271323}{
\index{BFU.h@{BFU.h}!BFU__wordL@{BFU\_\-\_\-wordL}}
\index{BFU__wordL@{BFU\_\-\_\-wordL}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline {\bf BFU} BFU\_\-\_\-wordL (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_b6a8dea95e392a7831cd4e4b7a271323}


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_5d168b754b816b151f779200a5ad054b}{
\index{BFU.h@{BFU.h}!BFU__wordR@{BFU\_\-\_\-wordR}}
\index{BFU__wordR@{BFU\_\-\_\-wordR}!BFU.h@{BFU.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline {\bf BFU} BFU\_\-\_\-wordR (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_5d168b754b816b151f779200a5ad054b}


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}
