diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-03-23 13:38:06 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-03-28 09:12:48 +0100 |
commit | 5d71f97e0e02740bf85c6de9c2855e5592bd053c (patch) | |
tree | ece61a2c212ea7503ce3c2d2e94fdf52ea9ee19a /libavutil/cpu.c | |
parent | a69cedb6a641c7dd742adac917f63fe3c0c8a064 (diff) | |
download | ffmpeg-5d71f97e0e02740bf85c6de9c2855e5592bd053c.tar.gz |
all: Don't use ATOMIC_VAR_INIT
C11 required to use ATOMIC_VAR_INIT to statically initialize
atomic objects with static storage duration. Yet this macro
was unsuitable for initializing structures [1] and was actually
unneeded for all known implementations (this includes our
compatibility fallback implementations which simply wrap the value
in parentheses: #define ATOMIC_VAR_INIT(value) (value)).
Therefore C17 deprecated the macro and C23 actually removed it [2].
Since commit 5ff0eb34d2b1089d3dd9f27fdb51520001709138 we default
to C17 if the compiler supports it; Clang warns about ATOMIC_VAR_INIT
in this mode. Given that no implementation ever needed this macro,
this commit stops using it to avoid this warning.
[1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_485
[2]: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavutil/cpu.c')
-rw-r--r-- | libavutil/cpu.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 48d195168c..d4f947360a 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -49,8 +49,8 @@ #include <unistd.h> #endif -static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1); -static atomic_int cpu_count = ATOMIC_VAR_INIT(-1); +static atomic_int cpu_flags = -1; +static atomic_int cpu_count = -1; static int get_cpu_flags(void) { @@ -208,7 +208,7 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) int av_cpu_count(void) { - static atomic_int printed = ATOMIC_VAR_INIT(0); + static atomic_int printed = 0; int nb_cpus = 1; int count = 0; |