1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-12 01:46:16 +00:00

compat: use __atomic operations instead of __sync, when present

Fixes #434
Fixes #437
This commit is contained in:
Alessandro Ghedini 2013-12-30 16:33:50 +01:00 committed by wm4
parent 773db053aa
commit 416015f059

View File

@ -19,5 +19,12 @@
// At this point both gcc and clang had __sync_synchronize support for some
// time. We only support a full memory barrier.
#define mp_memory_barrier() __sync_synchronize()
#define mp_atomic_add_and_fetch(a, b) __sync_add_and_fetch(a, b)
#include "config.h"
#if HAVE_ATOMIC_BUILTINS
# define mp_memory_barrier() __atomic_thread_fence(__ATOMIC_SEQ_CST)
# define mp_atomic_add_and_fetch(a, b) __atomic_add_fetch(a, b,__ATOMIC_SEQ_CST)
#else
# define mp_memory_barrier() __sync_synchronize()
# define mp_atomic_add_and_fetch(a, b) __sync_add_and_fetch(a, b)
#endif