OSAtomicDeprecated.h [plain text]
#ifndef _OSATOMIC_DEPRECATED_H_
#define _OSATOMIC_DEPRECATED_H_
#if !(defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED)
#include <sys/cdefs.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <Availability.h>
#ifndef OSATOMIC_DEPRECATED
#define OSATOMIC_DEPRECATED 1
#ifndef __cplusplus
#define OSATOMIC_BARRIER_DEPRECATED_MSG(_r) \
"Use " #_r "() from <stdatomic.h> instead"
#define OSATOMIC_DEPRECATED_MSG(_r) \
"Use " #_r "_explicit(memory_order_relaxed) from <stdatomic.h> instead"
#else
#define OSATOMIC_BARRIER_DEPRECATED_MSG(_r) \
"Use std::" #_r "() from <atomic> instead"
#define OSATOMIC_DEPRECATED_MSG(_r) \
"Use std::" #_r "_explicit(std::memory_order_relaxed) from <atomic> instead"
#endif
#define OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(_r) \
__OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r))
#define OSATOMIC_DEPRECATED_REPLACE_WITH(_r) \
__OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSATOMIC_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSATOMIC_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSATOMIC_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSATOMIC_DEPRECATED_MSG(_r))
#else
#undef OSATOMIC_DEPRECATED
#define OSATOMIC_DEPRECATED 0
#define OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(_r)
#define OSATOMIC_DEPRECATED_REPLACE_WITH(_r)
#endif
__BEGIN_DECLS
#if __has_attribute(aligned)
typedef int64_t __attribute__((__aligned__((sizeof(int64_t)))))
OSAtomic_int64_aligned64_t;
#else
typedef int64_t OSAtomic_int64_aligned64_t;
#endif
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicAdd32( int32_t __theAmount, volatile int32_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicAdd32Barrier( int32_t __theAmount, volatile int32_t *__theValue );
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_1
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int32_t OSAtomicIncrement32( volatile int32_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int32_t OSAtomicIncrement32Barrier( volatile int32_t *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int32_t OSAtomicDecrement32( volatile int32_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue );
#else
__inline static
int32_t OSAtomicIncrement32( volatile int32_t *__theValue )
{ return OSAtomicAdd32( 1, __theValue); }
__inline static
int32_t OSAtomicIncrement32Barrier( volatile int32_t *__theValue )
{ return OSAtomicAdd32Barrier( 1, __theValue); }
__inline static
int32_t OSAtomicDecrement32( volatile int32_t *__theValue )
{ return OSAtomicAdd32( -1, __theValue); }
__inline static
int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue )
{ return OSAtomicAdd32Barrier( -1, __theValue); }
#endif
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int64_t OSAtomicAdd64( int64_t __theAmount,
volatile OSAtomic_int64_aligned64_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_3_2)
int64_t OSAtomicAdd64Barrier( int64_t __theAmount,
volatile OSAtomic_int64_aligned64_t *__theValue );
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_1
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int64_t OSAtomicIncrement64( volatile OSAtomic_int64_aligned64_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int64_t OSAtomicIncrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int64_t OSAtomicDecrement64( volatile OSAtomic_int64_aligned64_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int64_t OSAtomicDecrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue );
#else
__inline static
int64_t OSAtomicIncrement64( volatile OSAtomic_int64_aligned64_t *__theValue )
{ return OSAtomicAdd64( 1, __theValue); }
__inline static
int64_t OSAtomicIncrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue )
{ return OSAtomicAdd64Barrier( 1, __theValue); }
__inline static
int64_t OSAtomicDecrement64( volatile OSAtomic_int64_aligned64_t *__theValue )
{ return OSAtomicAdd64( -1, __theValue); }
__inline static
int64_t OSAtomicDecrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue )
{ return OSAtomicAdd64Barrier( -1, __theValue); }
#endif
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicOr32( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicOr32Barrier( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicOr32Orig( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicOr32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicAnd32( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicAnd32Barrier( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicAnd32Orig( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicAnd32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicXor32( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicXor32Barrier( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicXor32Orig( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicXor32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicCompareAndSwap32Barrier( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void *__newValue, void * volatile *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapInt( int __oldValue, int __newValue, volatile int *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapLong( long __oldValue, long __newValue, volatile long *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapLongBarrier( long __oldValue, long __newValue, volatile long *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue,
volatile OSAtomic_int64_aligned64_t *__theValue );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_3_2)
bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue,
volatile OSAtomic_int64_aligned64_t *__theValue );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicTestAndSet( uint32_t __n, volatile void *__theAddress );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicTestAndSetBarrier( uint32_t __n, volatile void *__theAddress );
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicTestAndClear( uint32_t __n, volatile void *__theAddress );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicTestAndClearBarrier( uint32_t __n, volatile void *__theAddress );
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_thread_fence)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
void OSMemoryBarrier( void );
__END_DECLS
#else // defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED
#include <sys/cdefs.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C++" {
#if !(__has_include(<atomic>) && __has_feature(cxx_atomic))
#error Cannot use inlined OSAtomic without <atomic> and C++11 atomics
#endif
#include <atomic>
typedef std::atomic<uint8_t> _OSAtomic_uint8_t;
typedef std::atomic<int32_t> _OSAtomic_int32_t;
typedef std::atomic<uint32_t> _OSAtomic_uint32_t;
typedef std::atomic<int64_t> _OSAtomic_int64_t;
typedef std::atomic<void*> _OSAtomic_void_ptr_t;
#define OSATOMIC_STD(_a) std::_a
__BEGIN_DECLS
#else
#if !(__has_include(<stdatomic.h>) && __has_extension(c_atomic))
#error Cannot use inlined OSAtomic without <stdatomic.h> and C11 atomics
#endif
#include <stdatomic.h>
typedef _Atomic(uint8_t) _OSAtomic_uint8_t;
typedef _Atomic(int32_t) _OSAtomic_int32_t;
typedef _Atomic(uint32_t) _OSAtomic_uint32_t;
typedef _Atomic(int64_t) _OSAtomic_int64_t;
typedef _Atomic(void*) _OSAtomic_void_ptr_t;
#define OSATOMIC_STD(_a) _a
#endif
#if __has_extension(c_alignof) && __has_attribute(aligned)
typedef int64_t __attribute__((__aligned__(_Alignof(_OSAtomic_int64_t))))
OSAtomic_int64_aligned64_t;
#elif __has_attribute(aligned)
typedef int64_t __attribute__((__aligned__((sizeof(_OSAtomic_int64_t)))))
OSAtomic_int64_aligned64_t;
#else
typedef int64_t OSAtomic_int64_aligned64_t;
#endif
#if __has_attribute(always_inline)
#define OSATOMIC_INLINE static __inline
#else
#define OSATOMIC_INLINE static __inline __attribute__((__always_inline__))
#endif
OSATOMIC_INLINE
int32_t
OSAtomicAdd32(int32_t __theAmount, volatile int32_t *__theValue)
{
return (OSATOMIC_STD(atomic_fetch_add_explicit)(
(volatile _OSAtomic_int32_t*) __theValue, __theAmount,
OSATOMIC_STD(memory_order_relaxed)) + __theAmount);
}
OSATOMIC_INLINE
int32_t
OSAtomicAdd32Barrier(int32_t __theAmount, volatile int32_t *__theValue)
{
return (OSATOMIC_STD(atomic_fetch_add_explicit)(
(volatile _OSAtomic_int32_t*) __theValue, __theAmount,
OSATOMIC_STD(memory_order_seq_cst)) + __theAmount);
}
OSATOMIC_INLINE
int32_t
OSAtomicIncrement32(volatile int32_t *__theValue)
{
return OSAtomicAdd32(1, __theValue);
}
OSATOMIC_INLINE
int32_t
OSAtomicIncrement32Barrier(volatile int32_t *__theValue)
{
return OSAtomicAdd32Barrier(1, __theValue);
}
OSATOMIC_INLINE
int32_t
OSAtomicDecrement32(volatile int32_t *__theValue)
{
return OSAtomicAdd32(-1, __theValue);
}
OSATOMIC_INLINE
int32_t
OSAtomicDecrement32Barrier(volatile int32_t *__theValue)
{
return OSAtomicAdd32Barrier(-1, __theValue);
}
OSATOMIC_INLINE
int64_t
OSAtomicAdd64(int64_t __theAmount,
volatile OSAtomic_int64_aligned64_t *__theValue)
{
return (OSATOMIC_STD(atomic_fetch_add_explicit)(
(volatile _OSAtomic_int64_t*) __theValue, __theAmount,
OSATOMIC_STD(memory_order_relaxed)) + __theAmount);
}
OSATOMIC_INLINE
int64_t
OSAtomicAdd64Barrier(int64_t __theAmount,
volatile OSAtomic_int64_aligned64_t *__theValue)
{
return (OSATOMIC_STD(atomic_fetch_add_explicit)(
(volatile _OSAtomic_int64_t*) __theValue, __theAmount,
OSATOMIC_STD(memory_order_seq_cst)) + __theAmount);
}
OSATOMIC_INLINE
int64_t
OSAtomicIncrement64(volatile OSAtomic_int64_aligned64_t *__theValue)
{
return OSAtomicAdd64(1, __theValue);
}
OSATOMIC_INLINE
int64_t
OSAtomicIncrement64Barrier(volatile OSAtomic_int64_aligned64_t *__theValue)
{
return OSAtomicAdd64Barrier(1, __theValue);
}
OSATOMIC_INLINE
int64_t
OSAtomicDecrement64(volatile OSAtomic_int64_aligned64_t *__theValue)
{
return OSAtomicAdd64(-1, __theValue);
}
OSATOMIC_INLINE
int64_t
OSAtomicDecrement64Barrier(volatile OSAtomic_int64_aligned64_t *__theValue)
{
return OSAtomicAdd64Barrier(-1, __theValue);
}
OSATOMIC_INLINE
int32_t
OSAtomicOr32(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)) | __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicOr32Barrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)) | __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicOr32Orig(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
int32_t
OSAtomicOr32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)));
}
OSATOMIC_INLINE
int32_t
OSAtomicAnd32(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)) & __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicAnd32Barrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)) & __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicAnd32Orig(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
int32_t
OSAtomicAnd32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)));
}
OSATOMIC_INLINE
int32_t
OSAtomicXor32(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)) ^ __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicXor32Barrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)) ^ __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicXor32Orig(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
int32_t
OSAtomicXor32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwap32(int32_t __oldValue, int32_t __newValue,
volatile int32_t *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_int32_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_relaxed),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwap32Barrier(int32_t __oldValue, int32_t __newValue,
volatile int32_t *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_int32_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_seq_cst),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapPtr(void *__oldValue, void *__newValue,
void * volatile *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_void_ptr_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_relaxed),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapPtrBarrier(void *__oldValue, void *__newValue,
void * volatile *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_void_ptr_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_seq_cst),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapInt(int __oldValue, int __newValue,
volatile int *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile OSATOMIC_STD(atomic_int)*)__theValue, &__oldValue,
__newValue, OSATOMIC_STD(memory_order_relaxed),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapIntBarrier(int __oldValue, int __newValue,
volatile int *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile OSATOMIC_STD(atomic_int)*)__theValue, &__oldValue,
__newValue, OSATOMIC_STD(memory_order_seq_cst),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapLong(long __oldValue, long __newValue,
volatile long *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile OSATOMIC_STD(atomic_long)*)__theValue, &__oldValue,
__newValue, OSATOMIC_STD(memory_order_relaxed),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapLongBarrier(long __oldValue, long __newValue,
volatile long *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile OSATOMIC_STD(atomic_long)*)__theValue, &__oldValue,
__newValue, OSATOMIC_STD(memory_order_seq_cst),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwap64(int64_t __oldValue, int64_t __newValue,
volatile OSAtomic_int64_aligned64_t *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_int64_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_relaxed),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwap64Barrier(int64_t __oldValue, int64_t __newValue,
volatile OSAtomic_int64_aligned64_t *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_int64_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_seq_cst),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicTestAndSet(uint32_t __n, volatile void *__theAddress)
{
uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
uint8_t v = (0x80u >> (__n & 7));
return (OSATOMIC_STD(atomic_fetch_or_explicit)((_OSAtomic_uint8_t*)a, v,
OSATOMIC_STD(memory_order_relaxed)) & v);
}
OSATOMIC_INLINE
bool
OSAtomicTestAndSetBarrier(uint32_t __n, volatile void *__theAddress)
{
uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
uint8_t v = (0x80u >> (__n & 7));
return (OSATOMIC_STD(atomic_fetch_or_explicit)((_OSAtomic_uint8_t*)a, v,
OSATOMIC_STD(memory_order_seq_cst)) & v);
}
OSATOMIC_INLINE
bool
OSAtomicTestAndClear(uint32_t __n, volatile void *__theAddress)
{
uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
uint8_t v = (0x80u >> (__n & 7));
return (OSATOMIC_STD(atomic_fetch_and_explicit)((_OSAtomic_uint8_t*)a,
(uint8_t)~v, OSATOMIC_STD(memory_order_relaxed)) & v);
}
OSATOMIC_INLINE
bool
OSAtomicTestAndClearBarrier(uint32_t __n, volatile void *__theAddress)
{
uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
uint8_t v = (0x80u >> (__n & 7));
return (OSATOMIC_STD(atomic_fetch_and_explicit)((_OSAtomic_uint8_t*)a,
(uint8_t)~v, OSATOMIC_STD(memory_order_seq_cst)) & v);
}
OSATOMIC_INLINE
void
OSMemoryBarrier(void)
{
OSATOMIC_STD(atomic_thread_fence)(OSATOMIC_STD(memory_order_seq_cst));
}
#undef OSATOMIC_INLINE
#undef OSATOMIC_STD
#ifdef __cplusplus
__END_DECLS
} #endif
#endif // defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED
#endif