\doxysection{Bit vectors}
\label{group__bitvec}\index{Bit vectors@{Bit vectors}}


Osmocom bit vector abstraction utility routines.  


\doxysubsection*{Files}
\begin{DoxyCompactItemize}
\item 
file \textbf{ bitvec.\+h}
\item 
file \textbf{ bitvec.\+c}
\end{DoxyCompactItemize}
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ bitvec}
\begin{DoxyCompactList}\small\item\em structure describing a bit vector \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ BITNUM\+\_\+\+FROM\+\_\+\+COMP}(byte,  bit)~((byte$\ast$8)+bit)
\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ bit\+\_\+value} \{ \newline
\textbf{ ZERO} = 0
, \newline
\textbf{ ONE} = 1
, \newline
\textbf{ L} = 2
, \newline
\textbf{ H} = 3
 \}
\begin{DoxyCompactList}\small\item\em A single GSM bit. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ bitvec\+\_\+add\+\_\+range1024} (struct \textbf{ bitvec} $\ast$bv, const struct \textbf{ gsm48\+\_\+range\+\_\+1024} $\ast$r)
\item 
enum \textbf{ bit\+\_\+value} \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos} (const struct \textbf{ bitvec} $\ast$bv, unsigned int bitnr)
\begin{DoxyCompactList}\small\item\em check if the bit is 0 or 1 for a given position inside a bitvec \end{DoxyCompactList}\item 
enum \textbf{ bit\+\_\+value} \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos\+\_\+high} (const struct \textbf{ bitvec} $\ast$bv, unsigned int bitnr)
\begin{DoxyCompactList}\small\item\em check if the bit is L or H for a given position inside a bitvec \end{DoxyCompactList}\item 
unsigned int \textbf{ bitvec\+\_\+get\+\_\+nth\+\_\+set\+\_\+bit} (const struct \textbf{ bitvec} $\ast$bv, unsigned int \textbf{ n})
\begin{DoxyCompactList}\small\item\em get the Nth set bit inside the bit vector \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+bit\+\_\+pos} (struct \textbf{ bitvec} $\ast$bv, unsigned int bitnr, enum \textbf{ bit\+\_\+value} bit)
\begin{DoxyCompactList}\small\item\em set a bit at given position in a bit vector \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+bit} (struct \textbf{ bitvec} $\ast$bv, enum \textbf{ bit\+\_\+value} bit)
\begin{DoxyCompactList}\small\item\em set the next bit inside a bitvec \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+high} (struct \textbf{ bitvec} $\ast$bv)
\begin{DoxyCompactList}\small\item\em get the next bit (low/high) inside a bitvec \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+bits} (struct \textbf{ bitvec} $\ast$bv, const enum \textbf{ bit\+\_\+value} $\ast$\textbf{ bits}, unsigned int count)
\begin{DoxyCompactList}\small\item\em set multiple bits (based on array of bitvals) at current pos \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+u64} (struct \textbf{ bitvec} $\ast$bv, uint64\+\_\+t v, uint8\+\_\+t num\+\_\+bits, bool use\+\_\+lh)
\begin{DoxyCompactList}\small\item\em set multiple bits (based on numeric value) at current pos. \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+uint} (struct \textbf{ bitvec} $\ast$bv, unsigned int ui, unsigned int num\+\_\+bits)
\begin{DoxyCompactList}\small\item\em set multiple bits (based on numeric value) at current pos. \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+get\+\_\+uint} (struct \textbf{ bitvec} $\ast$bv, unsigned int num\+\_\+bits)
\begin{DoxyCompactList}\small\item\em get multiple bits (based on numeric value) from current pos \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+find\+\_\+bit\+\_\+pos} (const struct \textbf{ bitvec} $\ast$bv, unsigned int \textbf{ n}, enum \textbf{ bit\+\_\+value} val)
\begin{DoxyCompactList}\small\item\em find first bit set in bit vector \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+spare\+\_\+padding} (struct \textbf{ bitvec} $\ast$bv, unsigned int up\+\_\+to\+\_\+bit)
\begin{DoxyCompactList}\small\item\em pad all remaining bits up to a given bit number \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+get\+\_\+bytes} (struct \textbf{ bitvec} $\ast$bv, uint8\+\_\+t $\ast$bytes, unsigned int count)
\begin{DoxyCompactList}\small\item\em get multiple bytes from current pos Assumes MSB first encoding. \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+bytes} (struct \textbf{ bitvec} $\ast$bv, const uint8\+\_\+t $\ast$bytes, unsigned int count)
\begin{DoxyCompactList}\small\item\em set multiple bytes at current pos Assumes MSB first encoding. \end{DoxyCompactList}\item 
struct \textbf{ bitvec} $\ast$ \textbf{ bitvec\+\_\+alloc} (unsigned int size, void $\ast$ctx)
\begin{DoxyCompactList}\small\item\em Allocate a bit vector. \end{DoxyCompactList}\item 
void \textbf{ bitvec\+\_\+free} (struct \textbf{ bitvec} $\ast$bv)
\begin{DoxyCompactList}\small\item\em Free a bit vector (release its memory) \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+unhex} (struct \textbf{ bitvec} $\ast$bv, const char $\ast$src)
\begin{DoxyCompactList}\small\item\em read hexadecimap string into a bit vector \end{DoxyCompactList}\item 
unsigned int \textbf{ bitvec\+\_\+pack} (const struct \textbf{ bitvec} $\ast$bv, uint8\+\_\+t $\ast$\textbf{ buffer})
\begin{DoxyCompactList}\small\item\em Export a bit vector to a buffer. \end{DoxyCompactList}\item 
unsigned int \textbf{ bitvec\+\_\+unpack} (struct \textbf{ bitvec} $\ast$bv, const uint8\+\_\+t $\ast$\textbf{ buffer})
\begin{DoxyCompactList}\small\item\em Copy buffer of unpacked bits into bit vector. \end{DoxyCompactList}\item 
uint64\+\_\+t \textbf{ bitvec\+\_\+read\+\_\+field} (struct \textbf{ bitvec} $\ast$bv, unsigned int $\ast$read\+\_\+index, unsigned int \textbf{ len})
\begin{DoxyCompactList}\small\item\em read part of the vector \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+write\+\_\+field} (struct \textbf{ bitvec} $\ast$bv, unsigned int $\ast$write\+\_\+index, uint64\+\_\+t val, unsigned int \textbf{ len})
\begin{DoxyCompactList}\small\item\em write into the vector \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+fill} (struct \textbf{ bitvec} $\ast$bv, unsigned int num\+\_\+bits, enum \textbf{ bit\+\_\+value} fill)
\begin{DoxyCompactList}\small\item\em fill num\+\_\+bits with \textbackslash{}fill starting from the current position \end{DoxyCompactList}\item 
char \textbf{ bit\+\_\+value\+\_\+to\+\_\+char} (enum \textbf{ bit\+\_\+value} v)
\begin{DoxyCompactList}\small\item\em convert enum to corresponding character \end{DoxyCompactList}\item 
void \textbf{ bitvec\+\_\+to\+\_\+string\+\_\+r} (const struct \textbf{ bitvec} $\ast$bv, char $\ast$str)
\begin{DoxyCompactList}\small\item\em prints bit vector to provided string It\textquotesingle{}s caller\textquotesingle{}s responsibility to ensure that we won\textquotesingle{}t shoot him in the foot\+: the provided buffer should be at lest cur\+\_\+bit + 1 bytes long \end{DoxyCompactList}\item 
void \textbf{ bitvec\+\_\+zero} (struct \textbf{ bitvec} $\ast$bv)
\begin{DoxyCompactList}\small\item\em force bit vector to all 0 and current bit to the beginnig of the vector \end{DoxyCompactList}\item 
unsigned \textbf{ bitvec\+\_\+rl} (const struct \textbf{ bitvec} $\ast$bv, bool b)
\begin{DoxyCompactList}\small\item\em Return number (bits) of uninterrupted bit run in vector starting from the MSB. \end{DoxyCompactList}\item 
unsigned \textbf{ bitvec\+\_\+rl\+\_\+curbit} (struct \textbf{ bitvec} $\ast$bv, bool b, unsigned int max\+\_\+bits)
\begin{DoxyCompactList}\small\item\em Return number (bits) of uninterrupted bit run in vector starting from the current bit. \end{DoxyCompactList}\item 
void \textbf{ bitvec\+\_\+shiftl} (struct \textbf{ bitvec} $\ast$bv, unsigned int \textbf{ n})
\item 
int16\+\_\+t \textbf{ bitvec\+\_\+get\+\_\+int16\+\_\+msb} (const struct \textbf{ bitvec} $\ast$bv, unsigned int num\+\_\+bits)
\begin{DoxyCompactList}\small\item\em get multiple bits (num\+\_\+bits) from beginning of vector (MSB side) \end{DoxyCompactList}\item 
unsigned int \textbf{ bitvec\+\_\+add\+\_\+array} (struct \textbf{ bitvec} $\ast$bv, const uint32\+\_\+t $\ast$array, unsigned int array\+\_\+len, bool dry\+\_\+run, unsigned int num\+\_\+bits)
\begin{DoxyCompactList}\small\item\em Add given array to bitvec. \end{DoxyCompactList}\item 
static unsigned int \textbf{ bitvec\+\_\+used\+\_\+bytes} (const struct \textbf{ bitvec} $\ast$bv)
\begin{DoxyCompactList}\small\item\em Return the number of bytes used within the bit vector. \end{DoxyCompactList}\item 
static unsigned int \textbf{ bitvec\+\_\+tailroom\+\_\+bits} (const struct \textbf{ bitvec} $\ast$bv)
\begin{DoxyCompactList}\small\item\em Return the tailroom in number of unused bits remaining in the bit-\/vector. \end{DoxyCompactList}\item 
static unsigned int \textbf{ bytenum\+\_\+from\+\_\+bitnum} (unsigned int bitnum)
\item 
static uint8\+\_\+t \textbf{ bitval2mask} (enum \textbf{ bit\+\_\+value} bit, uint8\+\_\+t bitnum)
\item 
static unsigned \textbf{ leading\+\_\+bits} (uint8\+\_\+t \textbf{ x}, bool b)
\item 
void \textbf{ bitvec\+\_\+shiftl} (struct \textbf{ bitvec} $\ast$bv, unsigned \textbf{ n})
\begin{DoxyCompactList}\small\item\em Shifts bitvec to the left, n MSB bits lost. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Osmocom bit vector abstraction utility routines. 

These functions assume a MSB (most significant bit) first layout of the bits, so that for instance the 5 bit number abcde (a is MSB) can be embedded into a byte sequence like in xxxxxxab cdexxxxx. The bit count starts with the MSB, so the bits in a byte are numbered (MSB) 01234567 (LSB). Note that there are other incompatible encodings, like it is used for the EGPRS RLC data block headers (there the bits are numbered from LSB to MSB). 

\doxysubsection{Macro Definition Documentation}
\mbox{\label{group__bitvec_ga586608cc901ec22be0d175eb8d320a00}} 
\index{Bit vectors@{Bit vectors}!BITNUM\_FROM\_COMP@{BITNUM\_FROM\_COMP}}
\index{BITNUM\_FROM\_COMP@{BITNUM\_FROM\_COMP}!Bit vectors@{Bit vectors}}
\doxysubsubsection{BITNUM\_FROM\_COMP}
{\footnotesize\ttfamily \#define BITNUM\+\_\+\+FROM\+\_\+\+COMP(\begin{DoxyParamCaption}\item[{}]{byte,  }\item[{}]{bit }\end{DoxyParamCaption})~((byte$\ast$8)+bit)}



\doxysubsection{Enumeration Type Documentation}
\mbox{\label{group__bitvec_ga9f16b701956714c5f84b0a6120d131ea}} 
\index{Bit vectors@{Bit vectors}!bit\_value@{bit\_value}}
\index{bit\_value@{bit\_value}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bit\_value}
{\footnotesize\ttfamily enum \textbf{ bit\+\_\+value}}



A single GSM bit. 

In GSM mac blocks, every bit can be 0 or 1, or L or H. L/H are defined relative to the 0x2b padding pattern \begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{ZERO@{ZERO}!Bit vectors@{Bit vectors}}\index{Bit vectors@{Bit vectors}!ZERO@{ZERO}}}\mbox{\label{group__bitvec_gga9f16b701956714c5f84b0a6120d131eaae117e3533122c80b262257b49b21cddf}} 
ZERO&A zero (0) bit. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{ONE@{ONE}!Bit vectors@{Bit vectors}}\index{Bit vectors@{Bit vectors}!ONE@{ONE}}}\mbox{\label{group__bitvec_gga9f16b701956714c5f84b0a6120d131eaa7a725f13af144bdef532d0389ba75e0d}} 
ONE&A one (1) bit. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{L@{L}!Bit vectors@{Bit vectors}}\index{Bit vectors@{Bit vectors}!L@{L}}}\mbox{\label{group__bitvec_gga9f16b701956714c5f84b0a6120d131eaaef31cc6fe9479955961311ee18ac205f}} 
L&A CSN.\+1 \char`\"{}\+L\char`\"{} bit. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{H@{H}!Bit vectors@{Bit vectors}}\index{Bit vectors@{Bit vectors}!H@{H}}}\mbox{\label{group__bitvec_gga9f16b701956714c5f84b0a6120d131eaa5008b1179f399a2273fd3f6a7fc3b292}} 
H&A CSN.\+1 \char`\"{}\+H\char`\"{} bit. \\
\hline

\end{DoxyEnumFields}


\doxysubsection{Function Documentation}
\mbox{\label{group__bitvec_ga3ff0dbe3fbc6eb1b6c4a93a680e5d1c0}} 
\index{Bit vectors@{Bit vectors}!bit\_value\_to\_char@{bit\_value\_to\_char}}
\index{bit\_value\_to\_char@{bit\_value\_to\_char}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bit\_value\_to\_char()}
{\footnotesize\ttfamily char bit\+\_\+value\+\_\+to\+\_\+char (\begin{DoxyParamCaption}\item[{enum \textbf{ bit\+\_\+value}}]{v }\end{DoxyParamCaption})}



convert enum to corresponding character 


\begin{DoxyParams}{Parameters}
{\em v} & input value (bit) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
single character, either 0, 1, L or H 
\end{DoxyReturn}


References \textbf{ H}, \textbf{ L}, \textbf{ ONE}, \textbf{ osmo\+\_\+panic()}, and \textbf{ ZERO}.



Referenced by \textbf{ bitvec\+\_\+to\+\_\+string\+\_\+r()}.

\mbox{\label{group__bitvec_ga46d71adbe96a25e3eea080bcc0eca79e}} 
\index{Bit vectors@{Bit vectors}!bitval2mask@{bitval2mask}}
\index{bitval2mask@{bitval2mask}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitval2mask()}
{\footnotesize\ttfamily static uint8\+\_\+t bitval2mask (\begin{DoxyParamCaption}\item[{enum \textbf{ bit\+\_\+value}}]{bit,  }\item[{uint8\+\_\+t}]{bitnum }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ H}, \textbf{ L}, \textbf{ ONE}, and \textbf{ ZERO}.



Referenced by \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos()}, \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos\+\_\+high()}, and \textbf{ bitvec\+\_\+set\+\_\+bit\+\_\+pos()}.

\mbox{\label{group__bitvec_gaec9f2c4612b55bbbd840187f46d92e9c}} 
\index{Bit vectors@{Bit vectors}!bitvec\_add\_array@{bitvec\_add\_array}}
\index{bitvec\_add\_array@{bitvec\_add\_array}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_add\_array()}
{\footnotesize\ttfamily unsigned int bitvec\+\_\+add\+\_\+array (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{const uint32\+\_\+t $\ast$}]{array,  }\item[{unsigned int}]{array\+\_\+len,  }\item[{bool}]{dry\+\_\+run,  }\item[{unsigned int}]{num\+\_\+bits }\end{DoxyParamCaption})}



Add given array to bitvec. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em bv} & bit vector to work with \\
\hline
\mbox{\texttt{ in}}  & {\em array} & elements to be added \\
\hline
\mbox{\texttt{ in}}  & {\em array\+\_\+len} & length of array \\
\hline
\mbox{\texttt{ in}}  & {\em dry\+\_\+run} & indicates whether to return number of bits required instead of adding anything to bv for real \\
\hline
\mbox{\texttt{ in}}  & {\em num\+\_\+bits} & number of bits to consider in each element of array \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bits necessary to add array elements if dry\+\_\+run is true, 0 otherwise (only in this case bv is actually changed)
\end{DoxyReturn}
N. B\+: no length checks are performed on bv -\/ it\textquotesingle{}s caller\textquotesingle{}s job to ensure enough space is available -\/ for example by calling with dry\+\_\+run = true first.

Useful for common pattern in CSN.\+1 spec which looks like\+: \{ 1 $<$ XXX \+: bit (num\+\_\+bits) $>$ \} $\ast$$\ast$ 0 which means repeat any times (between 0 and infinity), start each repetition with 1, mark end of repetitions with 0 bit see app. note in 3GPP TS 24.\+007 § B.\+2.\+1 Rule A2 

References \textbf{ bits}, \textbf{ bitvec\+\_\+set\+\_\+bit()}, and \textbf{ bitvec\+\_\+set\+\_\+uint()}.

\mbox{\label{group__bitvec_ga4fab97ef97d237370c1147e765f80a16}} 
\index{Bit vectors@{Bit vectors}!bitvec\_alloc@{bitvec\_alloc}}
\index{bitvec\_alloc@{bitvec\_alloc}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_alloc()}
{\footnotesize\ttfamily struct \textbf{ bitvec} $\ast$ bitvec\+\_\+alloc (\begin{DoxyParamCaption}\item[{unsigned int}]{size,  }\item[{void $\ast$}]{ctx }\end{DoxyParamCaption})}



Allocate a bit vector. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em size} & Number of bytes in the vector \\
\hline
\mbox{\texttt{ in}}  & {\em ctx} & Context from which to allocate \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to allocated vector; NULL in case of error 
\end{DoxyReturn}


References \textbf{ cur\+\_\+bit}, \textbf{ data}, and \textbf{ data\+\_\+len}.

\mbox{\label{group__bitvec_ga58e79f89821667662d35ac16f296517f}} 
\index{Bit vectors@{Bit vectors}!bitvec\_fill@{bitvec\_fill}}
\index{bitvec\_fill@{bitvec\_fill}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_fill()}
{\footnotesize\ttfamily int bitvec\+\_\+fill (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{num\+\_\+bits,  }\item[{enum \textbf{ bit\+\_\+value}}]{fill }\end{DoxyParamCaption})}



fill num\+\_\+bits with \textbackslash{}fill starting from the current position 

\begin{DoxyReturn}{Returns}
0 on success; negative otherwise (out of vector boundary) 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+set\+\_\+bit()}, and \textbf{ cur\+\_\+bit}.



Referenced by \textbf{ bitvec\+\_\+spare\+\_\+padding()}.

\mbox{\label{group__bitvec_ga7366e9cd542a95177d1d906b1a83200d}} 
\index{Bit vectors@{Bit vectors}!bitvec\_find\_bit\_pos@{bitvec\_find\_bit\_pos}}
\index{bitvec\_find\_bit\_pos@{bitvec\_find\_bit\_pos}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_find\_bit\_pos()}
{\footnotesize\ttfamily int bitvec\+\_\+find\+\_\+bit\+\_\+pos (\begin{DoxyParamCaption}\item[{const struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{n,  }\item[{enum \textbf{ bit\+\_\+value}}]{val }\end{DoxyParamCaption})}



find first bit set in bit vector 

\begin{DoxyReturn}{Returns}
0 on success; negative otherwise 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos()}, \textbf{ data\+\_\+len}, and \textbf{ n}.

\mbox{\label{group__bitvec_gaed6f952768bfdfbb09491195cba83232}} 
\index{Bit vectors@{Bit vectors}!bitvec\_free@{bitvec\_free}}
\index{bitvec\_free@{bitvec\_free}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_free()}
{\footnotesize\ttfamily void bitvec\+\_\+free (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv }\end{DoxyParamCaption})}



Free a bit vector (release its memory) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bit} & vector to free \\
\hline
\end{DoxyParams}


References \textbf{ data}.

\mbox{\label{group__bitvec_ga9bc267f4f06fbc4d51754144ad195e01}} 
\index{Bit vectors@{Bit vectors}!bitvec\_get\_bit\_high@{bitvec\_get\_bit\_high}}
\index{bitvec\_get\_bit\_high@{bitvec\_get\_bit\_high}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_get\_bit\_high()}
{\footnotesize\ttfamily int bitvec\+\_\+get\+\_\+bit\+\_\+high (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv }\end{DoxyParamCaption})}



get the next bit (low/high) inside a bitvec 

\begin{DoxyReturn}{Returns}
value of th next bit in the vector 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos\+\_\+high()}, and \textbf{ cur\+\_\+bit}.

\mbox{\label{group__bitvec_gaafa5522adcd980634faa6059b9aee3a1}} 
\index{Bit vectors@{Bit vectors}!bitvec\_get\_bit\_pos@{bitvec\_get\_bit\_pos}}
\index{bitvec\_get\_bit\_pos@{bitvec\_get\_bit\_pos}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_get\_bit\_pos()}
{\footnotesize\ttfamily enum \textbf{ bit\+\_\+value} bitvec\+\_\+get\+\_\+bit\+\_\+pos (\begin{DoxyParamCaption}\item[{const struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{bitnr }\end{DoxyParamCaption})}



check if the bit is 0 or 1 for a given position inside a bitvec 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & the bit vector on which to check \\
\hline
\mbox{\texttt{ in}}  & {\em bitnr} & the bit number inside the bit vector to check \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
value of the requested bit 
\end{DoxyReturn}


References \textbf{ bitval2mask()}, \textbf{ bytenum\+\_\+from\+\_\+bitnum()}, \textbf{ data}, \textbf{ data\+\_\+len}, \textbf{ ONE}, and \textbf{ ZERO}.



Referenced by \textbf{ bitvec\+\_\+find\+\_\+bit\+\_\+pos()}, \textbf{ bitvec\+\_\+get\+\_\+nth\+\_\+set\+\_\+bit()}, \textbf{ bitvec\+\_\+get\+\_\+uint()}, and \textbf{ bitvec\+\_\+to\+\_\+string\+\_\+r()}.

\mbox{\label{group__bitvec_ga958c055f2e6c1983de24f970fcf351b2}} 
\index{Bit vectors@{Bit vectors}!bitvec\_get\_bit\_pos\_high@{bitvec\_get\_bit\_pos\_high}}
\index{bitvec\_get\_bit\_pos\_high@{bitvec\_get\_bit\_pos\_high}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_get\_bit\_pos\_high()}
{\footnotesize\ttfamily enum \textbf{ bit\+\_\+value} bitvec\+\_\+get\+\_\+bit\+\_\+pos\+\_\+high (\begin{DoxyParamCaption}\item[{const struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{bitnr }\end{DoxyParamCaption})}



check if the bit is L or H for a given position inside a bitvec 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & the bit vector on which to check \\
\hline
\mbox{\texttt{ in}}  & {\em bitnr} & the bit number inside the bit vector to check \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
value of the requested bit 
\end{DoxyReturn}


References \textbf{ bitval2mask()}, \textbf{ bytenum\+\_\+from\+\_\+bitnum()}, \textbf{ data}, \textbf{ data\+\_\+len}, \textbf{ H}, and \textbf{ L}.



Referenced by \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+high()}.

\mbox{\label{group__bitvec_ga531d7610f179bbcb46cbe2fe8fafbc9e}} 
\index{Bit vectors@{Bit vectors}!bitvec\_get\_bytes@{bitvec\_get\_bytes}}
\index{bitvec\_get\_bytes@{bitvec\_get\_bytes}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_get\_bytes()}
{\footnotesize\ttfamily int bitvec\+\_\+get\+\_\+bytes (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{uint8\+\_\+t $\ast$}]{bytes,  }\item[{unsigned int}]{count }\end{DoxyParamCaption})}



get multiple bytes from current pos Assumes MSB first encoding. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & bit vector \\
\hline
\mbox{\texttt{ in}}  & {\em bytes} & array \\
\hline
\mbox{\texttt{ in}}  & {\em count} & number of bytes to copy \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative otherwise 
\end{DoxyReturn}


References \textbf{ bytenum\+\_\+from\+\_\+bitnum()}, \textbf{ c}, \textbf{ cur\+\_\+bit}, \textbf{ data}, and \textbf{ data\+\_\+len}.

\mbox{\label{group__bitvec_ga0a6fbad0ee12ac9b17af6eb0b49fce7a}} 
\index{Bit vectors@{Bit vectors}!bitvec\_get\_int16\_msb@{bitvec\_get\_int16\_msb}}
\index{bitvec\_get\_int16\_msb@{bitvec\_get\_int16\_msb}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_get\_int16\_msb()}
{\footnotesize\ttfamily int16\+\_\+t bitvec\+\_\+get\+\_\+int16\+\_\+msb (\begin{DoxyParamCaption}\item[{const struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{num\+\_\+bits }\end{DoxyParamCaption})}



get multiple bits (num\+\_\+bits) from beginning of vector (MSB side) 

\begin{DoxyReturn}{Returns}
16bit signed integer retrieved from bit vector 
\end{DoxyReturn}


References \textbf{ cur\+\_\+bit}, \textbf{ data}, and \textbf{ osmo\+\_\+load16be()}.

\mbox{\label{group__bitvec_ga586f2e477420cf97ff85fb5029409528}} 
\index{Bit vectors@{Bit vectors}!bitvec\_get\_nth\_set\_bit@{bitvec\_get\_nth\_set\_bit}}
\index{bitvec\_get\_nth\_set\_bit@{bitvec\_get\_nth\_set\_bit}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_get\_nth\_set\_bit()}
{\footnotesize\ttfamily unsigned int bitvec\+\_\+get\+\_\+nth\+\_\+set\+\_\+bit (\begin{DoxyParamCaption}\item[{const struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{n }\end{DoxyParamCaption})}



get the Nth set bit inside the bit vector 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & the bit vector to use \\
\hline
\mbox{\texttt{ in}}  & {\em n} & the bit number to get \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the bit number (offset) of the Nth set bit in {\itshape bv} 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos()}, \textbf{ data\+\_\+len}, \textbf{ k}, \textbf{ n}, and \textbf{ ONE}.

\mbox{\label{group__bitvec_gaca0563425ea4947dacaf33ce23cbe817}} 
\index{Bit vectors@{Bit vectors}!bitvec\_get\_uint@{bitvec\_get\_uint}}
\index{bitvec\_get\_uint@{bitvec\_get\_uint}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_get\_uint()}
{\footnotesize\ttfamily int bitvec\+\_\+get\+\_\+uint (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{num\+\_\+bits }\end{DoxyParamCaption})}



get multiple bits (based on numeric value) from current pos 

\begin{DoxyReturn}{Returns}
integer value retrieved from bit vector 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos()}, and \textbf{ cur\+\_\+bit}.

\mbox{\label{group__bitvec_ga309e4e3f006f160f016eca5ff9d29411}} 
\index{Bit vectors@{Bit vectors}!bitvec\_pack@{bitvec\_pack}}
\index{bitvec\_pack@{bitvec\_pack}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_pack()}
{\footnotesize\ttfamily unsigned int bitvec\+\_\+pack (\begin{DoxyParamCaption}\item[{const struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{uint8\+\_\+t $\ast$}]{buffer }\end{DoxyParamCaption})}



Export a bit vector to a buffer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bitvec} & (unpacked bits) \\
\hline
\mbox{\texttt{ out}}  & {\em buffer} & for the unpacked bits \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bytes (= bits) copied 
\end{DoxyReturn}


References \textbf{ data}, and \textbf{ data\+\_\+len}.

\mbox{\label{group__bitvec_ga465b2992b4abf3a6bd88244fb012215e}} 
\index{Bit vectors@{Bit vectors}!bitvec\_read\_field@{bitvec\_read\_field}}
\index{bitvec\_read\_field@{bitvec\_read\_field}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_read\_field()}
{\footnotesize\ttfamily uint64\+\_\+t bitvec\+\_\+read\+\_\+field (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int $\ast$}]{read\+\_\+index,  }\item[{unsigned int}]{len }\end{DoxyParamCaption})}



read part of the vector 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & The boolean vector to work on \\
\hline
\mbox{\texttt{ in,out}}  & {\em read\+\_\+index} & Where reading supposed to start in the vector \\
\hline
\mbox{\texttt{ in}}  & {\em len} & How many bits to read from vector \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
An integer made up of the bits read.
\end{DoxyReturn}
In case of an error, errno is set to a non-\/zero value. Otherwise it holds 0. 

References \textbf{ bytenum\+\_\+from\+\_\+bitnum()}, \textbf{ cur\+\_\+bit}, \textbf{ data}, \textbf{ data\+\_\+len}, and \textbf{ len()}.



Referenced by \textbf{ bitvec\+\_\+rl\+\_\+curbit()}.

\mbox{\label{group__bitvec_gaacff55d1b7b4749bb47998bff2ab69f9}} 
\index{Bit vectors@{Bit vectors}!bitvec\_rl@{bitvec\_rl}}
\index{bitvec\_rl@{bitvec\_rl}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_rl()}
{\footnotesize\ttfamily unsigned bitvec\+\_\+rl (\begin{DoxyParamCaption}\item[{const struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{bool}]{b }\end{DoxyParamCaption})}



Return number (bits) of uninterrupted bit run in vector starting from the MSB. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & The boolean vector to work on \\
\hline
\mbox{\texttt{ in}}  & {\em b} & The boolean, sequence of which is looked at from the vector start \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Number of consecutive bits of {\ttfamily b} in {\ttfamily bv} 
\end{DoxyReturn}


References \textbf{ cur\+\_\+bit}, \textbf{ data}, and \textbf{ leading\+\_\+bits()}.



Referenced by \textbf{ osmo\+\_\+t4\+\_\+encode()}.

\mbox{\label{group__bitvec_ga3dd2844a5868df3c3e33ccf04e9179cb}} 
\index{Bit vectors@{Bit vectors}!bitvec\_rl\_curbit@{bitvec\_rl\_curbit}}
\index{bitvec\_rl\_curbit@{bitvec\_rl\_curbit}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_rl\_curbit()}
{\footnotesize\ttfamily unsigned bitvec\+\_\+rl\+\_\+curbit (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{bool}]{b,  }\item[{unsigned int}]{max\+\_\+bits }\end{DoxyParamCaption})}



Return number (bits) of uninterrupted bit run in vector starting from the current bit. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & The boolean vector to work on \\
\hline
\mbox{\texttt{ in}}  & {\em b} & The boolean, sequence of 1\textquotesingle{}s or 0\textquotesingle{}s to be checked \\
\hline
\mbox{\texttt{ in}}  & {\em max\+\_\+bits} & Total Number of Uncmopresed bits \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Number of consecutive bits of {\ttfamily b} in {\ttfamily bv} and cur\+\_\+bit will \textbackslash{}go to cur\+\_\+bit + number of consecutive bit 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+read\+\_\+field()}, \textbf{ cur\+\_\+bit}, \textbf{ data}, and \textbf{ leading\+\_\+bits()}.

\mbox{\label{group__bitvec_gaaaec65c173424583952f3f8c87b8d9e0}} 
\index{Bit vectors@{Bit vectors}!bitvec\_set\_bit@{bitvec\_set\_bit}}
\index{bitvec\_set\_bit@{bitvec\_set\_bit}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_set\_bit()}
{\footnotesize\ttfamily int bitvec\+\_\+set\+\_\+bit (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{enum \textbf{ bit\+\_\+value}}]{bit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



set the next bit inside a bitvec 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & bit vector to be used \\
\hline
\mbox{\texttt{ in}}  & {\em bit} & value of the bit to be set \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative value on error 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+set\+\_\+bit\+\_\+pos()}, and \textbf{ cur\+\_\+bit}.



Referenced by \textbf{ bitvec\+\_\+add\+\_\+array()}, \textbf{ bitvec\+\_\+fill()}, \textbf{ bitvec\+\_\+set\+\_\+bits()}, and \textbf{ bitvec\+\_\+set\+\_\+u64()}.

\mbox{\label{group__bitvec_ga58af5972b3f9f9590ab677591ea08654}} 
\index{Bit vectors@{Bit vectors}!bitvec\_set\_bit\_pos@{bitvec\_set\_bit\_pos}}
\index{bitvec\_set\_bit\_pos@{bitvec\_set\_bit\_pos}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_set\_bit\_pos()}
{\footnotesize\ttfamily int bitvec\+\_\+set\+\_\+bit\+\_\+pos (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{bitnr,  }\item[{enum \textbf{ bit\+\_\+value}}]{bit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



set a bit at given position in a bit vector 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & bit vector on which to operate \\
\hline
\mbox{\texttt{ in}}  & {\em bitnr} & number of bit to be set \\
\hline
\mbox{\texttt{ in}}  & {\em bit} & value to which the bit is to be set \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative value on error 
\end{DoxyReturn}


References \textbf{ bitval2mask()}, \textbf{ bytenum\+\_\+from\+\_\+bitnum()}, \textbf{ data}, \textbf{ data\+\_\+len}, and \textbf{ ONE}.



Referenced by \textbf{ bitvec\+\_\+set\+\_\+bit()}.

\mbox{\label{group__bitvec_ga8a35d07a2716e1d6d816a4028612e869}} 
\index{Bit vectors@{Bit vectors}!bitvec\_set\_bits@{bitvec\_set\_bits}}
\index{bitvec\_set\_bits@{bitvec\_set\_bits}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_set\_bits()}
{\footnotesize\ttfamily int bitvec\+\_\+set\+\_\+bits (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{const enum \textbf{ bit\+\_\+value} $\ast$}]{bits,  }\item[{unsigned int}]{count }\end{DoxyParamCaption})}



set multiple bits (based on array of bitvals) at current pos 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & bit vector \\
\hline
\mbox{\texttt{ in}}  & {\em bits} & array of \doxyref{bit\+\_\+value}{p.}{group__bitvec_ga9f16b701956714c5f84b0a6120d131ea} \\
\hline
\mbox{\texttt{ in}}  & {\em count} & number of bits to set \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative in case of error 
\end{DoxyReturn}


References \textbf{ bits}, and \textbf{ bitvec\+\_\+set\+\_\+bit()}.

\mbox{\label{group__bitvec_gae64f81294cb6f0521d7b03addcbedee2}} 
\index{Bit vectors@{Bit vectors}!bitvec\_set\_bytes@{bitvec\_set\_bytes}}
\index{bitvec\_set\_bytes@{bitvec\_set\_bytes}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_set\_bytes()}
{\footnotesize\ttfamily int bitvec\+\_\+set\+\_\+bytes (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{const uint8\+\_\+t $\ast$}]{bytes,  }\item[{unsigned int}]{count }\end{DoxyParamCaption})}



set multiple bytes at current pos Assumes MSB first encoding. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & bit vector \\
\hline
\mbox{\texttt{ in}}  & {\em bytes} & array \\
\hline
\mbox{\texttt{ in}}  & {\em count} & number of bytes to copy \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative otherwise 
\end{DoxyReturn}


References \textbf{ bytenum\+\_\+from\+\_\+bitnum()}, \textbf{ c}, \textbf{ cur\+\_\+bit}, \textbf{ data}, and \textbf{ data\+\_\+len}.

\mbox{\label{group__bitvec_ga3bc972c0ec080f82adb7cc1328c85e1c}} 
\index{Bit vectors@{Bit vectors}!bitvec\_set\_u64@{bitvec\_set\_u64}}
\index{bitvec\_set\_u64@{bitvec\_set\_u64}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_set\_u64()}
{\footnotesize\ttfamily int bitvec\+\_\+set\+\_\+u64 (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{uint64\+\_\+t}]{v,  }\item[{uint8\+\_\+t}]{num\+\_\+bits,  }\item[{bool}]{use\+\_\+lh }\end{DoxyParamCaption})}



set multiple bits (based on numeric value) at current pos. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & bit vector. \\
\hline
\mbox{\texttt{ in}}  & {\em v} & mask representing which bits needs to be set. \\
\hline
\mbox{\texttt{ in}}  & {\em num\+\_\+bits} & number of meaningful bits in the mask. \\
\hline
\mbox{\texttt{ in}}  & {\em use\+\_\+lh} & whether to interpret the bits as L/H values or as 0/1. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative in case of error. 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+set\+\_\+bit()}, \textbf{ H}, and \textbf{ L}.



Referenced by \textbf{ bitvec\+\_\+set\+\_\+uint()}, and \textbf{ bitvec\+\_\+write\+\_\+field()}.

\mbox{\label{group__bitvec_gada7f0c0bad40354d9323db1ef53da13b}} 
\index{Bit vectors@{Bit vectors}!bitvec\_set\_uint@{bitvec\_set\_uint}}
\index{bitvec\_set\_uint@{bitvec\_set\_uint}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_set\_uint()}
{\footnotesize\ttfamily int bitvec\+\_\+set\+\_\+uint (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{ui,  }\item[{unsigned int}]{num\+\_\+bits }\end{DoxyParamCaption})}



set multiple bits (based on numeric value) at current pos. 

\begin{DoxyReturn}{Returns}
0 in case of success; negative in case of error. 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+set\+\_\+u64()}.



Referenced by \textbf{ bitvec\+\_\+add\+\_\+array()}, and \textbf{ t4\+\_\+rle()}.

\mbox{\label{group__bitvec_ga5e336973391eb0e24d6973ec51fdda00}} 
\index{Bit vectors@{Bit vectors}!bitvec\_shiftl@{bitvec\_shiftl}}
\index{bitvec\_shiftl@{bitvec\_shiftl}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_shiftl()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily void bitvec\+\_\+shiftl (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{n }\end{DoxyParamCaption})}



Referenced by \textbf{ osmo\+\_\+t4\+\_\+encode()}.

\mbox{\label{group__bitvec_ga5037965c835b03f55f87cb0ab99f0cac}} 
\index{Bit vectors@{Bit vectors}!bitvec\_shiftl@{bitvec\_shiftl}}
\index{bitvec\_shiftl@{bitvec\_shiftl}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_shiftl()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily void bitvec\+\_\+shiftl (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned}]{n }\end{DoxyParamCaption})}



Shifts bitvec to the left, n MSB bits lost. 



References \textbf{ bitvec\+\_\+zero()}, \textbf{ cur\+\_\+bit}, \textbf{ data}, \textbf{ data\+\_\+len}, \textbf{ n}, \textbf{ osmo\+\_\+load16be()}, and \textbf{ osmo\+\_\+store16be()}.

\mbox{\label{group__bitvec_ga6c6bf6ae771c101a05b3695fff54e593}} 
\index{Bit vectors@{Bit vectors}!bitvec\_spare\_padding@{bitvec\_spare\_padding}}
\index{bitvec\_spare\_padding@{bitvec\_spare\_padding}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_spare\_padding()}
{\footnotesize\ttfamily int bitvec\+\_\+spare\+\_\+padding (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int}]{up\+\_\+to\+\_\+bit }\end{DoxyParamCaption})}



pad all remaining bits up to a given bit number 

\begin{DoxyReturn}{Returns}
0 on success; negative otherwise 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+fill()}, \textbf{ cur\+\_\+bit}, \textbf{ L}, and \textbf{ n}.

\mbox{\label{group__bitvec_ga79117cb575fe0c1e334fa727f8fe8d1d}} 
\index{Bit vectors@{Bit vectors}!bitvec\_tailroom\_bits@{bitvec\_tailroom\_bits}}
\index{bitvec\_tailroom\_bits@{bitvec\_tailroom\_bits}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_tailroom\_bits()}
{\footnotesize\ttfamily static unsigned int bitvec\+\_\+tailroom\+\_\+bits (\begin{DoxyParamCaption}\item[{const struct \textbf{ bitvec} $\ast$}]{bv }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Return the tailroom in number of unused bits remaining in the bit-\/vector. 



References \textbf{ cur\+\_\+bit}, and \textbf{ data\+\_\+len}.

\mbox{\label{group__bitvec_ga5c0c73912905c1f4400869da0a7bb439}} 
\index{Bit vectors@{Bit vectors}!bitvec\_to\_string\_r@{bitvec\_to\_string\_r}}
\index{bitvec\_to\_string\_r@{bitvec\_to\_string\_r}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_to\_string\_r()}
{\footnotesize\ttfamily void bitvec\+\_\+to\+\_\+string\+\_\+r (\begin{DoxyParamCaption}\item[{const struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{char $\ast$}]{str }\end{DoxyParamCaption})}



prints bit vector to provided string It\textquotesingle{}s caller\textquotesingle{}s responsibility to ensure that we won\textquotesingle{}t shoot him in the foot\+: the provided buffer should be at lest cur\+\_\+bit + 1 bytes long 



References \textbf{ bit\+\_\+value\+\_\+to\+\_\+char()}, \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos()}, and \textbf{ cur\+\_\+bit}.

\mbox{\label{group__bitvec_gae6aad886f187d967552ab8807dc84048}} 
\index{Bit vectors@{Bit vectors}!bitvec\_unhex@{bitvec\_unhex}}
\index{bitvec\_unhex@{bitvec\_unhex}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_unhex()}
{\footnotesize\ttfamily int bitvec\+\_\+unhex (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{const char $\ast$}]{src }\end{DoxyParamCaption})}



read hexadecimap string into a bit vector 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em src} & string containing hex digits \\
\hline
\mbox{\texttt{ out}}  & {\em bv} & unpacked bit vector \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 in case of success; 1 in case of error 
\end{DoxyReturn}


References \textbf{ cur\+\_\+bit}, \textbf{ data}, \textbf{ data\+\_\+len}, and \textbf{ osmo\+\_\+hexparse()}.

\mbox{\label{group__bitvec_gad4c8196ee9a8cab04af60577ea0fcadf}} 
\index{Bit vectors@{Bit vectors}!bitvec\_unpack@{bitvec\_unpack}}
\index{bitvec\_unpack@{bitvec\_unpack}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_unpack()}
{\footnotesize\ttfamily unsigned int bitvec\+\_\+unpack (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{const uint8\+\_\+t $\ast$}]{buffer }\end{DoxyParamCaption})}



Copy buffer of unpacked bits into bit vector. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em buffer} & unpacked input bits \\
\hline
\mbox{\texttt{ out}}  & {\em bv} & unpacked bit vector \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bytes (= bits) copied 
\end{DoxyReturn}


References \textbf{ data}, and \textbf{ data\+\_\+len}.

\mbox{\label{group__bitvec_ga634c68602acc9f1d1de490ac1c53e293}} 
\index{Bit vectors@{Bit vectors}!bitvec\_used\_bytes@{bitvec\_used\_bytes}}
\index{bitvec\_used\_bytes@{bitvec\_used\_bytes}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_used\_bytes()}
{\footnotesize\ttfamily static unsigned int bitvec\+\_\+used\+\_\+bytes (\begin{DoxyParamCaption}\item[{const struct \textbf{ bitvec} $\ast$}]{bv }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Return the number of bytes used within the bit vector. 



References \textbf{ cur\+\_\+bit}.

\mbox{\label{group__bitvec_gab76ababf6e79ccb51314d7e74381881a}} 
\index{Bit vectors@{Bit vectors}!bitvec\_write\_field@{bitvec\_write\_field}}
\index{bitvec\_write\_field@{bitvec\_write\_field}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_write\_field()}
{\footnotesize\ttfamily int bitvec\+\_\+write\+\_\+field (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv,  }\item[{unsigned int $\ast$}]{write\+\_\+index,  }\item[{uint64\+\_\+t}]{val,  }\item[{unsigned int}]{len }\end{DoxyParamCaption})}



write into the vector 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em bv} & The boolean vector to work on \\
\hline
\mbox{\texttt{ in,out}}  & {\em write\+\_\+index} & Where writing supposed to start in the vector \\
\hline
\mbox{\texttt{ in}}  & {\em len} & How many bits to write \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative value on error 
\end{DoxyReturn}


References \textbf{ bitvec\+\_\+set\+\_\+u64()}, \textbf{ cur\+\_\+bit}, and \textbf{ len()}.

\mbox{\label{group__bitvec_gab3953b2f83b395699039b565edc803a3}} 
\index{Bit vectors@{Bit vectors}!bitvec\_zero@{bitvec\_zero}}
\index{bitvec\_zero@{bitvec\_zero}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bitvec\_zero()}
{\footnotesize\ttfamily void bitvec\+\_\+zero (\begin{DoxyParamCaption}\item[{struct \textbf{ bitvec} $\ast$}]{bv }\end{DoxyParamCaption})}



force bit vector to all 0 and current bit to the beginnig of the vector 



References \textbf{ cur\+\_\+bit}, \textbf{ data}, and \textbf{ data\+\_\+len}.



Referenced by \textbf{ bitvec\+\_\+shiftl()}, and \textbf{ osmo\+\_\+t4\+\_\+encode()}.

\mbox{\label{group__bitvec_ga47c5a8afa396a44c819ac4e938552784}} 
\index{Bit vectors@{Bit vectors}!bytenum\_from\_bitnum@{bytenum\_from\_bitnum}}
\index{bytenum\_from\_bitnum@{bytenum\_from\_bitnum}!Bit vectors@{Bit vectors}}
\doxysubsubsection{bytenum\_from\_bitnum()}
{\footnotesize\ttfamily static unsigned int bytenum\+\_\+from\+\_\+bitnum (\begin{DoxyParamCaption}\item[{unsigned int}]{bitnum }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Referenced by \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos()}, \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos\+\_\+high()}, \textbf{ bitvec\+\_\+get\+\_\+bytes()}, \textbf{ bitvec\+\_\+read\+\_\+field()}, \textbf{ bitvec\+\_\+set\+\_\+bit\+\_\+pos()}, and \textbf{ bitvec\+\_\+set\+\_\+bytes()}.

\mbox{\label{group__bitvec_ga118debf7503fc8beaafc54d6b7b404f7}} 
\index{Bit vectors@{Bit vectors}!leading\_bits@{leading\_bits}}
\index{leading\_bits@{leading\_bits}!Bit vectors@{Bit vectors}}
\doxysubsubsection{leading\_bits()}
{\footnotesize\ttfamily static unsigned leading\+\_\+bits (\begin{DoxyParamCaption}\item[{uint8\+\_\+t}]{x,  }\item[{bool}]{b }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



References \textbf{ x}.



Referenced by \textbf{ bitvec\+\_\+rl()}, and \textbf{ bitvec\+\_\+rl\+\_\+curbit()}.

