PR #24642 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24642
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24642.patch


From 6ee75ef8da01ec000d339e64d9b31ee0df3538b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Wed, 23 Sep 2026 03:13:49 +0200
Subject: [PATCH 1/3] configure: update the win32 atomics backend check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Nothing has called MemoryBarrier() since the backend rewrite. Check the
_InterlockedOr directly and drop HAVE_MEMORYBARRIER which is not used
anywhere.

Signed-off-by: Kacper Michajłow <[email protected]>
---
 configure | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/configure b/configure
index 84ab8beb4b..5506eee57e 100755
--- a/configure
+++ b/configure
@@ -2430,7 +2430,6 @@ ARCH_FEATURES="
 "
 
 BUILTIN_LIST="
-    MemoryBarrier
     mm_empty
     rdtsc
     sem_timedwait
@@ -3018,7 +3017,6 @@ valgrind_backtrace_conflict="optimizations"
 valgrind_backtrace_deps="valgrind_valgrind_h"
 
 # threading support
-atomics_win32_if="MemoryBarrier"
 atomics_os2_if="stdatomic"
 atomics_native_if_any="$ATOMICS_LIST"
 w32threads_deps="atomics_native"
@@ -6826,7 +6824,7 @@ if ! disabled network; then
     fi
 fi
 
-check_builtin MemoryBarrier windows.h "MemoryBarrier()"
+check_builtin atomics_win32 intrin.h "long v = 0; _InterlockedOr(&v, 0)"
 check_builtin gmtime_r time.h "time_t *time; struct tm *tm; gmtime_r(time, tm)"
 check_builtin localtime_r time.h "time_t *time; struct tm *tm; 
localtime_r(time, tm)"
 check_builtin int128 "" "volatile __int128 i128var = 1; i128var /= 100;"
-- 
2.52.0


From 0b5bbba15ff658f1db7f8bafd1cfb9f0e55a7de1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Wed, 23 Sep 2026 03:30:43 +0200
Subject: [PATCH 2/3] configure: define atomics_native as any real atomics
 implementation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

atomics_os2 was not a backend. It has no compat directory and nothing
reads it. It aliased stdatomic without a target guard, so it enabled
atomics_native on every platform with C11 atomics as a side effect,
only to satisfy the os2threads dependency on OS/2.

State the rule directly instead. atomics_native is stdatomic or the
win32 compat backend, and every non-pthread thread backend depends on
it. os2threads stays enabled exactly when stdatomic is available, and
the shared protocol can depend on atomics_native alone, without the
internal stdatomic check as a dependency.

Signed-off-by: Kacper Michajłow <[email protected]>
---
 configure | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 5506eee57e..364a9ab5ce 100755
--- a/configure
+++ b/configure
@@ -2281,11 +2281,6 @@ THREADS_LIST="
     w32threads
 "
 
-ATOMICS_LIST="
-    atomics_win32
-    atomics_os2
-"
-
 AUTODETECT_LIBS="
     $EXTERNAL_AUTODETECT_LIBRARY_LIST
     $HWACCEL_AUTODETECT_LIBRARY_LIST
@@ -3017,8 +3012,7 @@ valgrind_backtrace_conflict="optimizations"
 valgrind_backtrace_deps="valgrind_valgrind_h"
 
 # threading support
-atomics_os2_if="stdatomic"
-atomics_native_if_any="$ATOMICS_LIST"
+atomics_native_if_any="stdatomic atomics_win32"
 w32threads_deps="atomics_native"
 os2threads_deps="atomics_native"
 threads_if_any="$THREADS_LIST"
@@ -4086,8 +4080,7 @@ schannel_conflict="openssl gnutls libtls mbedtls"
 sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags"
 sctp_protocol_select="network"
 securetransport_conflict="openssl gnutls libtls mbedtls"
-shared_protocol_deps="mmap unistd_h"
-shared_protocol_deps_any="stdatomic atomics_native"
+shared_protocol_deps="mmap unistd_h atomics_native"
 srtp_protocol_select="rtp_protocol srtp"
 tcp_protocol_select="network"
 tls_protocol_deps_any="gnutls openssl schannel securetransport libtls mbedtls"
-- 
2.52.0


From ad3bb6b68a9748f499a3fc79fbd603413c51b17e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Wed, 23 Sep 2026 03:32:35 +0200
Subject: [PATCH 3/3] configure: drop the unreachable non-pthread atomics abort
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Both non-pthread thread backends depend on atomics_native, so
check_deps has already disabled them, or died for an explicit request,
before this line runs. The remedies it suggests refer to the pthread
emulation and the gcc builtins backend, both removed in 8c185ef4e7.
The remaining case, C11 atomics missing on a pthreads target, is still
caught by the abort at the compat include path selection.

Signed-off-by: Kacper Michajłow <[email protected]>
---
 configure | 2 --
 1 file changed, 2 deletions(-)

diff --git a/configure b/configure
index 364a9ab5ce..dfb810a36f 100755
--- a/configure
+++ b/configure
@@ -8097,8 +8097,6 @@ check_deps $CONFIG_LIST       \
            $HAVE_LIST         \
            $ALL_COMPONENTS    \
 
-enabled threads && ! enabled pthreads && ! enabled atomics_native && die "non 
pthread threading without atomics not supported, try adding --enable-pthreads 
or --cpu=i486 or higher if you are on x86"
-
 enabled threads || warn \
     "Threading support was disabled or is not available on the target 
platform." \
     "This means that not only is this build not multi-threaded, but also"    \
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to