msg: use relaxed atomics for log level test

This should be sufficient.

If stdatomic.h is not available, we make no difference.

(cherry picked from commit 01b87e509c)
This commit is contained in:
wm4 2015-03-02 19:09:31 +01:00 committed by Diogo Franco (Kovensky)
parent e682d82527
commit 931f614257
2 changed files with 9 additions and 1 deletions

View File

@ -136,8 +136,11 @@ bool mp_msg_test(struct mp_log *log, int lev)
struct mp_log_root *root = log->root;
if (!root || root->mute)
return false;
if (atomic_load(&log->reload_counter) != atomic_load(&root->reload_counter))
if (atomic_load_explicit(&log->reload_counter, memory_order_relaxed) !=
atomic_load_explicit(&root->reload_counter, memory_order_relaxed))
{
update_loglevel(log);
}
return lev <= log->level;
}

View File

@ -41,6 +41,11 @@ typedef struct { volatile unsigned long long v; } atomic_ullong;
#define ATOMIC_VAR_INIT(x) \
{.v = (x)}
#define memory_order_relaxed 1
#define memory_order_seq_cst 2
#define atomic_load_explicit(p, e) atomic_load(p)
#if HAVE_ATOMIC_BUILTINS
#define atomic_load(p) \