summaryrefslogtreecommitdiff
path: root/libavutil/cpu.h
diff options
context:
space:
mode:
authorWan-Teh Chang <wtc-at-google.com@ffmpeg.org>2016-12-06 18:16:13 -0800
committerMichael Niedermayer <michael@niedermayer.cc>2016-12-13 00:07:20 +0100
commitfed50c4304eecb352e29ce789cdb96ea84d6162f (patch)
tree2514d8429a6926deb5a056b7417a747c0431c7d1 /libavutil/cpu.h
parent4cf3def805cf522ddd9c24c24ef1246b008bac2c (diff)
avutil: fix data race in av_get_cpu_flags()
Make the one-time initialization in av_get_cpu_flags() thread-safe. The static variable |cpu_flags| in libavutil/cpu.c is read and written using normal load and store operations. These are considered as data races. The fix is to use atomic load and store operations. The fix can be verified by running the libavutil/tests/cpu_init.c test program under ThreadSanitizer: ./configure --toolchain=clang-tsan make libavutil/tests/cpu_init libavutil/tests/cpu_init There should be no warnings from ThreadSanitizer. Co-author: Dmitry Vyukov of Google, who suggested the data race fix. Signed-off-by: Wan-Teh Chang <wtc@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavutil/cpu.h')
-rw-r--r--libavutil/cpu.h2
1 files changed, 0 insertions, 2 deletions
diff --git a/libavutil/cpu.h b/libavutil/cpu.h
index 4bff16714a..8499f0ea8b 100644
--- a/libavutil/cpu.h
+++ b/libavutil/cpu.h
@@ -85,8 +85,6 @@ void av_force_cpu_flags(int flags);
* Set a mask on flags returned by av_get_cpu_flags().
* This function is mainly useful for testing.
* Please use av_force_cpu_flags() and av_get_cpu_flags() instead which are more flexible
- *
- * @warning this function is not thread safe.
*/
attribute_deprecated void av_set_cpu_flags_mask(int mask);