nemequ/portable-snippets

Wrong intrinsics for GCC in atomic/atomic.h

leafi opened this issue · 0 comments

leafi commented

When PSNIP_ATOMIC_IMPL is equal to PSNIP_ATOMIC_IMPL_GCC, the wrong intrinsics are used for the _int64_add & _int64_sub implementations.

In https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html , you can see these intrinsics exist:

__atomic_add_fetch
__atomic_sub_fetch

__atomic_fetch_add
__atomic_fetch_sub

To be consistent with the other implementations of psnip_atomic_int64_add and psnip_atomic_int64_sub, we want to fetch and then add or subtract. However, the intrinsics used in PSNIP_ATOMIC_IMPL_GCC do things in the opposite "order".