diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-06-12 05:51:12 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-06-15 04:56:37 +0200 |
commit | 40e6575aa3eed64cd32bf28c00ae57edc5acb25a (patch) | |
tree | 3bc6e3ebca1972cf51f04e30f227e46ff204ec05 /libavutil/cpu.c | |
parent | e5f6707a7b91664491041526ef3cce7412258b89 (diff) | |
download | ffmpeg-40e6575aa3eed64cd32bf28c00ae57edc5acb25a.tar.gz |
all: Replace if (ARCH_FOO) checks by #if ARCH_FOO
This is more spec-compliant because it does not rely
on dead-code elimination by the compiler. Especially
MSVC has problems with this, as can be seen in
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296373.html
or
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/297022.html
This commit does not eliminate every instance where we rely
on dead code elimination: It only tackles branching to
the initialization of arch-specific dsp code, not e.g. all
uses of CONFIG_ and HAVE_ checks. But maybe it is already
enough to compile FFmpeg with MSVC with whole-programm-optimizations
enabled (if one does not disable too many components).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavutil/cpu.c')
-rw-r--r-- | libavutil/cpu.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 24b99d2554..0035e927a5 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -54,18 +54,19 @@ static atomic_int cpu_count = ATOMIC_VAR_INIT(-1); static int get_cpu_flags(void) { - if (ARCH_MIPS) - return ff_get_cpu_flags_mips(); - if (ARCH_AARCH64) - return ff_get_cpu_flags_aarch64(); - if (ARCH_ARM) - return ff_get_cpu_flags_arm(); - if (ARCH_PPC) - return ff_get_cpu_flags_ppc(); - if (ARCH_X86) - return ff_get_cpu_flags_x86(); - if (ARCH_LOONGARCH) - return ff_get_cpu_flags_loongarch(); +#if ARCH_MIPS + return ff_get_cpu_flags_mips(); +#elif ARCH_AARCH64 + return ff_get_cpu_flags_aarch64(); +#elif ARCH_ARM + return ff_get_cpu_flags_arm(); +#elif ARCH_PPC + return ff_get_cpu_flags_ppc(); +#elif ARCH_X86 + return ff_get_cpu_flags_x86(); +#elif ARCH_LOONGARCH + return ff_get_cpu_flags_loongarch(); +#endif return 0; } @@ -252,18 +253,19 @@ void av_cpu_force_count(int count) size_t av_cpu_max_align(void) { - if (ARCH_MIPS) - return ff_get_cpu_max_align_mips(); - if (ARCH_AARCH64) - return ff_get_cpu_max_align_aarch64(); - if (ARCH_ARM) - return ff_get_cpu_max_align_arm(); - if (ARCH_PPC) - return ff_get_cpu_max_align_ppc(); - if (ARCH_X86) - return ff_get_cpu_max_align_x86(); - if (ARCH_LOONGARCH) - return ff_get_cpu_max_align_loongarch(); +#if ARCH_MIPS + return ff_get_cpu_max_align_mips(); +#elif ARCH_AARCH64 + return ff_get_cpu_max_align_aarch64(); +#elif ARCH_ARM + return ff_get_cpu_max_align_arm(); +#elif ARCH_PPC + return ff_get_cpu_max_align_ppc(); +#elif ARCH_X86 + return ff_get_cpu_max_align_x86(); +#elif ARCH_LOONGARCH + return ff_get_cpu_max_align_loongarch(); +#endif return 8; } |