void-packages/srcpkgs/renderdoc/patches/atomic.patch
Đoàn Trần Công Danh 103ab731ab srcpkgs/r*: convert patches to -Np1
* runit is kept at -Np0

```sh
git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.-][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.-][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

56 lines
1.5 KiB
Diff

@q66: replace old __sync stuff with equivalent modern ones,
so we can use libatomic on targets without atomic8 support
--- a/renderdoc/CMakeLists.txt
+++ b/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)
--- a/renderdoc/os/posix/posix_threading.cpp
+++ b/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;
}
};