16#if defined( MI_ARCH_X86) && (defined( MI_COMPILER_GCC) || defined( MI_COMPILER_ICC))
17# define MI_ATOM32_X86GCC
18#elif (__cplusplus >= 201103L)
21#elif defined( MI_ARCH_X86) && defined( MI_COMPILER_MSC)
22# define MI_ATOM32_X86MSC
24# pragma intrinsic( _InterlockedExchangeAdd)
25# pragma intrinsic( _InterlockedCompareExchange)
27# define MI_ATOM32_GENERIC
49#if defined( MI_ATOM32_STD) || defined( MI_ATOM32_GENERIC)
79 operator Uint32()
const {
return m_value; }
85#if defined( MI_ATOM32_STD)
87#if defined( MI_COMPILER_GCC) && (__GNUC__ <= 6)
88 std::atomic<std::uint32_t> m_value;
90 std::atomic_uint32_t m_value;
97#if defined( MI_ATOM32_GENERIC)
103#if !defined( MI_FOR_DOXYGEN_ONLY)
105#if defined( MI_ATOM32_X86GCC)
112 "lock; xaddl %0,%1\n"
114 :
"=&r"( retval),
"+m"( m_value)
127 "lock; xaddl %0,%1\n"
129 :
"=&r"( retval),
"+m"( m_value)
141 "lock; xaddl %0,%1\n"
143 :
"=&r"( retval),
"+m"( m_value)
155 "lock; xaddl %0,%1\n"
156 :
"=&r"( retval),
"+m"( m_value)
168 "lock; xaddl %0,%1\n"
170 :
"=&r"( retval),
"+m"( m_value)
182 "lock; xaddl %0,%1\n"
183 :
"=&r"( retval),
"+m"( m_value)
196 "lock; cmpxchg %2,%1\n"
198 :
"=&a"( retval),
"+m"( m_value)
205#elif defined( MI_ATOM32_STD)
207inline Atom32::Atom32(
const Atom32& other) : m_value( other.m_value.load()) { }
211 m_value = rhs.m_value.load();
249 return m_value.exchange( rhs);
252#elif defined( MI_ATOM32_X86MSC)
256 return _InterlockedExchangeAdd(
reinterpret_cast<volatile long*
>( &m_value), rhs) + rhs;
261 return _InterlockedExchangeAdd(
262 reinterpret_cast<volatile long*
>( &m_value), -
static_cast<const Sint32>( rhs)) - rhs;
267 return _InterlockedExchangeAdd(
reinterpret_cast<volatile long*
>( &m_value), 1L) + 1L;
272 return _InterlockedExchangeAdd(
reinterpret_cast<volatile long*
>( &m_value), 1L);
277 return _InterlockedExchangeAdd(
reinterpret_cast<volatile long*
>( &m_value), -1L) - 1L;
282 return _InterlockedExchangeAdd(
reinterpret_cast<volatile long*
>( &m_value), -1L);
287 return _InterlockedExchange(
reinterpret_cast<volatile long*
>( &m_value), rhs);
290#elif defined( MI_ATOM32_GENERIC)
292inline Atom32::Atom32(
const Atom32& other) : m_value( other.m_value) { }
296 m_value = rhs.m_value;
303 return m_value += rhs;
309 return m_value -= rhs;
345#error One of MI_ATOM32_X86GCC, MI_ATOM32_STD, MI_ATOM32_X86MSC, or MI_ATOM32_GENERIC must be \
349#undef MI_ATOM32_X86GCC
351#undef MI_ATOM32_X86MSC
352#undef MI_ATOM32_GENERIC
A 32-bit unsigned counter with atomic arithmetic, increments, and decrements.
Definition: atom.h:41
Utility class to acquire a lock that is released by the destructor.
Definition: lock.h:61
Non-recursive lock class.
Definition: lock.h:49
Configuration of the Base API.
Uint32 operator-=(const Uint32 rhs)
Subtracts rhs from the counter.
Uint32 operator--(int)
Decrements the counter by one (post-decrement).
Atom32()
The default constructor initializes the counter to zero.
Definition: atom.h:44
Uint32 operator+=(const Uint32 rhs)
Adds rhs to the counter.
Uint32 operator=(const Uint32 rhs)
Assigns rhs to the counter.
Definition: atom.h:58
Uint32 operator++(int)
Increments the counter by one (post-increment).
Atom32(const Uint32 value)
This constructor initializes the counter to value.
Definition: atom.h:47
Atom32(const Atom32 &other)
The copy constructor assigns the value of other to the counter.
Uint32 operator++()
Increments the counter by one (pre-increment).
Atom32 & operator=(const Atom32 &rhs)
Assigns the value of rhs to the counter.
Uint32 swap(const Uint32 rhs)
Assigns rhs to the counter and returns the old value of counter.
Uint32 operator--()
Decrements the counter by one (pre-decrement).
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
signed int Sint32
32-bit signed integer.
Definition: types.h:46
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: base.h:34