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
827129f0
Commit
827129f0
authored
Nov 22, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update c89atomic.
parent
db91bcca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
372 additions
and
43 deletions
+372
-43
miniaudio.h
miniaudio.h
+372
-43
No files found.
miniaudio.h
View file @
827129f0
...
@@ -8154,7 +8154,7 @@ typedef unsigned char c89atomic_flag;
...
@@ -8154,7 +8154,7 @@ typedef unsigned char c89atomic_flag;
#else
#else
#define C89ATOMIC_INLINE
#define C89ATOMIC_INLINE
#endif
#endif
#if defined(_MSC_VER) || defined(__WATCOMC__)
#if defined(_MSC_VER) || defined(__WATCOMC__)
|| defined(__DMC__)
#define c89atomic_memory_order_relaxed 0
#define c89atomic_memory_order_relaxed 0
#define c89atomic_memory_order_consume 1
#define c89atomic_memory_order_consume 1
#define c89atomic_memory_order_acquire 2
#define c89atomic_memory_order_acquire 2
...
@@ -8193,10 +8193,9 @@ typedef unsigned char c89atomic_flag;
...
@@ -8193,10 +8193,9 @@ typedef unsigned char c89atomic_flag;
#if defined(C89ATOMIC_X86)
#if defined(C89ATOMIC_X86)
static C89ATOMIC_INLINE void __stdcall c89atomic_thread_fence(int order)
static C89ATOMIC_INLINE void __stdcall c89atomic_thread_fence(int order)
{
{
volatile c89atomic_uint32 barrier = 0;
(void)order;
(void)order;
__asm {
__asm {
xchg barrier, eax
lock add [esp], 0
}
}
}
}
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, int order)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, int order)
...
@@ -8324,7 +8323,7 @@ typedef unsigned char c89atomic_flag;
...
@@ -8324,7 +8323,7 @@ typedef unsigned char c89atomic_flag;
return ((c89atomic_uint64)resultEDX << 32) | resultEAX;
return ((c89atomic_uint64)resultEDX << 32) | resultEAX;
}
}
#else
#else
error "Unsupported architecture."
#error Unsupported architecture.
#endif
#endif
#endif
#endif
#define c89atomic_compiler_fence() c89atomic_thread_fence(c89atomic_memory_order_seq_cst)
#define c89atomic_compiler_fence() c89atomic_thread_fence(c89atomic_memory_order_seq_cst)
...
@@ -8622,67 +8621,397 @@ typedef unsigned char c89atomic_flag;
...
@@ -8622,67 +8621,397 @@ typedef unsigned char c89atomic_flag;
#define c89atomic_memory_order_release 4
#define c89atomic_memory_order_release 4
#define c89atomic_memory_order_acq_rel 5
#define c89atomic_memory_order_acq_rel 5
#define c89atomic_memory_order_seq_cst 6
#define c89atomic_memory_order_seq_cst 6
#define c89atomic_compiler_fence() __asm__ __volatile__("":::"memory")
#define c89atomic_compiler_fence() __asm__ __volatile__("":::"memory")
#define c89atomic_thread_fence(order) __sync_synchronize()
#if defined(__GNUC__)
#define c89atomic_signal_fence(order) c89atomic_thread_fence(order)
#define c89atomic_thread_fence(order) __sync_synchronize()
static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
{
if (order > c89atomic_memory_order_acquire) {
if (order > c89atomic_memory_order_acquire) {
__sync_synchronize();
__sync_synchronize();
}
return __sync_lock_test_and_set(dst, src);
}
static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
volatile c89atomic_uint16 oldValue;
do {
oldValue = *dst;
} while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
volatile c89atomic_uint32 oldValue;
do {
oldValue = *dst;
} while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
(void)order;
return oldValue;
}
static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
volatile c89atomic_uint64 oldValue;
do {
oldValue = *dst;
} while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
(void)order;
return oldValue;
}
#define c89atomic_fetch_add_explicit_8( dst, src, order) __sync_fetch_and_add(dst, src)
#define c89atomic_fetch_add_explicit_16(dst, src, order) __sync_fetch_and_add(dst, src)
#define c89atomic_fetch_add_explicit_32(dst, src, order) __sync_fetch_and_add(dst, src)
#define c89atomic_fetch_add_explicit_64(dst, src, order) __sync_fetch_and_add(dst, src)
#define c89atomic_fetch_sub_explicit_8( dst, src, order) __sync_fetch_and_sub(dst, src)
#define c89atomic_fetch_sub_explicit_16(dst, src, order) __sync_fetch_and_sub(dst, src)
#define c89atomic_fetch_sub_explicit_32(dst, src, order) __sync_fetch_and_sub(dst, src)
#define c89atomic_fetch_sub_explicit_64(dst, src, order) __sync_fetch_and_sub(dst, src)
#define c89atomic_fetch_or_explicit_8( dst, src, order) __sync_fetch_and_or(dst, src)
#define c89atomic_fetch_or_explicit_16(dst, src, order) __sync_fetch_and_or(dst, src)
#define c89atomic_fetch_or_explicit_32(dst, src, order) __sync_fetch_and_or(dst, src)
#define c89atomic_fetch_or_explicit_64(dst, src, order) __sync_fetch_and_or(dst, src)
#define c89atomic_fetch_xor_explicit_8( dst, src, order) __sync_fetch_and_xor(dst, src)
#define c89atomic_fetch_xor_explicit_16(dst, src, order) __sync_fetch_and_xor(dst, src)
#define c89atomic_fetch_xor_explicit_32(dst, src, order) __sync_fetch_and_xor(dst, src)
#define c89atomic_fetch_xor_explicit_64(dst, src, order) __sync_fetch_and_xor(dst, src)
#define c89atomic_fetch_and_explicit_8( dst, src, order) __sync_fetch_and_and(dst, src)
#define c89atomic_fetch_and_explicit_16(dst, src, order) __sync_fetch_and_and(dst, src)
#define c89atomic_fetch_and_explicit_32(dst, src, order) __sync_fetch_and_and(dst, src)
#define c89atomic_fetch_and_explicit_64(dst, src, order) __sync_fetch_and_and(dst, src)
#define c89atomic_compare_and_swap_8( dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired)
#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)
#else
#if defined(C89ATOMIC_X86)
#define c89atomic_thread_fence(order) __asm__ __volatile__("lock; addl $0, (%%esp)" ::: "memory", "cc")
#elif defined(C89ATOMIC_X64)
#define c89atomic_thread_fence(order) __asm__ __volatile__("lock; addq $0, (%%rsp)" ::: "memory", "cc")
#else
#error Unsupported architecture. Please submit a feature request.
#endif
static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_compare_and_swap_8(volatile c89atomic_uint8* dst, c89atomic_uint8 expected, c89atomic_uint8 desired)
{
volatile c89atomic_uint8 result;
#if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_compare_and_swap_16(volatile c89atomic_uint16* dst, c89atomic_uint16 expected, c89atomic_uint16 desired)
{
volatile c89atomic_uint16 result;
#if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_compare_and_swap_32(volatile c89atomic_uint32* dst, c89atomic_uint32 expected, c89atomic_uint32 desired)
{
volatile c89atomic_uint32 result;
#if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_compare_and_swap_64(volatile c89atomic_uint64* dst, c89atomic_uint64 expected, c89atomic_uint64 desired)
{
volatile c89atomic_uint64 result;
#if defined(C89ATOMIC_X86)
volatile c89atomic_uint32 resultEAX;
volatile c89atomic_uint32 resultEDX;
__asm__ __volatile__("push %%ebx; xchg %5, %%ebx; lock; cmpxchg8b %0; pop %%ebx" : "+m"(*dst), "=a"(resultEAX), "=d"(resultEDX) : "a"(expected & 0xFFFFFFFF), "d"(expected >> 32), "r"(desired & 0xFFFFFFFF), "c"(desired >> 32) : "cc");
result = ((c89atomic_uint64)resultEDX << 32) | resultEAX;
#elif defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, int order)
{
volatile c89atomic_uint8 result = 0;
(void)order;
#if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, int order)
{
volatile c89atomic_uint16 result = 0;
(void)order;
#if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, int order)
{
volatile c89atomic_uint32 result;
(void)order;
#if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, int order)
{
volatile c89atomic_uint64 result;
(void)order;
#if defined(C89ATOMIC_X86)
do {
result = *dst;
} while (c89atomic_compare_and_swap_64(dst, result, src) != result);
#elif defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, int order)
{
c89atomic_uint8 result;
(void)order;
#if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, int order)
{
c89atomic_uint16 result;
(void)order;
#if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, int order)
{
c89atomic_uint32 result;
(void)order;
#if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
__asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
#else
#error Unsupported architecture. Please submit a feature request.
#endif
return result;
}
static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, int order)
{
#if defined(C89ATOMIC_X86)
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
(void)order;
do {
oldValue = *dst;
newValue = oldValue + src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
return oldValue;
#elif defined(C89ATOMIC_X64)
volatile c89atomic_uint64 result;
(void)order;
__asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
return result;
#endif
}
}
return __sync_lock_test_and_set(dst, src);
#endif
static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_sub_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, int 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 c89atomic_
exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order
order)
static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_
fetch_sub_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, int
order)
{
{
volatile c89atomic_uint16 oldValue;
volatile c89atomic_uint16 oldValue;
volatile c89atomic_uint16 newValue;
do {
do {
oldValue = *dst;
oldValue = *dst;
} while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
newValue = (c89atomic_uint16)(oldValue - src);
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
(void)order;
return oldValue;
return oldValue;
}
}
static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_
exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order
order)
static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_
fetch_sub_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, int
order)
{
{
volatile c89atomic_uint32 oldValue;
volatile c89atomic_uint32 oldValue;
volatile c89atomic_uint32 newValue;
do {
do {
oldValue = *dst;
oldValue = *dst;
} while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
newValue = oldValue - src;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
(void)order;
return oldValue;
return oldValue;
}
}
static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_
exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order
order)
static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_
fetch_sub_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, int
order)
{
{
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 oldValue;
volatile c89atomic_uint64 newValue;
do {
do {
oldValue = *dst;
oldValue = *dst;
} while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
newValue = oldValue - src;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
(void)order;
return oldValue;
return oldValue;
}
}
#define c89atomic_fetch_add_explicit_8( dst, src, order) __sync_fetch_and_add(dst, src)
static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_and_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, int order)
#define c89atomic_fetch_add_explicit_16(dst, src, order) __sync_fetch_and_add(dst, src)
{
#define c89atomic_fetch_add_explicit_32(dst, src, order) __sync_fetch_and_add(dst, src)
volatile c89atomic_uint8 oldValue;
#define c89atomic_fetch_add_explicit_64(dst, src, order) __sync_fetch_and_add(dst, src)
volatile c89atomic_uint8 newValue;
#define c89atomic_fetch_sub_explicit_8( dst, src, order) __sync_fetch_and_sub(dst, src)
do {
#define c89atomic_fetch_sub_explicit_16(dst, src, order) __sync_fetch_and_sub(dst, src)
oldValue = *dst;
#define c89atomic_fetch_sub_explicit_32(dst, src, order) __sync_fetch_and_sub(dst, src)
newValue = (c89atomic_uint8)(oldValue & src);
#define c89atomic_fetch_sub_explicit_64(dst, src, order) __sync_fetch_and_sub(dst, src)
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
#define c89atomic_fetch_or_explicit_8( dst, src, order) __sync_fetch_and_or(dst, src)
(void)order;
#define c89atomic_fetch_or_explicit_16(dst, src, order) __sync_fetch_and_or(dst, src)
return oldValue;
#define c89atomic_fetch_or_explicit_32(dst, src, order) __sync_fetch_and_or(dst, src)
}
#define c89atomic_fetch_or_explicit_64(dst, src, order) __sync_fetch_and_or(dst, src)
static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_and_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, int order)
#define c89atomic_fetch_xor_explicit_8( dst, src, order) __sync_fetch_and_xor(dst, src)
{
#define c89atomic_fetch_xor_explicit_16(dst, src, order) __sync_fetch_and_xor(dst, src)
volatile c89atomic_uint16 oldValue;
#define c89atomic_fetch_xor_explicit_32(dst, src, order) __sync_fetch_and_xor(dst, src)
volatile c89atomic_uint16 newValue;
#define c89atomic_fetch_xor_explicit_64(dst, src, order) __sync_fetch_and_xor(dst, src)
do {
#define c89atomic_fetch_and_explicit_8( dst, src, order) __sync_fetch_and_and(dst, src)
oldValue = *dst;
#define c89atomic_fetch_and_explicit_16(dst, src, order) __sync_fetch_and_and(dst, src)
newValue = (c89atomic_uint16)(oldValue & src);
#define c89atomic_fetch_and_explicit_32(dst, src, order) __sync_fetch_and_and(dst, src)
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
#define c89atomic_fetch_and_explicit_64(dst, src, order) __sync_fetch_and_and(dst, src)
(void)order;
#define c89atomic_compare_and_swap_8( dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired)
return oldValue;
#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)
static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_and_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, int order)
#define c89atomic_compare_and_swap_64(dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired)
{
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 c89atomic_fetch_and_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, int 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 c89atomic_fetch_xor_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, int 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 c89atomic_fetch_xor_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, int 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 c89atomic_fetch_xor_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, int 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 c89atomic_fetch_xor_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, int 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 c89atomic_fetch_or_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, int 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 c89atomic_fetch_or_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, int 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 c89atomic_fetch_or_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, int 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 c89atomic_fetch_or_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, int 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_signal_fence(order) c89atomic_thread_fence(order)
#define c89atomic_load_explicit_8( ptr, order) c89atomic_compare_and_swap_8 (ptr, 0, 0)
#define c89atomic_load_explicit_8( ptr, order) c89atomic_compare_and_swap_8 (ptr, 0, 0)
#define c89atomic_load_explicit_16(ptr, order) c89atomic_compare_and_swap_16(ptr, 0, 0)
#define c89atomic_load_explicit_16(ptr, order) c89atomic_compare_and_swap_16(ptr, 0, 0)
#define c89atomic_load_explicit_32(ptr, order) c89atomic_compare_and_swap_32(ptr, 0, 0)
#define c89atomic_load_explicit_32(ptr, order) c89atomic_compare_and_swap_32(ptr, 0, 0)
...
@@ -8799,7 +9128,7 @@ c89atomic_bool c89atomic_compare_exchange_strong_explicit_64(volatile c89atomic_
...
@@ -8799,7 +9128,7 @@ c89atomic_bool c89atomic_compare_exchange_strong_explicit_64(volatile c89atomic_
#define c89atomic_compare_exchange_weak_explicit_ptr(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_weak_explicit_32((volatile c89atomic_uint32*)dst, (volatile c89atomic_uint32*)expected, (c89atomic_uint32)desired, successOrder, failureOrder)
#define c89atomic_compare_exchange_weak_explicit_ptr(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_weak_explicit_32((volatile c89atomic_uint32*)dst, (volatile c89atomic_uint32*)expected, (c89atomic_uint32)desired, successOrder, failureOrder)
#define c89atomic_compare_and_swap_ptr(dst, expected, desired) (void*)c89atomic_compare_and_swap_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32)expected, (c89atomic_uint32)desired)
#define c89atomic_compare_and_swap_ptr(dst, expected, desired) (void*)c89atomic_compare_and_swap_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32)expected, (c89atomic_uint32)desired)
#else
#else
error "Unsupported architecture."
#error Unsupported architecture.
#endif
#endif
#define c89atomic_flag_test_and_set(ptr) c89atomic_flag_test_and_set_explicit(ptr, c89atomic_memory_order_seq_cst)
#define c89atomic_flag_test_and_set(ptr) c89atomic_flag_test_and_set_explicit(ptr, c89atomic_memory_order_seq_cst)
#define c89atomic_flag_clear(ptr) c89atomic_flag_clear_explicit(ptr, c89atomic_memory_order_seq_cst)
#define c89atomic_flag_clear(ptr) c89atomic_flag_clear_explicit(ptr, c89atomic_memory_order_seq_cst)
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