Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
81a3b5d0
Commit
81a3b5d0
authored
Jan 20, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update c89atomic.
parent
a389b65a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
568 additions
and
423 deletions
+568
-423
miniaudio.h
miniaudio.h
+568
-423
No files found.
miniaudio.h
View file @
81a3b5d0
...
...
@@ -8255,7 +8255,6 @@ typedef unsigned int c89atomic_uint32;
#endif
typedef int c89atomic_memory_order;
typedef unsigned char c89atomic_bool;
typedef unsigned char c89atomic_flag;
#if !defined(C89ATOMIC_64BIT) && !defined(C89ATOMIC_32BIT)
#ifdef _WIN32
#ifdef _WIN64
...
...
@@ -8302,6 +8301,10 @@ typedef unsigned char c89atomic_flag;
#else
#define C89ATOMIC_INLINE
#endif
#define C89ATOMIC_HAS_8
#define C89ATOMIC_HAS_16
#define C89ATOMIC_HAS_32
#define C89ATOMIC_HAS_64
#if (defined(_MSC_VER) ) || defined(__WATCOMC__) || defined(__DMC__)
#define c89atomic_memory_order_relaxed 0
#define c89atomic_memory_order_consume 1
...
...
@@ -8309,75 +8312,93 @@ typedef unsigned char c89atomic_flag;
#define c89atomic_memory_order_release 3
#define c89atomic_memory_order_acq_rel 4
#define c89atomic_memory_order_seq_cst 5
#if _MSC_VER >= 1400
#include <intrin.h>
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint8)_InterlockedExchange8((volatile char*)dst, (char)src);
}
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint16)_InterlockedExchange16((volatile short*)dst, (short)src);
}
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint32)_InterlockedExchange((volatile long*)dst, (long)src);
}
#if defined(C89ATOMIC_64BIT)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint64)_InterlockedExchange64((volatile long long*)dst, (long long)src);
}
#if _MSC_VER < 1600 && defined(C89ATOMIC_32BIT)
#define C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY
#endif
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint8)_InterlockedExchangeAdd8((volatile char*)dst, (char)src);
}
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint16)_InterlockedExchangeAdd16((volatile short*)dst, (short)src);
}
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint32)_InterlockedExchangeAdd((volatile long*)dst, (long)src);
}
#if defined(C89ATOMIC_64BIT)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint64)_InterlockedExchangeAdd64((volatile long long*)dst, (long long)src);
}
#if _MSC_VER < 1600
#undef C89ATOMIC_HAS_8
#undef C89ATOMIC_HAS_16
#endif
#define c89atomic_compare_and_swap_8( dst, expected, desired) (c89atomic_uint8 )_InterlockedCompareExchange8 ((volatile char* )dst, (char )desired, (char )expected)
#define c89atomic_compare_and_swap_16(dst, expected, desired) (c89atomic_uint16)_InterlockedCompareExchange16((volatile short* )dst, (short )desired, (short )expected)
#define c89atomic_compare_and_swap_32(dst, expected, desired) (c89atomic_uint32)_InterlockedCompareExchange ((volatile long* )dst, (long )desired, (long )expected)
#define c89atomic_compare_and_swap_64(dst, expected, desired) (c89atomic_uint64)_InterlockedCompareExchange64((volatile long long*)dst, (long long)desired, (long long)expected)
#if defined(C89ATOMIC_X64)
#define c89atomic_thread_fence(order) __faststorefence(), (void)order
#else
static C89ATOMIC_INLINE void c89atomic_thread_fence(c89atomic_memory_order order)
{
volatile c89atomic_uint32 barrier = 0;
(void)order;
c89atomic_fetch_add_explicit_32(&barrier, 0, order);
}
#if !defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
#include <intrin.h>
#endif
#
else
#if defined(C89ATOMIC_
X86
)
static C89ATOMIC_INLINE
void __stdcall c89atomic_thread_fence(c89atomic_memory_order order
)
#
if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
#if defined(C89ATOMIC_
HAS_8
)
static C89ATOMIC_INLINE
c89atomic_uint8 __stdcall c89atomic_compare_and_swap_8(volatile c89atomic_uint8* dst, c89atomic_uint8 expected, c89atomic_uint8 desired
)
{
(void)order
;
c89atomic_uint8 result = 0
;
__asm {
lock add [esp], 0
mov ecx, dst
mov al, expected
mov dl, desired
lock cmpxchg [ecx], dl
mov result, al
}
return result;
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_compare_and_swap_16(volatile c89atomic_uint16* dst, c89atomic_uint16 expected, c89atomic_uint16 desired)
{
c89atomic_uint16 result = 0;
__asm {
mov ecx, dst
mov ax, expected
mov dx, desired
lock cmpxchg [ecx], dx
mov result, ax
}
return result;
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_compare_and_swap_32(volatile c89atomic_uint32* dst, c89atomic_uint32 expected, c89atomic_uint32 desired)
{
c89atomic_uint32 result = 0;
__asm {
mov ecx, dst
mov eax, expected
mov edx, desired
lock cmpxchg [ecx], edx
mov result, eax
}
return result;
}
#endif
#if defined(C89ATOMIC_HAS_64)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_compare_and_swap_64(volatile c89atomic_uint64* dst, c89atomic_uint64 expected, c89atomic_uint64 desired)
{
c89atomic_uint32 resultEAX = 0;
c89atomic_uint32 resultEDX = 0;
__asm {
mov esi, dst
mov eax, dword ptr expected
mov edx, dword ptr expected + 4
mov ebx, dword ptr desired
mov ecx, dword ptr desired + 4
lock cmpxchg8b qword ptr [esi]
mov resultEAX, eax
mov resultEDX, edx
}
return ((c89atomic_uint64)resultEDX << 32) | resultEAX;
}
#endif
#else
#if defined(C89ATOMIC_HAS_8)
#define c89atomic_compare_and_swap_8( dst, expected, desired) (c89atomic_uint8 )_InterlockedCompareExchange8((volatile char*)dst, (char)desired, (char)expected)
#endif
#if defined(C89ATOMIC_HAS_16)
#define c89atomic_compare_and_swap_16(dst, expected, desired) (c89atomic_uint16)_InterlockedCompareExchange16((volatile short*)dst, (short)desired, (short)expected)
#endif
#if defined(C89ATOMIC_HAS_32)
#define c89atomic_compare_and_swap_32(dst, expected, desired) (c89atomic_uint32)_InterlockedCompareExchange((volatile long*)dst, (long)desired, (long)expected)
#endif
#if defined(C89ATOMIC_HAS_64)
#define c89atomic_compare_and_swap_64(dst, expected, desired) (c89atomic_uint64)_InterlockedCompareExchange64((volatile long long*)dst, (long long)desired, (long long)expected)
#endif
#endif
#if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
c89atomic_uint8 result = 0;
...
...
@@ -8390,6 +8411,8 @@ typedef unsigned char c89atomic_flag;
}
return result;
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
c89atomic_uint16 result = 0;
...
...
@@ -8402,6 +8425,8 @@ typedef unsigned char c89atomic_flag;
}
return result;
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
c89atomic_uint32 result = 0;
...
...
@@ -8414,6 +8439,51 @@ typedef unsigned char c89atomic_flag;
}
return result;
}
#endif
#else
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint8)_InterlockedExchange8((volatile char*)dst, (char)src);
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint16)_InterlockedExchange16((volatile short*)dst, (short)src);
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint32)_InterlockedExchange((volatile long*)dst, (long)src);
}
#endif
#if defined(C89ATOMIC_HAS_64) && defined(C89ATOMIC_64BIT)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
(void)order;
return (c89atomic_uint64)_InterlockedExchange64((volatile long long*)dst, (long long)src);
}
#else
#endif
#endif
#if defined(C89ATOMIC_HAS_64) && !defined(C89ATOMIC_64BIT)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
do {
oldValue = *dst;
} while (c89atomic_compare_and_swap_64(dst, oldValue, src) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
c89atomic_uint8 result = 0;
...
...
@@ -8426,6 +8496,8 @@ typedef unsigned char c89atomic_flag;
}
return result;
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
c89atomic_uint16 result = 0;
...
...
@@ -8438,6 +8510,8 @@ typedef unsigned char c89atomic_flag;
}
return result;
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
c89atomic_uint32 result = 0;
...
...
@@ -8450,314 +8524,371 @@ typedef unsigned char c89atomic_flag;
}
return result;
}
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_compare_and_swap_8(volatile c89atomic_uint8* dst, c89atomic_uint8 expected, c89atomic_uint8 desired)
#endif
#else
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
c89atomic_uint8 result = 0;
__asm {
mov ecx, dst
mov al, expected
mov dl, desired
lock cmpxchg [ecx], dl
mov result, al
}
return result;
(void)order;
return (c89atomic_uint8)_InterlockedExchangeAdd8((volatile char*)dst, (char)src);
}
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_compare_and_swap_16(volatile c89atomic_uint16* dst, c89atomic_uint16 expected, c89atomic_uint16 desired)
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
c89atomic_uint16 result = 0;
__asm {
mov ecx, dst
mov ax, expected
mov dx, desired
lock cmpxchg [ecx], dx
mov result, ax
}
return result;
(void)order;
return (c89atomic_uint16)_InterlockedExchangeAdd16((volatile short*)dst, (short)src);
}
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_compare_and_swap_32(volatile c89atomic_uint32* dst, c89atomic_uint32 expected, c89atomic_uint32 desired)
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
c89atomic_uint32 result = 0;
__asm {
mov ecx, dst
mov eax, expected
mov edx, desired
lock cmpxchg [ecx], edx
mov result, eax
}
return result;
(void)order;
return (c89atomic_uint32)_InterlockedExchangeAdd((volatile long*)dst, (long)src);
}
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_compare_and_swap_64(volatile c89atomic_uint64* dst, c89atomic_uint64 expected, c89atomic_uint64 desired)
#endif
#if defined(C89ATOMIC_HAS_64) && defined(C89ATOMIC_64BIT)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
c89atomic_uint32 resultEAX = 0;
c89atomic_uint32 resultEDX = 0;
__asm {
mov esi, dst
mov eax, dword ptr expected
mov edx, dword ptr expected + 4
mov ebx, dword ptr desired
mov ecx, dword ptr desired + 4
lock cmpxchg8b qword ptr [esi]
mov resultEAX, eax
mov resultEDX, edx
}
return ((c89atomic_uint64)resultEDX << 32) | resultEAX;
(void)order;
return (c89atomic_uint64)_InterlockedExchangeAdd64((volatile long long*)dst, (long long)src);
}
#else
#error Unsupported architecture.
#endif
#endif
#define c89atomic_compiler_fence() c89atomic_thread_fence(c89atomic_memory_order_seq_cst)
#define c89atomic_signal_fence(order) c89atomic_thread_fence(order)
static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_load_explicit_8(volatile c89atomic_uint8* ptr, c89atomic_memory_order order)
{
(void)order;
return c89atomic_compare_and_swap_8(ptr, 0, 0);
}
static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_load_explicit_16(volatile c89atomic_uint16* ptr, c89atomic_memory_order order)
{
(void)order;
return c89atomic_compare_and_swap_16(ptr, 0, 0);
}
static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_load_explicit_32(volatile c89atomic_uint32* ptr, c89atomic_memory_order order)
{
(void)order;
return c89atomic_compare_and_swap_32(ptr, 0, 0);
}
static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_load_explicit_64(volatile c89atomic_uint64* ptr, c89atomic_memory_order order)
{
(void)order;
return c89atomic_compare_and_swap_64(ptr, 0, 0);
}
#define c89atomic_store_explicit_8( dst, src, order) (void)c89atomic_exchange_explicit_8 (dst, src, order)
#define c89atomic_store_explicit_16(dst, src, order) (void)c89atomic_exchange_explicit_16(dst, src, order)
#define c89atomic_store_explicit_32(dst, src, order) (void)c89atomic_exchange_explicit_32(dst, src, order)
#define c89atomic_store_explicit_64(dst, src, order) (void)c89atomic_exchange_explicit_64(dst, src, order)
#if defined(C89ATOMIC_32BIT)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
do {
oldValue = *dst;
} while (c89atomic_compare_and_swap_64(dst, oldValue, src) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
oldValue = *dst;
newValue = oldValue + src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_sub_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
volatile c89atomic_uint8 oldValue;
volatile c89atomic_uint8 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint8)(oldValue - src);
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_sub_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
volatile c89atomic_uint16 oldValue;
volatile c89atomic_uint16 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint16)(oldValue - src);
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_sub_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
volatile c89atomic_uint32 oldValue;
volatile c89atomic_uint32 newValue;
do {
oldValue = *dst;
newValue = oldValue - src;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_sub_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
oldValue = *dst;
newValue = oldValue - src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_and_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
volatile c89atomic_uint8 oldValue;
volatile c89atomic_uint8 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint8)(oldValue & src);
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_and_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
volatile c89atomic_uint16 oldValue;
volatile c89atomic_uint16 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint16)(oldValue & src);
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_and_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
volatile c89atomic_uint32 oldValue;
volatile c89atomic_uint32 newValue;
do {
oldValue = *dst;
newValue = oldValue & src;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_and_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
oldValue = *dst;
newValue = oldValue & src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_xor_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
volatile c89atomic_uint8 oldValue;
volatile c89atomic_uint8 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint8)(oldValue ^ src);
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_xor_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
volatile c89atomic_uint16 oldValue;
volatile c89atomic_uint16 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint16)(oldValue ^ src);
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_xor_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
volatile c89atomic_uint32 oldValue;
volatile c89atomic_uint32 newValue;
do {
oldValue = *dst;
newValue = oldValue ^ src;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_xor_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
oldValue = *dst;
newValue = oldValue ^ src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_or_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
volatile c89atomic_uint8 oldValue;
volatile c89atomic_uint8 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint8)(oldValue | src);
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_or_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
volatile c89atomic_uint16 oldValue;
volatile c89atomic_uint16 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint16)(oldValue | src);
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_or_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
volatile c89atomic_uint32 oldValue;
volatile c89atomic_uint32 newValue;
do {
oldValue = *dst;
newValue = oldValue | src;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_or_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
oldValue = *dst;
newValue = oldValue | src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#define c89atomic_test_and_set_explicit_8( dst, order) c89atomic_exchange_explicit_8 (dst, 1, order)
#define c89atomic_test_and_set_explicit_16(dst, order) c89atomic_exchange_explicit_16(dst, 1, order)
#define c89atomic_test_and_set_explicit_32(dst, order) c89atomic_exchange_explicit_32(dst, 1, order)
#define c89atomic_test_and_set_explicit_64(dst, order) c89atomic_exchange_explicit_64(dst, 1, order)
#define c89atomic_clear_explicit_8( dst, order) c89atomic_store_explicit_8 (dst, 0, order)
#define c89atomic_clear_explicit_16(dst, order) c89atomic_store_explicit_16(dst, 0, order)
#define c89atomic_clear_explicit_32(dst, order) c89atomic_store_explicit_32(dst, 0, order)
#define c89atomic_clear_explicit_64(dst, order) c89atomic_store_explicit_64(dst, 0, order)
#define c89atomic_flag_test_and_set_explicit(ptr, order) (c89atomic_flag)c89atomic_test_and_set_explicit_8(ptr, order)
#define c89atomic_flag_clear_explicit(ptr, order) c89atomic_clear_explicit_8(ptr, order)
#if defined(C89ATOMIC_HAS_64) && !defined(C89ATOMIC_64BIT)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
oldValue = *dst;
newValue = oldValue + src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
static C89ATOMIC_INLINE void __stdcall c89atomic_thread_fence(c89atomic_memory_order order)
{
(void)order;
__asm {
lock add [esp], 0
}
}
#else
#if defined(C89ATOMIC_X64)
#define c89atomic_thread_fence(order) __faststorefence(), (void)order
#else
static C89ATOMIC_INLINE void c89atomic_thread_fence(c89atomic_memory_order order)
{
volatile c89atomic_uint32 barrier = 0;
c89atomic_fetch_add_explicit_32(&barrier, 0, order);
}
#endif
#endif
#define c89atomic_compiler_fence() c89atomic_thread_fence(c89atomic_memory_order_seq_cst)
#define c89atomic_signal_fence(order) c89atomic_thread_fence(order)
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_load_explicit_8(volatile c89atomic_uint8* ptr, c89atomic_memory_order order)
{
(void)order;
return c89atomic_compare_and_swap_8(ptr, 0, 0);
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_load_explicit_16(volatile c89atomic_uint16* ptr, c89atomic_memory_order order)
{
(void)order;
return c89atomic_compare_and_swap_16(ptr, 0, 0);
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_load_explicit_32(volatile c89atomic_uint32* ptr, c89atomic_memory_order order)
{
(void)order;
return c89atomic_compare_and_swap_32(ptr, 0, 0);
}
#endif
#if defined(C89ATOMIC_HAS_64)
static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_load_explicit_64(volatile c89atomic_uint64* ptr, c89atomic_memory_order order)
{
(void)order;
return c89atomic_compare_and_swap_64(ptr, 0, 0);
}
#endif
#if defined(C89ATOMIC_HAS_8)
#define c89atomic_store_explicit_8( dst, src, order) (void)c89atomic_exchange_explicit_8 (dst, src, order)
#endif
#if defined(C89ATOMIC_HAS_16)
#define c89atomic_store_explicit_16(dst, src, order) (void)c89atomic_exchange_explicit_16(dst, src, order)
#endif
#if defined(C89ATOMIC_HAS_32)
#define c89atomic_store_explicit_32(dst, src, order) (void)c89atomic_exchange_explicit_32(dst, src, order)
#endif
#if defined(C89ATOMIC_HAS_64)
#define c89atomic_store_explicit_64(dst, src, order) (void)c89atomic_exchange_explicit_64(dst, src, order)
#endif
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_sub_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
volatile c89atomic_uint8 oldValue;
volatile c89atomic_uint8 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint8)(oldValue - src);
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_sub_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
volatile c89atomic_uint16 oldValue;
volatile c89atomic_uint16 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint16)(oldValue - src);
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_sub_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
volatile c89atomic_uint32 oldValue;
volatile c89atomic_uint32 newValue;
do {
oldValue = *dst;
newValue = oldValue - src;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_64)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_sub_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
oldValue = *dst;
newValue = oldValue - src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_and_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
volatile c89atomic_uint8 oldValue;
volatile c89atomic_uint8 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint8)(oldValue & src);
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_and_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
volatile c89atomic_uint16 oldValue;
volatile c89atomic_uint16 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint16)(oldValue & src);
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_and_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
volatile c89atomic_uint32 oldValue;
volatile c89atomic_uint32 newValue;
do {
oldValue = *dst;
newValue = oldValue & src;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_64)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_and_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
oldValue = *dst;
newValue = oldValue & src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_xor_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
volatile c89atomic_uint8 oldValue;
volatile c89atomic_uint8 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint8)(oldValue ^ src);
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_xor_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
volatile c89atomic_uint16 oldValue;
volatile c89atomic_uint16 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint16)(oldValue ^ src);
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_xor_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
volatile c89atomic_uint32 oldValue;
volatile c89atomic_uint32 newValue;
do {
oldValue = *dst;
newValue = oldValue ^ src;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_64)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_xor_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
oldValue = *dst;
newValue = oldValue ^ src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_or_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
volatile c89atomic_uint8 oldValue;
volatile c89atomic_uint8 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint8)(oldValue | src);
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_or_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
volatile c89atomic_uint16 oldValue;
volatile c89atomic_uint16 newValue;
do {
oldValue = *dst;
newValue = (c89atomic_uint16)(oldValue | src);
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_or_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
volatile c89atomic_uint32 oldValue;
volatile c89atomic_uint32 newValue;
do {
oldValue = *dst;
newValue = oldValue | src;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_64)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_or_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
oldValue = *dst;
newValue = oldValue | src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
}
#endif
#if defined(C89ATOMIC_HAS_8)
#define c89atomic_test_and_set_explicit_8( dst, order) c89atomic_exchange_explicit_8 (dst, 1, order)
#endif
#if defined(C89ATOMIC_HAS_16)
#define c89atomic_test_and_set_explicit_16(dst, order) c89atomic_exchange_explicit_16(dst, 1, order)
#endif
#if defined(C89ATOMIC_HAS_32)
#define c89atomic_test_and_set_explicit_32(dst, order) c89atomic_exchange_explicit_32(dst, 1, order)
#endif
#if defined(C89ATOMIC_HAS_64)
#define c89atomic_test_and_set_explicit_64(dst, order) c89atomic_exchange_explicit_64(dst, 1, order)
#endif
#if defined(C89ATOMIC_HAS_8)
#define c89atomic_clear_explicit_8( dst, order) c89atomic_store_explicit_8 (dst, 0, order)
#endif
#if defined(C89ATOMIC_HAS_16)
#define c89atomic_clear_explicit_16(dst, order) c89atomic_store_explicit_16(dst, 0, order)
#endif
#if defined(C89ATOMIC_HAS_32)
#define c89atomic_clear_explicit_32(dst, order) c89atomic_store_explicit_32(dst, 0, order)
#endif
#if defined(C89ATOMIC_HAS_64)
#define c89atomic_clear_explicit_64(dst, order) c89atomic_store_explicit_64(dst, 0, order)
#endif
#if defined(C89ATOMIC_HAS_8)
typedef c89atomic_uint8 c89atomic_flag;
#define c89atomic_flag_test_and_set_explicit(ptr, order) (c89atomic_bool)c89atomic_test_and_set_explicit_8(ptr, order)
#define c89atomic_flag_clear_explicit(ptr, order) c89atomic_clear_explicit_8(ptr, order)
#define c89atoimc_flag_load_explicit(ptr, order) c89atomic_load_explicit_8(ptr, order)
#else
typedef c89atomic_uint32 c89atomic_flag;
#define c89atomic_flag_test_and_set_explicit(ptr, order) (c89atomic_bool)c89atomic_test_and_set_explicit_32(ptr, order)
#define c89atomic_flag_clear_explicit(ptr, order) c89atomic_clear_explicit_32(ptr, order)
#define c89atoimc_flag_load_explicit(ptr, order) c89atomic_load_explicit_32(ptr, order)
#endif
#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
#define C89ATOMIC_HAS_NATIVE_COMPARE_EXCHANGE
#define C89ATOMIC_HAS_NATIVE_IS_LOCK_FREE
#define c89atomic_memory_order_relaxed __ATOMIC_RELAXED
#define c89atomic_memory_order_consume __ATOMIC_CONSUME
#define c89atomic_memory_order_acquire __ATOMIC_ACQUIRE
#define c89atomic_memory_order_release __ATOMIC_RELEASE
#define c89atomic_memory_order_acq_rel __ATOMIC_ACQ_REL
#define c89atomic_memory_order_seq_cst __ATOMIC_SEQ_CST
#define c89atomic_compiler_fence() __asm__ __volatile__("":::"memory")
#define c89atomic_thread_fence(order) __atomic_thread_fence(order)
#define c89atomic_signal_fence(order) __atomic_signal_fence(order)
#define c89atomic_is_lock_free_8(ptr) __atomic_is_lock_free(1, ptr)
#define c89atomic_is_lock_free_16(ptr) __atomic_is_lock_free(2, ptr)
#define c89atomic_is_lock_free_32(ptr) __atomic_is_lock_free(4, ptr)
#define c89atomic_is_lock_free_64(ptr) __atomic_is_lock_free(8, ptr)
#define c89atomic_flag_test_and_set_explicit(dst, order) (c89atomic_flag)__atomic_test_and_set(dst, order)
#define c89atomic_flag_clear_explicit(dst, order) __atomic_clear(dst, order)
#define c89atomic_memory_order_relaxed __ATOMIC_RELAXED
#define c89atomic_memory_order_consume __ATOMIC_CONSUME
#define c89atomic_memory_order_acquire __ATOMIC_ACQUIRE
#define c89atomic_memory_order_release __ATOMIC_RELEASE
#define c89atomic_memory_order_acq_rel __ATOMIC_ACQ_REL
#define c89atomic_memory_order_seq_cst __ATOMIC_SEQ_CST
#define c89atomic_compiler_fence() __asm__ __volatile__("":::"memory")
#define c89atomic_thread_fence(order) __atomic_thread_fence(order)
#define c89atomic_signal_fence(order) __atomic_signal_fence(order)
#define c89atomic_is_lock_free_8(ptr) __atomic_is_lock_free(1, ptr)
#define c89atomic_is_lock_free_16(ptr) __atomic_is_lock_free(2, ptr)
#define c89atomic_is_lock_free_32(ptr) __atomic_is_lock_free(4, ptr)
#define c89atomic_is_lock_free_64(ptr) __atomic_is_lock_free(8, ptr)
#define c89atomic_test_and_set_explicit_8( dst, order) __atomic_exchange_n(dst, 1, order)
#define c89atomic_test_and_set_explicit_16(dst, order) __atomic_exchange_n(dst, 1, order)
#define c89atomic_test_and_set_explicit_32(dst, order) __atomic_exchange_n(dst, 1, order)
...
...
@@ -8810,6 +8941,10 @@ typedef unsigned char c89atomic_flag;
#define c89atomic_compare_and_swap_16(dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired)
#define c89atomic_compare_and_swap_32(dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired)
#define c89atomic_compare_and_swap_64(dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired)
typedef c89atomic_uint8 c89atomic_flag;
#define c89atomic_flag_test_and_set_explicit(dst, order) (c89atomic_bool)__atomic_test_and_set(dst, order)
#define c89atomic_flag_clear_explicit(dst, order) __atomic_clear(dst, order)
#define c89atoimc_flag_load_explicit(ptr, order) c89atomic_load_explicit_8(ptr, order)
#else
#define c89atomic_memory_order_relaxed 1
#define c89atomic_memory_order_consume 2
...
...
@@ -9320,74 +9455,84 @@ typedef unsigned char c89atomic_flag;
#define c89atomic_clear_explicit_16(dst, order) c89atomic_store_explicit_16(dst, 0, order)
#define c89atomic_clear_explicit_32(dst, order) c89atomic_store_explicit_32(dst, 0, order)
#define c89atomic_clear_explicit_64(dst, order) c89atomic_store_explicit_64(dst, 0, order)
#define c89atomic_flag_test_and_set_explicit(ptr, order) (c89atomic_flag)c89atomic_test_and_set_explicit_8(ptr, order)
typedef c89atomic_uint8 c89atomic_flag;
#define c89atomic_flag_test_and_set_explicit(ptr, order) (c89atomic_bool)c89atomic_test_and_set_explicit_8(ptr, order)
#define c89atomic_flag_clear_explicit(ptr, order) c89atomic_clear_explicit_8(ptr, order)
#define c89atoimc_flag_load_explicit(ptr, order) c89atomic_load_explicit_8(ptr, order)
#endif
#if !defined(C89ATOMIC_HAS_NATIVE_COMPARE_EXCHANGE)
c89atomic_bool c89atomic_compare_exchange_strong_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8* expected, c89atomic_uint8 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint8 expectedValue;
c89atomic_uint8 result;
(void)successOrder;
(void)failureOrder;
expectedValue = c89atomic_load_explicit_8(expected, c89atomic_memory_order_seq_cst);
result = c89atomic_compare_and_swap_8(dst, expectedValue, desired);
if (result == expectedValue) {
return 1;
} else {
c89atomic_store_explicit_8(expected, result, failureOrder);
return 0;
}
}
c89atomic_bool c89atomic_compare_exchange_strong_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16* expected, c89atomic_uint16 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint16 expectedValue;
c89atomic_uint16 result;
(void)successOrder;
(void)failureOrder;
expectedValue = c89atomic_load_explicit_16(expected, c89atomic_memory_order_seq_cst);
result = c89atomic_compare_and_swap_16(dst, expectedValue, desired);
if (result == expectedValue) {
return 1;
} else {
c89atomic_store_explicit_16(expected, result, failureOrder);
return 0;
}
}
c89atomic_bool c89atomic_compare_exchange_strong_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32* expected, c89atomic_uint32 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint32 expectedValue;
c89atomic_uint32 result;
(void)successOrder;
(void)failureOrder;
expectedValue = c89atomic_load_explicit_32(expected, c89atomic_memory_order_seq_cst);
result = c89atomic_compare_and_swap_32(dst, expectedValue, desired);
if (result == expectedValue) {
return 1;
} else {
c89atomic_store_explicit_32(expected, result, failureOrder);
return 0;
}
}
c89atomic_bool c89atomic_compare_exchange_strong_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64* expected, c89atomic_uint64 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint64 expectedValue;
c89atomic_uint64 result;
(void)successOrder;
(void)failureOrder;
expectedValue = c89atomic_load_explicit_64(expected, c89atomic_memory_order_seq_cst);
result = c89atomic_compare_and_swap_64(dst, expectedValue, desired);
if (result == expectedValue) {
return 1;
} else {
c89atomic_store_explicit_64(expected, result, failureOrder);
return 0;
}
}
#define c89atomic_compare_exchange_weak_explicit_8( dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_8 (dst, expected, desired, successOrder, failureOrder)
#define c89atomic_compare_exchange_weak_explicit_16(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_16(dst, expected, desired, successOrder, failureOrder)
#define c89atomic_compare_exchange_weak_explicit_32(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_32(dst, expected, desired, successOrder, failureOrder)
#define c89atomic_compare_exchange_weak_explicit_64(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_64(dst, expected, desired, successOrder, failureOrder)
#if defined(C89ATOMIC_HAS_8)
c89atomic_bool c89atomic_compare_exchange_strong_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8* expected, c89atomic_uint8 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint8 expectedValue;
c89atomic_uint8 result;
(void)successOrder;
(void)failureOrder;
expectedValue = c89atomic_load_explicit_8(expected, c89atomic_memory_order_seq_cst);
result = c89atomic_compare_and_swap_8(dst, expectedValue, desired);
if (result == expectedValue) {
return 1;
} else {
c89atomic_store_explicit_8(expected, result, failureOrder);
return 0;
}
}
#endif
#if defined(C89ATOMIC_HAS_16)
c89atomic_bool c89atomic_compare_exchange_strong_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16* expected, c89atomic_uint16 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint16 expectedValue;
c89atomic_uint16 result;
(void)successOrder;
(void)failureOrder;
expectedValue = c89atomic_load_explicit_16(expected, c89atomic_memory_order_seq_cst);
result = c89atomic_compare_and_swap_16(dst, expectedValue, desired);
if (result == expectedValue) {
return 1;
} else {
c89atomic_store_explicit_16(expected, result, failureOrder);
return 0;
}
}
#endif
#if defined(C89ATOMIC_HAS_32)
c89atomic_bool c89atomic_compare_exchange_strong_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32* expected, c89atomic_uint32 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint32 expectedValue;
c89atomic_uint32 result;
(void)successOrder;
(void)failureOrder;
expectedValue = c89atomic_load_explicit_32(expected, c89atomic_memory_order_seq_cst);
result = c89atomic_compare_and_swap_32(dst, expectedValue, desired);
if (result == expectedValue) {
return 1;
} else {
c89atomic_store_explicit_32(expected, result, failureOrder);
return 0;
}
}
#endif
#if defined(C89ATOMIC_HAS_64)
c89atomic_bool c89atomic_compare_exchange_strong_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64* expected, c89atomic_uint64 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint64 expectedValue;
c89atomic_uint64 result;
(void)successOrder;
(void)failureOrder;
expectedValue = c89atomic_load_explicit_64(expected, c89atomic_memory_order_seq_cst);
result = c89atomic_compare_and_swap_64(dst, expectedValue, desired);
if (result == expectedValue) {
return 1;
} else {
c89atomic_store_explicit_64(expected, result, failureOrder);
return 0;
}
}
#endif
#define c89atomic_compare_exchange_weak_explicit_8( dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_8 (dst, expected, desired, successOrder, failureOrder)
#define c89atomic_compare_exchange_weak_explicit_16(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_16(dst, expected, desired, successOrder, failureOrder)
#define c89atomic_compare_exchange_weak_explicit_32(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_32(dst, expected, desired, successOrder, failureOrder)
#define c89atomic_compare_exchange_weak_explicit_64(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_64(dst, expected, desired, successOrder, failureOrder)
#endif
#if !defined(C89ATOMIC_HAS_NATIVE_IS_LOCK_FREE)
static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_8(volatile void* ptr)
...
...
@@ -9698,7 +9843,7 @@ static C89ATOMIC_INLINE void c89atomic_spinlock_lock(volatile c89atomic_spinlock
if (c89atomic_flag_test_and_set_explicit(pSpinlock, c89atomic_memory_order_acquire) == 0) {
break;
}
while (c89ato
mic_load_explicit_8
(pSpinlock, c89atomic_memory_order_relaxed) == 1) {
while (c89ato
imc_flag_load_explicit
(pSpinlock, c89atomic_memory_order_relaxed) == 1) {
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment