mirror of
https://github.com/mpv-player/mpv
synced 2025-03-19 09:57:34 +00:00
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.
This commit is contained in:
parent
1a86bb59df
commit
0317d7350e
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user