commit 137ae62
Michael Forney
·
2025-04-28 19:37:25 +0000 UTC
parent 934f98f
ffmpeg: Fix build with gcc 15.1.0
2 files changed,
+114,
-1
1@@ -0,0 +1,113 @@
2+From 16aa2a5923497b440d526b34e12ea0961215d17f Mon Sep 17 00:00:00 2001
3+From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
4+Date: Sat, 23 Mar 2024 13:38:06 +0100
5+Subject: [PATCH] all: Don't use ATOMIC_VAR_INIT
6+
7+C11 required to use ATOMIC_VAR_INIT to statically initialize
8+atomic objects with static storage duration. Yet this macro
9+was unsuitable for initializing structures [1] and was actually
10+unneeded for all known implementations (this includes our
11+compatibility fallback implementations which simply wrap the value
12+in parentheses: #define ATOMIC_VAR_INIT(value) (value)).
13+Therefore C17 deprecated the macro and C23 actually removed it [2].
14+
15+Since commit 5ff0eb34d2b1089d3dd9f27fdb51520001709138 we default
16+to C17 if the compiler supports it; Clang warns about ATOMIC_VAR_INIT
17+in this mode. Given that no implementation ever needed this macro,
18+this commit stops using it to avoid this warning.
19+
20+[1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_485
21+[2]: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
22+
23+Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
24+---
25+ configure | 4 ++--
26+ fftools/ffmpeg.c | 2 +-
27+ libavformat/allformats.c | 4 ++--
28+ libavutil/cpu.c | 6 +++---
29+ libavutil/mem.c | 2 +-
30+ 5 files changed, 9 insertions(+), 9 deletions(-)
31+
32+diff --git a/configure b/configure
33+index 86425130bd..2bee29ff73 100755
34+--- a/configure
35++++ b/configure
36+@@ -6620,8 +6620,8 @@ check_headers asm/types.h
37+ # some configurations also require linking to libatomic, so try
38+ # both with -latomic and without
39+ for LATOMIC in "-latomic" ""; do
40+- check_builtin stdatomic stdatomic.h \
41+- "atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0); foo += bar" \
42++ check_builtin stdatomic stdatomic.h \
43++ "atomic_int foo, bar = -1; atomic_store(&foo, 0); foo += bar" \
44+ $LATOMIC && eval stdatomic_extralibs="\$LATOMIC" && break
45+ done
46+
47+diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
48+index 4a0c7d5c4d..d89a697616 100644
49+--- a/fftools/ffmpeg.c
50++++ b/fftools/ffmpeg.c
51+@@ -157,7 +157,7 @@ void term_exit(void)
52+
53+ static volatile int received_sigterm = 0;
54+ static volatile int received_nb_signals = 0;
55+-static atomic_int transcode_init_done = ATOMIC_VAR_INIT(0);
56++static atomic_int transcode_init_done = 0;
57+ static volatile int ffmpeg_exited = 0;
58+ static int64_t copy_ts_first_pts = AV_NOPTS_VALUE;
59+
60+diff --git a/libavformat/allformats.c b/libavformat/allformats.c
61+index e15d0fa6d7..9df42bb87a 100644
62+--- a/libavformat/allformats.c
63++++ b/libavformat/allformats.c
64+@@ -576,8 +576,8 @@ extern const FFInputFormat ff_vapoursynth_demuxer;
65+ #include "libavformat/muxer_list.c"
66+ #include "libavformat/demuxer_list.c"
67+
68+-static atomic_uintptr_t indev_list_intptr = ATOMIC_VAR_INIT(0);
69+-static atomic_uintptr_t outdev_list_intptr = ATOMIC_VAR_INIT(0);
70++static atomic_uintptr_t indev_list_intptr = 0;
71++static atomic_uintptr_t outdev_list_intptr = 0;
72+
73+ const AVOutputFormat *av_muxer_iterate(void **opaque)
74+ {
75+diff --git a/libavutil/cpu.c b/libavutil/cpu.c
76+index 48d195168c..d4f947360a 100644
77+--- a/libavutil/cpu.c
78++++ b/libavutil/cpu.c
79+@@ -49,8 +49,8 @@
80+ #include <unistd.h>
81+ #endif
82+
83+-static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);
84+-static atomic_int cpu_count = ATOMIC_VAR_INIT(-1);
85++static atomic_int cpu_flags = -1;
86++static atomic_int cpu_count = -1;
87+
88+ static int get_cpu_flags(void)
89+ {
90+@@ -208,7 +208,7 @@ int av_parse_cpu_caps(unsigned *flags, const char *s)
91+
92+ int av_cpu_count(void)
93+ {
94+- static atomic_int printed = ATOMIC_VAR_INIT(0);
95++ static atomic_int printed = 0;
96+
97+ int nb_cpus = 1;
98+ int count = 0;
99+diff --git a/libavutil/mem.c b/libavutil/mem.c
100+index 62163b4cb3..02d4cb791f 100644
101+--- a/libavutil/mem.c
102++++ b/libavutil/mem.c
103+@@ -69,7 +69,7 @@ void free(void *ptr);
104+ * dynamic libraries and remove -Wl,-Bsymbolic from the linker flags.
105+ * Note that this will cost performance. */
106+
107+-static atomic_size_t max_alloc_size = ATOMIC_VAR_INIT(INT_MAX);
108++static atomic_size_t max_alloc_size = INT_MAX;
109+
110+ void av_max_alloc(size_t max){
111+ atomic_store_explicit(&max_alloc_size, max, memory_order_relaxed);
112+--
113+2.45.2
114+
+1,
-1
1@@ -1 +1 @@
2-7.0.2 r0
3+7.0.2 r1