\hypertarget{a00737_source}{}\doxysection{AAX\+\_\+\+Atomic.\+h}
\label{a00737_source}\index{AAX\_Atomic.h@{AAX\_Atomic.h}}
\mbox{\hyperlink{a00737}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ \ Copyright\ 2013-\/2015,\ 2018,\ 2023\ Avid\ Technology,\ Inc.}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ \ All\ rights\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ \ CONFIDENTIAL:\ this\ document\ contains\ confidential\ information\ of\ Avid.\ Do}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ \ not\ disclose\ to\ any\ third\ party.\ Use\ of\ the\ information\ contained\ in\ this}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ \ document\ is\ subject\ to\ an\ Avid\ SDK\ license.}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00010\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00011\ }
\DoxyCodeLine{00017\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00018\ }
\DoxyCodeLine{00019\ }
\DoxyCodeLine{00020\ \textcolor{preprocessor}{\#pragma\ once}}
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00022\ \textcolor{preprocessor}{\#ifndef\ AAX\_ATOMIC\_H\_}}
\DoxyCodeLine{00023\ \textcolor{preprocessor}{\#define\ AAX\_ATOMIC\_H\_}}
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00025\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00533}{AAX.h}}"{}}}
\DoxyCodeLine{00026\ \textcolor{preprocessor}{\#include\ <stdint.h>}}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00028\ \textcolor{preprocessor}{\#if\ (!defined\ AAX\_PointerSize)}}
\DoxyCodeLine{00029\ \textcolor{preprocessor}{\#error\ Undefined\ pointer\ size}}
\DoxyCodeLine{00030\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00031\ }
\DoxyCodeLine{00032\ }
\DoxyCodeLine{00034\ uint32\_t\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}\ \mbox{\hyperlink{a00737_a56633d7039fae1d31c8984f9baafa17e}{AAX\_Atomic\_IncThenGet\_32}}(uint32\_t\ \&\ ioData);}
\DoxyCodeLine{00035\ }
\DoxyCodeLine{00037\ uint32\_t\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}\ \mbox{\hyperlink{a00737_adb8e12a71f90de1328a4fde6dd22fc41}{AAX\_Atomic\_DecThenGet\_32}}(uint32\_t\ \&\ ioData);}
\DoxyCodeLine{00038\ }
\DoxyCodeLine{00040\ uint32\_t\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}\ \mbox{\hyperlink{a00737_a44eb82707be40dd559db9051317c10d0}{AAX\_Atomic\_Exchange\_32}}(}
\DoxyCodeLine{00041\ \ \ \ \ \textcolor{keyword}{volatile}\ uint32\_t\&\ ioValue,}
\DoxyCodeLine{00042\ \ \ \ \ uint32\_t\ \ \ \ \ \ \ \ \ \ \ inExchangeValue);}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00045\ uint64\_t\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}\ \mbox{\hyperlink{a00737_a0a683337ef8627f1e2b01e69d5f11cb0}{AAX\_Atomic\_Exchange\_64}}(}
\DoxyCodeLine{00046\ \ \ \ \ \textcolor{keyword}{volatile}\ uint64\_t\&\ ioValue,}
\DoxyCodeLine{00047\ \ \ \ \ uint64\_t\ \ \ \ \ \ \ \ \ \ \ inExchangeValue);}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00050\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ TPo\textcolor{keywordtype}{int}er>\ TPointer*\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}\ \mbox{\hyperlink{a00737_add2856260ffb4309c4e515bac8490bea}{AAX\_Atomic\_Exchange\_Pointer}}(TPointer*\&\ ioValue,\ TPointer*\ inExchangeValue)}
\DoxyCodeLine{00051\ \{}
\DoxyCodeLine{00052\ \textcolor{preprocessor}{\#if\ (AAX\_PointerSize\ ==\ AAXPointer\_64bit)}}
\DoxyCodeLine{00053\ \ \ \ \ \textcolor{keywordflow}{return}\ (TPointer*)\mbox{\hyperlink{a00737_a0a683337ef8627f1e2b01e69d5f11cb0}{AAX\_Atomic\_Exchange\_64}}(*(uint64\_t*)(\textcolor{keywordtype}{void}*)\&ioValue,\ (uint64\_t)inExchangeValue);}
\DoxyCodeLine{00054\ \textcolor{preprocessor}{\#elif\ (AAX\_PointerSize\ ==\ AAXPointer\_32bit)}}
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keywordflow}{return}\ (TPointer*)\mbox{\hyperlink{a00737_a44eb82707be40dd559db9051317c10d0}{AAX\_Atomic\_Exchange\_32}}(*(uint32\_t*)(\textcolor{keywordtype}{void}*)\&ioValue,\ (uint32\_t)inExchangeValue);}
\DoxyCodeLine{00056\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00057\ \textcolor{preprocessor}{\#error\ Unsupported\ pointer\ size}}
\DoxyCodeLine{00058\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00059\ \}}
\DoxyCodeLine{00060\ }
\DoxyCodeLine{00062\ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}\ \mbox{\hyperlink{a00737_a74a2bdb895976193bdfe4cd2fe31e21e}{AAX\_Atomic\_CompareAndExchange\_32}}(}
\DoxyCodeLine{00063\ \ \ \ \ \textcolor{keyword}{volatile}\ uint32\_t\ \&\ ioValue,}
\DoxyCodeLine{00064\ \ \ \ \ uint32\_t\ \ \ \ \ \ \ \ \ \ \ \ inCompareValue,}
\DoxyCodeLine{00065\ \ \ \ \ uint32\_t\ \ \ \ \ \ \ \ \ \ \ \ inExchangeValue);}
\DoxyCodeLine{00066\ }
\DoxyCodeLine{00068\ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}\ \mbox{\hyperlink{a00737_ae1e5b0cf8d8c7a301e13772a57a3d2fd}{AAX\_Atomic\_CompareAndExchange\_64}}(}
\DoxyCodeLine{00069\ \ \ \ \ \textcolor{keyword}{volatile}\ uint64\_t\&\ \ ioValue,}
\DoxyCodeLine{00070\ \ \ \ \ uint64\_t\ \ \ \ \ \ \ \ \ \ \ \ inCompareValue,}
\DoxyCodeLine{00071\ \ \ \ \ uint64\_t\ \ \ \ \ \ \ \ \ \ \ \ inExchangeValue);}
\DoxyCodeLine{00072\ }
\DoxyCodeLine{00074\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ TPo\textcolor{keywordtype}{int}er>\ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}\ \mbox{\hyperlink{a00737_ab1c7611e7c95fd61900b8e5a44c36e63}{AAX\_Atomic\_CompareAndExchange\_Pointer}}(TPointer*\&\ ioValue,\ TPointer*\ inCompareValue,\ TPointer*\ inExchangeValue)}
\DoxyCodeLine{00075\ \{}
\DoxyCodeLine{00076\ \textcolor{preprocessor}{\#if\ (AAX\_PointerSize\ ==\ AAXPointer\_64bit)}}
\DoxyCodeLine{00077\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00737_ae1e5b0cf8d8c7a301e13772a57a3d2fd}{AAX\_Atomic\_CompareAndExchange\_64}}(*(uint64\_t*)(\textcolor{keywordtype}{void}*)\&ioValue,\ (uint64\_t)inCompareValue,\ (uint64\_t)inExchangeValue);}
\DoxyCodeLine{00078\ \textcolor{preprocessor}{\#elif\ (AAX\_PointerSize\ ==\ AAXPointer\_32bit)}}
\DoxyCodeLine{00079\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00737_a74a2bdb895976193bdfe4cd2fe31e21e}{AAX\_Atomic\_CompareAndExchange\_32}}(*(uint32\_t*)(\textcolor{keywordtype}{void}*)\&ioValue,\ (uint32\_t)inCompareValue,\ (uint32\_t)inExchangeValue);}
\DoxyCodeLine{00080\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00081\ \textcolor{preprocessor}{\#error\ Unsupported\ pointer\ size}}
\DoxyCodeLine{00082\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00083\ \}}
\DoxyCodeLine{00084\ }
\DoxyCodeLine{00086\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ TPo\textcolor{keywordtype}{int}er>\ TPointer*\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}\ \mbox{\hyperlink{a00737_ace950fb6e426fd95d69da49462dfb878}{AAX\_Atomic\_Load\_Pointer}}(TPointer\ \textcolor{keyword}{const}\ *\ \textcolor{keyword}{const}\ \textcolor{keyword}{volatile}\ *\ inValue);}
\DoxyCodeLine{00087\ }
\DoxyCodeLine{00088\ }
\DoxyCodeLine{00089\ }
\DoxyCodeLine{00090\ \textcolor{comment}{//TODO:\ Update\ all\ atomic\ function\ implementatons\ with\ proper\ acquire/release\ semantics}}
\DoxyCodeLine{00091\ }
\DoxyCodeLine{00092\ }
\DoxyCodeLine{00093\ \textcolor{comment}{//\ GCC/LLVM}}
\DoxyCodeLine{00094\ \textcolor{preprocessor}{\#if\ defined(\_\_GNUC\_\_)}}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00096\ \textcolor{comment}{//\ These\ intrinsics\ require\ GCC\ 4.2\ or\ later}}
\DoxyCodeLine{00097\ \textcolor{preprocessor}{\#if\ (\_\_GNUC\_\_\ >\ 4\ ||\ (\_\_GNUC\_\_\ ==\ 4\ \&\&\ \_\_GNUC\_MINOR\_\_\ >=\ 2))}}
\DoxyCodeLine{00098\ }
\DoxyCodeLine{00099\ \textcolor{keyword}{inline}\ uint32\_t\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}}
\DoxyCodeLine{00100\ \mbox{\hyperlink{a00737_a56633d7039fae1d31c8984f9baafa17e}{AAX\_Atomic\_IncThenGet\_32}}(uint32\_t\&\ ioData)}
\DoxyCodeLine{00101\ \{}
\DoxyCodeLine{00102\ \ \ \ \ \textcolor{keywordflow}{return}\ \_\_sync\_add\_and\_fetch(\&ioData,\ 1);}
\DoxyCodeLine{00103\ \}}
\DoxyCodeLine{00104\ }
\DoxyCodeLine{00105\ \textcolor{keyword}{inline}\ uint32\_t\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}}
\DoxyCodeLine{00106\ \mbox{\hyperlink{a00737_adb8e12a71f90de1328a4fde6dd22fc41}{AAX\_Atomic\_DecThenGet\_32}}(uint32\_t\&\ ioData)}
\DoxyCodeLine{00107\ \{}
\DoxyCodeLine{00108\ \ \ \ \ \textcolor{keywordflow}{return}\ \_\_sync\_sub\_and\_fetch(\&ioData,\ 1);}
\DoxyCodeLine{00109\ \}}
\DoxyCodeLine{00110\ }
\DoxyCodeLine{00111\ \textcolor{keyword}{inline}\ uint32\_t}
\DoxyCodeLine{00112\ \mbox{\hyperlink{a00737_a44eb82707be40dd559db9051317c10d0}{AAX\_Atomic\_Exchange\_32}}(}
\DoxyCodeLine{00113\ \ \ \ \ \textcolor{keyword}{volatile}\ uint32\_t\&\ ioValue,}
\DoxyCodeLine{00114\ \ \ \ \ uint32\_t\ \ \ \ \ \ \ \ \ \ \ inExchangeValue)}
\DoxyCodeLine{00115\ \{}
\DoxyCodeLine{00116\ \ \ \ \ \textcolor{keywordflow}{return}\ \_\_sync\_lock\_test\_and\_set(\&ioValue,\ inExchangeValue);}
\DoxyCodeLine{00117\ \}}
\DoxyCodeLine{00118\ }
\DoxyCodeLine{00119\ \textcolor{keyword}{inline}\ uint64\_t}
\DoxyCodeLine{00120\ \mbox{\hyperlink{a00737_a0a683337ef8627f1e2b01e69d5f11cb0}{AAX\_Atomic\_Exchange\_64}}(}
\DoxyCodeLine{00121\ \ \ \ \ \textcolor{keyword}{volatile}\ uint64\_t\&\ ioValue,}
\DoxyCodeLine{00122\ \ \ \ \ uint64\_t\ \ \ \ \ \ \ \ \ \ \ inExchangeValue)}
\DoxyCodeLine{00123\ \{}
\DoxyCodeLine{00124\ \ \ \ \ \textcolor{keywordflow}{return}\ \_\_sync\_lock\_test\_and\_set(\&ioValue,\ inExchangeValue);}
\DoxyCodeLine{00125\ \}}
\DoxyCodeLine{00126\ }
\DoxyCodeLine{00127\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{bool}}
\DoxyCodeLine{00128\ \mbox{\hyperlink{a00737_a74a2bdb895976193bdfe4cd2fe31e21e}{AAX\_Atomic\_CompareAndExchange\_32}}(}
\DoxyCodeLine{00129\ \ \ \ \ \textcolor{keyword}{volatile}\ uint32\_t\ \&\ ioValue,}
\DoxyCodeLine{00130\ \ \ \ \ uint32\_t\ \ \ \ \ \ \ \ \ \ \ \ inCompareValue,}
\DoxyCodeLine{00131\ \ \ \ \ uint32\_t\ \ \ \ \ \ \ \ \ \ \ \ inExchangeValue)}
\DoxyCodeLine{00132\ \{}
\DoxyCodeLine{00133\ \ \ \ \ \textcolor{keywordflow}{return}\ \_\_sync\_bool\_compare\_and\_swap(\&ioValue,\ inCompareValue,\ inExchangeValue);}
\DoxyCodeLine{00134\ \}}
\DoxyCodeLine{00135\ }
\DoxyCodeLine{00136\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{bool}}
\DoxyCodeLine{00137\ \mbox{\hyperlink{a00737_ae1e5b0cf8d8c7a301e13772a57a3d2fd}{AAX\_Atomic\_CompareAndExchange\_64}}(}
\DoxyCodeLine{00138\ \ \ \ \ \textcolor{keyword}{volatile}\ uint64\_t\&\ \ ioValue,}
\DoxyCodeLine{00139\ \ \ \ \ uint64\_t\ \ \ \ \ \ \ \ \ \ \ \ inCompareValue,}
\DoxyCodeLine{00140\ \ \ \ \ uint64\_t\ \ \ \ \ \ \ \ \ \ \ \ inExchangeValue)}
\DoxyCodeLine{00141\ \{}
\DoxyCodeLine{00142\ \ \ \ \ \textcolor{keywordflow}{return}\ \_\_sync\_bool\_compare\_and\_swap(\&ioValue,\ inCompareValue,\ inExchangeValue);}
\DoxyCodeLine{00143\ \}}
\DoxyCodeLine{00144\ }
\DoxyCodeLine{00145\ \textcolor{comment}{//TODO:\ Add\ GCC\ version\ check\ and\ alternative\ implementations\ for\ GCC\ versions\ that\ do\ not\ support\ \_\_atomic\_load}}
\DoxyCodeLine{00146\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ TPo\textcolor{keywordtype}{int}er>}
\DoxyCodeLine{00147\ \textcolor{keyword}{inline}\ TPointer*}
\DoxyCodeLine{00148\ \mbox{\hyperlink{a00737_ace950fb6e426fd95d69da49462dfb878}{AAX\_Atomic\_Load\_Pointer}}(TPointer\ \textcolor{keyword}{const}\ *\ \textcolor{keyword}{const}\ \textcolor{keyword}{volatile}\ *\ inValue)}
\DoxyCodeLine{00149\ \{}
\DoxyCodeLine{00150\ \ \ \ \ TPointer*\ value;}
\DoxyCodeLine{00151\ \ \ \ \ \_\_atomic\_load(\textcolor{keyword}{const\_cast<}TPointer\ *\ \textcolor{keyword}{volatile\ }*\textcolor{keyword}{>}(inValue),\ \&(value),\ \_\_ATOMIC\_ACQUIRE);}
\DoxyCodeLine{00152\ \ \ \ \ \textcolor{keywordflow}{return}\ value;}
\DoxyCodeLine{00153\ \}}
\DoxyCodeLine{00154\ }
\DoxyCodeLine{00155\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//\ (\_\_GNUC\_\_\ >\ 4\ ||\ (\_\_GNUC\_\_\ ==\ 4\ \&\&\ \_\_GNUC\_MINOR\_\_\ >=\ 2))}}
\DoxyCodeLine{00156\ \textcolor{preprocessor}{\#error\ This\ file\ requires\ GCC\ 4.2\ or\ later}}
\DoxyCodeLine{00157\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ (\_\_GNUC\_\_\ >\ 4\ ||\ (\_\_GNUC\_\_\ ==\ 4\ \&\&\ \_\_GNUC\_MINOR\_\_\ >=\ 2))}}
\DoxyCodeLine{00158\ \textcolor{comment}{//\ End\ GCC/LLVM}}
\DoxyCodeLine{00159\ }
\DoxyCodeLine{00160\ }
\DoxyCodeLine{00161\ }
\DoxyCodeLine{00162\ }
\DoxyCodeLine{00163\ }
\DoxyCodeLine{00164\ \textcolor{comment}{//\ Visual\ C}}
\DoxyCodeLine{00165\ \textcolor{preprocessor}{\#elif\ defined(\_MSC\_VER)}}
\DoxyCodeLine{00166\ }
\DoxyCodeLine{00167\ \textcolor{preprocessor}{\#ifndef\ \_\_INTRIN\_H\_}}
\DoxyCodeLine{00168\ \textcolor{preprocessor}{\#include\ <intrin.h>}}
\DoxyCodeLine{00169\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00170\ }
\DoxyCodeLine{00171\ \textcolor{preprocessor}{\#pragma\ intrinsic(\ \ \_InterlockedIncrement,\ \(\backslash\)}}
\DoxyCodeLine{00172\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_InterlockedDecrement,\ \(\backslash\)}}
\DoxyCodeLine{00173\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_InterlockedExchange,\ \(\backslash\)}}
\DoxyCodeLine{00174\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_InterlockedCompareExchange,\ \(\backslash\)}}
\DoxyCodeLine{00175\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_InterlockedCompareExchange64)}}
\DoxyCodeLine{00176\ }
\DoxyCodeLine{00177\ \textcolor{keyword}{inline}\ uint32\_t\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}}
\DoxyCodeLine{00178\ \mbox{\hyperlink{a00737_a56633d7039fae1d31c8984f9baafa17e}{AAX\_Atomic\_IncThenGet\_32}}(\textcolor{keyword}{register}\ uint32\_t\&\ ioData)}
\DoxyCodeLine{00179\ \{}
\DoxyCodeLine{00180\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}uint32\_t\textcolor{keyword}{>}(\_InterlockedIncrement((\textcolor{keyword}{volatile}\ \textcolor{keywordtype}{long}*)\&ioData));}
\DoxyCodeLine{00181\ \}}
\DoxyCodeLine{00182\ }
\DoxyCodeLine{00183\ \textcolor{keyword}{inline}\ uint32\_t\ \mbox{\hyperlink{a00533_aaa22112139aa627574b1ef562f579d43}{AAX\_CALLBACK}}}
\DoxyCodeLine{00184\ \mbox{\hyperlink{a00737_adb8e12a71f90de1328a4fde6dd22fc41}{AAX\_Atomic\_DecThenGet\_32}}(\textcolor{keyword}{register}\ uint32\_t\&\ ioData)}
\DoxyCodeLine{00185\ \{}
\DoxyCodeLine{00186\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}uint32\_t\textcolor{keyword}{>}(\_InterlockedDecrement((\textcolor{keyword}{volatile}\ \textcolor{keywordtype}{long}*)\&ioData));}
\DoxyCodeLine{00187\ \}}
\DoxyCodeLine{00188\ }
\DoxyCodeLine{00189\ \textcolor{keyword}{inline}\ uint32\_t}
\DoxyCodeLine{00190\ \mbox{\hyperlink{a00737_a44eb82707be40dd559db9051317c10d0}{AAX\_Atomic\_Exchange\_32}}(}
\DoxyCodeLine{00191\ \ \ \ \ \textcolor{keyword}{volatile}\ uint32\_t\&\ ioDestination,}
\DoxyCodeLine{00192\ \ \ \ \ uint32\_t\ \ \ \ \ \ \ \ \ \ \ inExchangeValue)}
\DoxyCodeLine{00193\ \{}
\DoxyCodeLine{00194\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}uint32\_t\textcolor{keyword}{>}(\_InterlockedExchange((\textcolor{keyword}{volatile}\ \textcolor{keywordtype}{long}*)\&ioDestination,\ (\textcolor{keywordtype}{long})inExchangeValue));}
\DoxyCodeLine{00195\ \}}
\DoxyCodeLine{00196\ }
\DoxyCodeLine{00197\ \textcolor{preprocessor}{\#if\ (AAX\_PointerSize\ ==\ AAXPointer\_64bit)}}
\DoxyCodeLine{00198\ }
\DoxyCodeLine{00199\ \textcolor{preprocessor}{\#pragma\ intrinsic(\ \ \_InterlockedExchange64,\ \(\backslash\)}}
\DoxyCodeLine{00200\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_InterlockedOr64)}}
\DoxyCodeLine{00201\ }
\DoxyCodeLine{00202\ \textcolor{keyword}{inline}\ uint64\_t}
\DoxyCodeLine{00203\ \mbox{\hyperlink{a00737_a0a683337ef8627f1e2b01e69d5f11cb0}{AAX\_Atomic\_Exchange\_64}}(}
\DoxyCodeLine{00204\ \ \ \ \ \textcolor{keyword}{volatile}\ uint64\_t\&\ ioValue,}
\DoxyCodeLine{00205\ \ \ \ \ uint64\_t\ \ \ \ \ \ \ \ \ \ \ inExchangeValue)}
\DoxyCodeLine{00206\ \{}
\DoxyCodeLine{00207\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}uint64\_t\textcolor{keyword}{>}(\_InterlockedExchange64((\textcolor{keyword}{volatile}\ \_\_int64*)\&ioValue,\ (\_\_int64)inExchangeValue));}
\DoxyCodeLine{00208\ \}}
\DoxyCodeLine{00209\ }
\DoxyCodeLine{00210\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ TPo\textcolor{keywordtype}{int}er>}
\DoxyCodeLine{00211\ \textcolor{keyword}{inline}\ TPointer*}
\DoxyCodeLine{00212\ \mbox{\hyperlink{a00737_ace950fb6e426fd95d69da49462dfb878}{AAX\_Atomic\_Load\_Pointer}}(TPointer\ \textcolor{keyword}{const}\ *\ \textcolor{keyword}{const}\ \textcolor{keyword}{volatile}\ *\ inValue)}
\DoxyCodeLine{00213\ \{}
\DoxyCodeLine{00214\ \textcolor{comment}{//\ Itanium\ supports\ acquire\ semantics}}
\DoxyCodeLine{00215\ \textcolor{preprocessor}{\#if\ (\_M\_IA64)}}
\DoxyCodeLine{00216\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{reinterpret\_cast<}TPointer*\textcolor{keyword}{>}(\_InterlockedOr64\_acq(\textcolor{keyword}{const\_cast<}\_\_int64\ \textcolor{keyword}{volatile\ }*\textcolor{keyword}{>}(\textcolor{keyword}{reinterpret\_cast<}\textcolor{keyword}{const\ }\_\_int64\ \textcolor{keyword}{volatile\ }*\textcolor{keyword}{>}(inValue)),\ 0x0000000000000000));}
\DoxyCodeLine{00217\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00218\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{reinterpret\_cast<}TPointer*\textcolor{keyword}{>}(\_InterlockedOr64(\textcolor{keyword}{const\_cast<}\_\_int64\ \textcolor{keyword}{volatile\ }*\textcolor{keyword}{>}(\textcolor{keyword}{reinterpret\_cast<}\textcolor{keyword}{const\ }\_\_int64\ \textcolor{keyword}{volatile\ }*\textcolor{keyword}{>}(inValue)),\ 0x0000000000000000));}
\DoxyCodeLine{00219\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00220\ \}}
\DoxyCodeLine{00221\ }
\DoxyCodeLine{00222\ \textcolor{preprocessor}{\#elif\ (AAX\_PointerSize\ ==\ AAXPointer\_32bit)}}
\DoxyCodeLine{00223\ }
\DoxyCodeLine{00224\ \textcolor{preprocessor}{\#pragma\ intrinsic(\ \ \_InterlockedOr\ )}}
\DoxyCodeLine{00225\ }
\DoxyCodeLine{00226\ \textcolor{comment}{//\ \_InterlockedExchange64\ is\ not\ available\ on\ 32-\/bit\ Pentium\ in\ Visual\ C}}
\DoxyCodeLine{00227\ \textcolor{keyword}{inline}\ uint64\_t}
\DoxyCodeLine{00228\ \mbox{\hyperlink{a00737_a0a683337ef8627f1e2b01e69d5f11cb0}{AAX\_Atomic\_Exchange\_64}}(}
\DoxyCodeLine{00229\ \ \ \ \ \textcolor{keyword}{volatile}\ uint64\_t\&\ ioValue,}
\DoxyCodeLine{00230\ \ \ \ \ uint64\_t\ \ \ \ \ \ \ \ \ \ \ inExchangeValue)}
\DoxyCodeLine{00231\ \{}
\DoxyCodeLine{00232\ \ \ \ \ \textcolor{keywordflow}{for}(;;)}
\DoxyCodeLine{00233\ \ \ \ \ \{}
\DoxyCodeLine{00234\ \ \ \ \ \ \ \ \ uint64\_t\ \ \ \ result\ =\ ioValue;}
\DoxyCodeLine{00235\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(\mbox{\hyperlink{a00737_ae1e5b0cf8d8c7a301e13772a57a3d2fd}{AAX\_Atomic\_CompareAndExchange\_64}}(ioValue,\ result,\ inExchangeValue))}
\DoxyCodeLine{00236\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00237\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ result;}
\DoxyCodeLine{00238\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00239\ \ \ \ \ \}}
\DoxyCodeLine{00240\ \ \ \ \ }
\DoxyCodeLine{00241\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;\ \ \ \textcolor{comment}{//\ will\ never\ get\ here}}
\DoxyCodeLine{00242\ \}}
\DoxyCodeLine{00243\ }
\DoxyCodeLine{00244\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ TPo\textcolor{keywordtype}{int}er>}
\DoxyCodeLine{00245\ \textcolor{keyword}{inline}\ TPointer*}
\DoxyCodeLine{00246\ \mbox{\hyperlink{a00737_ace950fb6e426fd95d69da49462dfb878}{AAX\_Atomic\_Load\_Pointer}}(TPointer\ \textcolor{keyword}{const}\ *\ \textcolor{keyword}{const}\ \textcolor{keyword}{volatile}\ *\ inValue)}
\DoxyCodeLine{00247\ \{}
\DoxyCodeLine{00248\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{reinterpret\_cast<}TPointer*\textcolor{keyword}{>}(\_InterlockedOr(\textcolor{keyword}{const\_cast<}\textcolor{keywordtype}{long}\ \textcolor{keyword}{volatile\ }*\textcolor{keyword}{>}(\textcolor{keyword}{reinterpret\_cast<}\textcolor{keyword}{const\ }\textcolor{keywordtype}{long}\ \textcolor{keyword}{volatile\ }*\textcolor{keyword}{>}(inValue)),\ 0x00000000));}
\DoxyCodeLine{00249\ \}}
\DoxyCodeLine{00250\ }
\DoxyCodeLine{00251\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00252\ }
\DoxyCodeLine{00253\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{bool}}
\DoxyCodeLine{00254\ \mbox{\hyperlink{a00737_a74a2bdb895976193bdfe4cd2fe31e21e}{AAX\_Atomic\_CompareAndExchange\_32}}(}
\DoxyCodeLine{00255\ \ \ \ \ uint32\_t\ \textcolor{keyword}{volatile}\ \&\ ioValue,}
\DoxyCodeLine{00256\ \ \ \ \ uint32\_t\ \ \ \ \ \ \ \ \ \ \ \ inCompareValue,}
\DoxyCodeLine{00257\ \ \ \ \ uint32\_t\ \ \ \ \ \ \ \ \ \ \ \ inExchangeValue)}
\DoxyCodeLine{00258\ \{}
\DoxyCodeLine{00259\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}uint32\_t\textcolor{keyword}{>}(\_InterlockedCompareExchange((\textcolor{keyword}{volatile}\ \textcolor{keywordtype}{long}*)\&ioValue,\ (\textcolor{keywordtype}{long})inExchangeValue,\ (\textcolor{keywordtype}{long})inCompareValue))\ ==\ inCompareValue;}
\DoxyCodeLine{00260\ \}}
\DoxyCodeLine{00261\ }
\DoxyCodeLine{00262\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{bool}}
\DoxyCodeLine{00263\ \mbox{\hyperlink{a00737_ae1e5b0cf8d8c7a301e13772a57a3d2fd}{AAX\_Atomic\_CompareAndExchange\_64}}(}
\DoxyCodeLine{00264\ \ \ \ \ \textcolor{keyword}{volatile}\ uint64\_t\&\ \ ioValue,}
\DoxyCodeLine{00265\ \ \ \ \ uint64\_t\ \ \ \ \ \ \ \ \ \ \ \ inCompareValue,}
\DoxyCodeLine{00266\ \ \ \ \ uint64\_t\ \ \ \ \ \ \ \ \ \ \ \ inExchangeValue)}
\DoxyCodeLine{00267\ \{}
\DoxyCodeLine{00268\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}uint64\_t\textcolor{keyword}{>}(\_InterlockedCompareExchange64((\textcolor{keyword}{volatile}\ \_\_int64*)\&ioValue,\ (\_\_int64)inExchangeValue,\ (\_\_int64)inCompareValue))\ ==\ inCompareValue;}
\DoxyCodeLine{00269\ \}}
\DoxyCodeLine{00270\ }
\DoxyCodeLine{00271\ \textcolor{comment}{//\ End\ Visual\ C}}
\DoxyCodeLine{00272\ }
\DoxyCodeLine{00273\ }
\DoxyCodeLine{00274\ }
\DoxyCodeLine{00275\ }
\DoxyCodeLine{00276\ }
\DoxyCodeLine{00277\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{//\ Not\ Visual\ C\ or\ GCC/LLVM}}
\DoxyCodeLine{00278\ \textcolor{preprocessor}{\#error\ Provide\ an\ atomic\ operation\ implementation\ for\ this\ compiler}}
\DoxyCodeLine{00279\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ Compiler\ version\ check}}
\DoxyCodeLine{00280\ }
\DoxyCodeLine{00281\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ \#ifndef\ AAX\_ATOMIC\_H\_}}

\end{DoxyCode}
