diff options
author | wm4 <wm4@nowhere> | 2018-05-21 19:54:21 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2018-05-24 19:56:35 +0200 |
commit | 0317d7350ea247c04472c82f925a0bc065959ef6 (patch) | |
tree | 02df0848b560ef9fafc1898acdc0685d1a9fe270 /options/m_config.c | |
parent | 1a86bb59dfdc68baf0075a14c13a63c219adc08d (diff) | |
download | mpv-0317d7350ea247c04472c82f925a0bc065959ef6.tar.bz2 mpv-0317d7350ea247c04472c82f925a0bc065959ef6.tar.xz |
m_config: fix build with emulated stdatomic
C11 can access atomic variables normally (in which case they use the
strictest memory access semantics). But the mpv stdatomic wrapper for
C99 compilers does not allow it, because it couldn't give any
guarantees. This means we always need to access them with atomic macros.
While we're at, use relaxed semantics for the m_config_cache field,
since because it's accessed from a single thread only (essentially
used in a non-atomic way). Switch the comparison arguments to make the
formatting look slightly less weird.
Diffstat (limited to 'options/m_config.c')
-rw-r--r-- | options/m_config.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/options/m_config.c b/options/m_config.c index 8d66a1955e..4adb64384e 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -1314,7 +1314,7 @@ static bool update_options(struct m_config_data *dst, struct m_config_data *src) struct m_group_data *gdst = m_config_gdata(dst, n); assert(gsrc && gdst); - if (gsrc->ts <= gdst->ts) + if (gdst->ts >= gsrc->ts) continue; gdst->ts = gsrc->ts; res = true; @@ -1337,7 +1337,8 @@ bool m_config_cache_update(struct m_config_cache *cache) // Using atomics and checking outside of the lock - it's unknown whether // this makes it faster or slower. Just cargo culting it. - if (atomic_load(&shadow->data->ts) <= cache->data->ts) + if (atomic_load_explicit(&cache->data->ts, memory_order_relaxed) >= + atomic_load(&shadow->data->ts)) return false; pthread_mutex_lock(&shadow->lock); |