From bee87d03df104bc4c9cead961e5a91eeda123ac2 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianasulu@gmail.com>
Date: Wed, 3 Jun 2026 15:24:14 +0300
Subject: [PATCH 4/4] Add g++11 threading to x265 by barracuda156 - fixes
 linking on ppc32

---
 cinelerra-5.1/thirdparty/src/x265_4.2.patch6 | 31 ++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100755 cinelerra-5.1/thirdparty/src/x265_4.2.patch6

diff --git a/cinelerra-5.1/thirdparty/src/x265_4.2.patch6 b/cinelerra-5.1/thirdparty/src/x265_4.2.patch6
new file mode 100755
index 00000000..a796d242
--- /dev/null
+++ b/cinelerra-5.1/thirdparty/src/x265_4.2.patch6
@@ -0,0 +1,31 @@
+--- ./csource/ommon/threading.h	2026-04-19 14:29:17.000000000 +0800
++++ ./source/common/threading.h	2026-05-29 18:31:47.000000000 +0800
+@@ -81,11 +81,11 @@
+ #define BSF(id, x)            (id) = ((unsigned long)__builtin_ctz(x))
+ #define BSR64(id, x)          (id) = ((unsigned long)__builtin_clzll(x) ^ 63)
+ #define BSF64(id, x)          (id) = ((unsigned long)__builtin_ctzll(x))
+-#define ATOMIC_OR(ptr, mask)  __sync_fetch_and_or(ptr, mask)
+-#define ATOMIC_AND(ptr, mask) __sync_fetch_and_and(ptr, mask)
+-#define ATOMIC_INC(ptr)       __sync_add_and_fetch((volatile int32_t*)ptr, 1)
+-#define ATOMIC_DEC(ptr)       __sync_add_and_fetch((volatile int32_t*)ptr, -1)
+-#define ATOMIC_ADD(ptr, val)  __sync_fetch_and_add((volatile __typeof__(*(ptr))*)ptr, (__typeof__(*(ptr) + 0))(val))
++#define ATOMIC_OR(ptr, mask)  __atomic_fetch_or((ptr), (mask), __ATOMIC_SEQ_CST)
++#define ATOMIC_AND(ptr, mask) __atomic_fetch_and((ptr), (mask), __ATOMIC_SEQ_CST)
++#define ATOMIC_INC(ptr)       __atomic_add_fetch((volatile int32_t*)(ptr), 1, __ATOMIC_SEQ_CST)
++#define ATOMIC_DEC(ptr)       __atomic_add_fetch((volatile int32_t*)(ptr), -1, __ATOMIC_SEQ_CST)
++#define ATOMIC_ADD(ptr, val)  __atomic_fetch_add((volatile __typeof__(*(ptr))*)(ptr), (__typeof__(*(ptr) + 0))(val), __ATOMIC_SEQ_CST)
+ #define GIVE_UP_TIME()        usleep(0)
+ 
+ #elif defined(_MSC_VER)       /* Windows atomic intrinsics */
+
+--- ./source/CMakeLists.txt	2026-04-19 14:29:17.000000000 +0800
++++ ./source/CMakeLists.txt	2026-05-29 18:08:51.000000000 +0800
+@@ -285,7 +285,7 @@
+         endif()
+         add_definitions(-std=gnu++11)
+     else()
+-        add_definitions(-std=gnu++98)
++        add_definitions(-std=gnu++11)
+     endif()
+     if(ENABLE_PIC)
+          add_definitions(-fPIC)
-- 
2.51.2

