void-packages/srcpkgs/renderdoc/patches/atomic.patch

56 lines
1.4 KiB
Diff

@q66: replace old __sync stuff with equivalent modern ones,
so we can use libatomic on targets without atomic8 support
--- renderdoc/CMakeLists.txt
+++ renderdoc/CMakeLists.txt
@@ -55,6 +55,8 @@ elseif(UNIX)
PRIVATE -ldl
PRIVATE -lrt)
+#libatomic list(APPEND RDOC_LIBRARIES PRIVATE -latomic)
+
if(ENABLE_XLIB)
find_package(X11 REQUIRED)
--- renderdoc/os/posix/posix_threading.cpp
+++ renderdoc/os/posix/posix_threading.cpp
@@ -43,32 +43,33 @@ namespace Atomic
{
int32_t Inc32(int32_t *i)
{
- return __sync_add_and_fetch(i, int32_t(1));
+ return __atomic_add_fetch(i, int32_t(1), __ATOMIC_SEQ_CST);
}
int32_t Dec32(int32_t *i)
{
- return __sync_add_and_fetch(i, int32_t(-1));
+ return __atomic_sub_fetch(i, int32_t(1), __ATOMIC_SEQ_CST);
}
int64_t Inc64(int64_t *i)
{
- return __sync_add_and_fetch(i, int64_t(1));
+ return __atomic_add_fetch(i, int64_t(1), __ATOMIC_SEQ_CST);
}
int64_t Dec64(int64_t *i)
{
- return __sync_add_and_fetch(i, int64_t(-1));
+ return __atomic_sub_fetch(i, int64_t(1), __ATOMIC_SEQ_CST);
}
int64_t ExchAdd64(int64_t *i, int64_t a)
{
- return __sync_add_and_fetch(i, int64_t(a));
+ return __atomic_add_fetch(i, a, __ATOMIC_SEQ_CST);
}
int32_t CmpExch32(int32_t *dest, int32_t oldVal, int32_t newVal)
{
- return __sync_val_compare_and_swap(dest, oldVal, newVal);
+ __atomic_compare_exchange_n(dest, &oldVal, newVal, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ return oldVal;
}
};