From 0317d7350ea247c04472c82f925a0bc065959ef6 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 21 May 2018 19:54:21 +0200 Subject: 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. --- options/m_config.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'options/m_config.c') 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); -- cgit v1.2.3