\hypertarget{atomics_8h}{
\section{libthreads/include/atomics.h File Reference}
\label{atomics_8h}\index{libthreads/include/atomics.h@{libthreads/include/atomics.h}}
}
\subsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \hyperlink{atomics_8h_ae313282458f95fa2d743f519d988f4e7}{atomic\_\-compare\_\-t} \{ \hyperlink{atomics_8h_ae313282458f95fa2d743f519d988f4e7aa928025a0fa6e355ce5b68e004916124}{ATOMIC\_\-COMPARE\_\-NONE} =  0, 
\hyperlink{atomics_8h_ae313282458f95fa2d743f519d988f4e7abc5fed4b3733b1656b762d414eae036e}{ATOMIC\_\-COMPARE\_\-ZERO}, 
\hyperlink{atomics_8h_ae313282458f95fa2d743f519d988f4e7a7d17a2d7de9f1cc0db2c653b7e588e88}{ATOMIC\_\-COMPARE\_\-NEGATIVE}
 \}
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
u32 \hyperlink{atomics_8h_a6957e0a2509db392ab77b578a2ac6916}{atomics\_\-read} (u32 $\ast$v)
\begin{DoxyCompactList}\small\item\em Atomically read an integer. \item\end{DoxyCompactList}\item 
void \hyperlink{atomics_8h_af935efd83baeba7388ec5e326f02f465}{atomics\_\-set} (u32 $\ast$v, u32 i)
\begin{DoxyCompactList}\small\item\em Atomically set the value of an integer. \item\end{DoxyCompactList}\item 
int \hyperlink{atomics_8h_a0752848ba8203fd968f4f0e60d774d8c}{atomics\_\-add} (u32 $\ast$v, u32 i, \hyperlink{atomics_8h_ae313282458f95fa2d743f519d988f4e7}{atomic\_\-compare\_\-t} cmp)
\begin{DoxyCompactList}\small\item\em Atomically add an integer. \item\end{DoxyCompactList}\item 
int \hyperlink{atomics_8h_a6c026a49486555f0fd028f938c5ca634}{atomics\_\-sub} (u32 $\ast$v, u32 i, \hyperlink{atomics_8h_ae313282458f95fa2d743f519d988f4e7}{atomic\_\-compare\_\-t} cmp)
\begin{DoxyCompactList}\small\item\em Atomically subtract an integer. \item\end{DoxyCompactList}\item 
int \hyperlink{atomics_8h_a3e1ded518a76d91017821606685b2d9d}{atomics\_\-inc} (u32 $\ast$v, \hyperlink{atomics_8h_ae313282458f95fa2d743f519d988f4e7}{atomic\_\-compare\_\-t} cmp)
\begin{DoxyCompactList}\small\item\em Atomically increase an integer by 1. \item\end{DoxyCompactList}\item 
int \hyperlink{atomics_8h_a05cba72a80e5a27a85777b024516059a}{atomics\_\-dec} (u32 $\ast$v, \hyperlink{atomics_8h_ae313282458f95fa2d743f519d988f4e7}{atomic\_\-compare\_\-t} cmp)
\begin{DoxyCompactList}\small\item\em Atomically decrease an integer by 1. \item\end{DoxyCompactList}\item 
int \hyperlink{atomics_8h_a003c56da2d752bbfa8f8a5a524beb8c9}{atomics\_\-bitset} (u32 $\ast$v, u32 bit)
\begin{DoxyCompactList}\small\item\em Atomically set a bit in an integer. \item\end{DoxyCompactList}\item 
int \hyperlink{atomics_8h_a81047944e6c0e7da8b5522a9ba139488}{atomics\_\-bitclear} (u32 $\ast$v, u32 bit)
\begin{DoxyCompactList}\small\item\em Atomically clear a bit in an integer. \item\end{DoxyCompactList}\item 
int \hyperlink{atomics_8h_a44017d17475c8c0ab6d193d6e7f020f3}{atomics\_\-bitchange} (u32 $\ast$v, u32 bit)
\begin{DoxyCompactList}\small\item\em Atomically switch a bit in an integer. \item\end{DoxyCompactList}\item 
int \hyperlink{atomics_8h_adbaef918e21a6478f93e88203a2e70ef}{atomics\_\-bitcheck} (u32 $\ast$v, u32 bit)
\begin{DoxyCompactList}\small\item\em Atomically check a bit in an integer. \item\end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Atomic instruction wrappers 

\subsection{Enumeration Type Documentation}
\hypertarget{atomics_8h_ae313282458f95fa2d743f519d988f4e7}{
\index{atomics.h@{atomics.h}!atomic\_\-compare\_\-t@{atomic\_\-compare\_\-t}}
\index{atomic\_\-compare\_\-t@{atomic\_\-compare\_\-t}!atomics.h@{atomics.h}}
\subsubsection[{atomic\_\-compare\_\-t}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf atomic\_\-compare\_\-t}}}
\label{atomics_8h_ae313282458f95fa2d743f519d988f4e7}
An enumeration of the types of atomic comparisons available \begin{Desc}
\item[Enumerator: ]\par
\begin{description}
\index{ATOMIC\_\-COMPARE\_\-NONE@{ATOMIC\_\-COMPARE\_\-NONE}!atomics.h@{atomics.h}}\index{atomics.h@{atomics.h}!ATOMIC\_\-COMPARE\_\-NONE@{ATOMIC\_\-COMPARE\_\-NONE}}\item[{\em 
\hypertarget{atomics_8h_ae313282458f95fa2d743f519d988f4e7aa928025a0fa6e355ce5b68e004916124}{
ATOMIC\_\-COMPARE\_\-NONE}
\label{atomics_8h_ae313282458f95fa2d743f519d988f4e7aa928025a0fa6e355ce5b68e004916124}
}]Don't compare \index{ATOMIC\_\-COMPARE\_\-ZERO@{ATOMIC\_\-COMPARE\_\-ZERO}!atomics.h@{atomics.h}}\index{atomics.h@{atomics.h}!ATOMIC\_\-COMPARE\_\-ZERO@{ATOMIC\_\-COMPARE\_\-ZERO}}\item[{\em 
\hypertarget{atomics_8h_ae313282458f95fa2d743f519d988f4e7abc5fed4b3733b1656b762d414eae036e}{
ATOMIC\_\-COMPARE\_\-ZERO}
\label{atomics_8h_ae313282458f95fa2d743f519d988f4e7abc5fed4b3733b1656b762d414eae036e}
}]If the result is 0, return 1. Otherwise return 0. \index{ATOMIC\_\-COMPARE\_\-NEGATIVE@{ATOMIC\_\-COMPARE\_\-NEGATIVE}!atomics.h@{atomics.h}}\index{atomics.h@{atomics.h}!ATOMIC\_\-COMPARE\_\-NEGATIVE@{ATOMIC\_\-COMPARE\_\-NEGATIVE}}\item[{\em 
\hypertarget{atomics_8h_ae313282458f95fa2d743f519d988f4e7a7d17a2d7de9f1cc0db2c653b7e588e88}{
ATOMIC\_\-COMPARE\_\-NEGATIVE}
\label{atomics_8h_ae313282458f95fa2d743f519d988f4e7a7d17a2d7de9f1cc0db2c653b7e588e88}
}]If the result is negative, return 1. Otherwise return 0. \end{description}
\end{Desc}



\subsection{Function Documentation}
\hypertarget{atomics_8h_a0752848ba8203fd968f4f0e60d774d8c}{
\index{atomics.h@{atomics.h}!atomics\_\-add@{atomics\_\-add}}
\index{atomics\_\-add@{atomics\_\-add}!atomics.h@{atomics.h}}
\subsubsection[{atomics\_\-add}]{\setlength{\rightskip}{0pt plus 5cm}int atomics\_\-add (u32 $\ast$ {\em v}, \/  u32 {\em i}, \/  {\bf atomic\_\-compare\_\-t} {\em cmp})}}
\label{atomics_8h_a0752848ba8203fd968f4f0e60d774d8c}


Atomically add an integer. 


\begin{DoxyParams}{Parameters}
\item[{\em v}]a pointer to an integer to add to atomically. \item[{\em i}]the value to add to the integer. \item[{\em cmp}]the type of comparison to do with the result. \end{DoxyParams}
\begin{DoxyReturn}{Returns}
The result of the comparison. 
\end{DoxyReturn}
\hypertarget{atomics_8h_a44017d17475c8c0ab6d193d6e7f020f3}{
\index{atomics.h@{atomics.h}!atomics\_\-bitchange@{atomics\_\-bitchange}}
\index{atomics\_\-bitchange@{atomics\_\-bitchange}!atomics.h@{atomics.h}}
\subsubsection[{atomics\_\-bitchange}]{\setlength{\rightskip}{0pt plus 5cm}int atomics\_\-bitchange (u32 $\ast$ {\em v}, \/  u32 {\em bit})}}
\label{atomics_8h_a44017d17475c8c0ab6d193d6e7f020f3}


Atomically switch a bit in an integer. 


\begin{DoxyParams}{Parameters}
\item[{\em v}]a pointer to an integer to switch a bit in atomically. \item[{\em bit}]the bit index to switch. 0 is least significant bit. \end{DoxyParams}
\begin{DoxyReturn}{Returns}
The old value of the bit. If set, result is 1. 
\end{DoxyReturn}
\hypertarget{atomics_8h_adbaef918e21a6478f93e88203a2e70ef}{
\index{atomics.h@{atomics.h}!atomics\_\-bitcheck@{atomics\_\-bitcheck}}
\index{atomics\_\-bitcheck@{atomics\_\-bitcheck}!atomics.h@{atomics.h}}
\subsubsection[{atomics\_\-bitcheck}]{\setlength{\rightskip}{0pt plus 5cm}int atomics\_\-bitcheck (u32 $\ast$ {\em v}, \/  u32 {\em bit})}}
\label{atomics_8h_adbaef918e21a6478f93e88203a2e70ef}


Atomically check a bit in an integer. 


\begin{DoxyParams}{Parameters}
\item[{\em v}]a pointer to an integer to check a bit in atomically. \item[{\em bit}]the bit index to check. 0 is least significant bit. \end{DoxyParams}
\begin{DoxyReturn}{Returns}
The old value of the bit. If set, result is 1. 
\end{DoxyReturn}
\hypertarget{atomics_8h_a81047944e6c0e7da8b5522a9ba139488}{
\index{atomics.h@{atomics.h}!atomics\_\-bitclear@{atomics\_\-bitclear}}
\index{atomics\_\-bitclear@{atomics\_\-bitclear}!atomics.h@{atomics.h}}
\subsubsection[{atomics\_\-bitclear}]{\setlength{\rightskip}{0pt plus 5cm}int atomics\_\-bitclear (u32 $\ast$ {\em v}, \/  u32 {\em bit})}}
\label{atomics_8h_a81047944e6c0e7da8b5522a9ba139488}


Atomically clear a bit in an integer. 


\begin{DoxyParams}{Parameters}
\item[{\em v}]a pointer to an integer to clear a bit in atomically. \item[{\em bit}]the bit index to clear. 0 is least significant bit. \end{DoxyParams}
\begin{DoxyReturn}{Returns}
The old value of the bit. If set, result is 1. 
\end{DoxyReturn}
\hypertarget{atomics_8h_a003c56da2d752bbfa8f8a5a524beb8c9}{
\index{atomics.h@{atomics.h}!atomics\_\-bitset@{atomics\_\-bitset}}
\index{atomics\_\-bitset@{atomics\_\-bitset}!atomics.h@{atomics.h}}
\subsubsection[{atomics\_\-bitset}]{\setlength{\rightskip}{0pt plus 5cm}int atomics\_\-bitset (u32 $\ast$ {\em v}, \/  u32 {\em bit})}}
\label{atomics_8h_a003c56da2d752bbfa8f8a5a524beb8c9}


Atomically set a bit in an integer. 


\begin{DoxyParams}{Parameters}
\item[{\em v}]a pointer to an integer to set a bit in atomically. \item[{\em bit}]the bit index to set. 0 is least significant bit. \end{DoxyParams}
\begin{DoxyReturn}{Returns}
The old value of the bit. If set, result is 1. 
\end{DoxyReturn}
\hypertarget{atomics_8h_a05cba72a80e5a27a85777b024516059a}{
\index{atomics.h@{atomics.h}!atomics\_\-dec@{atomics\_\-dec}}
\index{atomics\_\-dec@{atomics\_\-dec}!atomics.h@{atomics.h}}
\subsubsection[{atomics\_\-dec}]{\setlength{\rightskip}{0pt plus 5cm}int atomics\_\-dec (u32 $\ast$ {\em v}, \/  {\bf atomic\_\-compare\_\-t} {\em cmp})}}
\label{atomics_8h_a05cba72a80e5a27a85777b024516059a}


Atomically decrease an integer by 1. 


\begin{DoxyParams}{Parameters}
\item[{\em v}]a pointer to an integer to decrease atomically. \item[{\em cmp}]the type of comparison to do with the result. \end{DoxyParams}
\begin{DoxyReturn}{Returns}
The result of the comparison. 
\end{DoxyReturn}
\hypertarget{atomics_8h_a3e1ded518a76d91017821606685b2d9d}{
\index{atomics.h@{atomics.h}!atomics\_\-inc@{atomics\_\-inc}}
\index{atomics\_\-inc@{atomics\_\-inc}!atomics.h@{atomics.h}}
\subsubsection[{atomics\_\-inc}]{\setlength{\rightskip}{0pt plus 5cm}int atomics\_\-inc (u32 $\ast$ {\em v}, \/  {\bf atomic\_\-compare\_\-t} {\em cmp})}}
\label{atomics_8h_a3e1ded518a76d91017821606685b2d9d}


Atomically increase an integer by 1. 


\begin{DoxyParams}{Parameters}
\item[{\em v}]a pointer to an integer to increase atomically. \item[{\em cmp}]the type of comparison to do with the result. \end{DoxyParams}
\begin{DoxyReturn}{Returns}
The result of the comparison. 
\end{DoxyReturn}
\hypertarget{atomics_8h_a6957e0a2509db392ab77b578a2ac6916}{
\index{atomics.h@{atomics.h}!atomics\_\-read@{atomics\_\-read}}
\index{atomics\_\-read@{atomics\_\-read}!atomics.h@{atomics.h}}
\subsubsection[{atomics\_\-read}]{\setlength{\rightskip}{0pt plus 5cm}u32 atomics\_\-read (u32 $\ast$ {\em v})}}
\label{atomics_8h_a6957e0a2509db392ab77b578a2ac6916}


Atomically read an integer. 


\begin{DoxyParams}{Parameters}
\item[{\em v}]a pointer to an integer to read atomically. \end{DoxyParams}
\begin{DoxyReturn}{Returns}
The value of the integer. 
\end{DoxyReturn}
\hypertarget{atomics_8h_af935efd83baeba7388ec5e326f02f465}{
\index{atomics.h@{atomics.h}!atomics\_\-set@{atomics\_\-set}}
\index{atomics\_\-set@{atomics\_\-set}!atomics.h@{atomics.h}}
\subsubsection[{atomics\_\-set}]{\setlength{\rightskip}{0pt plus 5cm}void atomics\_\-set (u32 $\ast$ {\em v}, \/  u32 {\em i})}}
\label{atomics_8h_af935efd83baeba7388ec5e326f02f465}


Atomically set the value of an integer. 


\begin{DoxyParams}{Parameters}
\item[{\em v}]a pointer to an integer to set atomically. \item[{\em i}]the value to set the integer to. \end{DoxyParams}
\hypertarget{atomics_8h_a6c026a49486555f0fd028f938c5ca634}{
\index{atomics.h@{atomics.h}!atomics\_\-sub@{atomics\_\-sub}}
\index{atomics\_\-sub@{atomics\_\-sub}!atomics.h@{atomics.h}}
\subsubsection[{atomics\_\-sub}]{\setlength{\rightskip}{0pt plus 5cm}int atomics\_\-sub (u32 $\ast$ {\em v}, \/  u32 {\em i}, \/  {\bf atomic\_\-compare\_\-t} {\em cmp})}}
\label{atomics_8h_a6c026a49486555f0fd028f938c5ca634}


Atomically subtract an integer. 


\begin{DoxyParams}{Parameters}
\item[{\em v}]a pointer to an integer to subtract from atomically. \item[{\em i}]the value to subtract the integer. \item[{\em cmp}]the type of comparison to do with the result. \end{DoxyParams}
\begin{DoxyReturn}{Returns}
The result of the comparison. 
\end{DoxyReturn}
