On Mon, Nov 21, 2016 at 03:37:49PM -0800, Wan-Teh Chang wrote: > Make the one-time initialization in av_get_cpu_flags() thread-safe. > The fix assumes -1 is an invalid value for cpu flags.
please explain the bug / race that occurs and how it is fixed
>
> The fix requires new atomic functions to get, set, and compare-and-swap
> an integer without a memory barrier.
why ?
>
> The data race fix is written by Dmitry Vyukov of Google.
Then the author for the git patch should be set accordingly
[...]
> @@ -44,7 +45,20 @@
> #include <unistd.h>
> #endif
>
> -static int flags, checked;
> +static int cpu_flags = -1;
> +
> +static int get_cpu_flags(void)
> +{
> + 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();
> + /* Not reached. */
src/libavutil/cpu.c: In function ‘get_cpu_flags’:
src/libavutil/cpu.c:61: error: control reaches end of non-void function
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have often repented speaking, but never of holding my tongue.
-- Xenocrates
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list [email protected] http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
