diff --git a/common/msg.c b/common/msg.c index 9b05e55660..4f9bd886a5 100644 --- a/common/msg.c +++ b/common/msg.c @@ -469,6 +469,10 @@ struct mp_log_buffer *mp_msg_log_buffer_new(struct mpv_global *global, { struct mp_log_root *root = global->log->root; +#if !HAVE_ATOMICS + return NULL; +#endif + pthread_mutex_lock(&mp_msg_lock); struct mp_log_buffer *buffer = talloc_ptrtype(NULL, buffer); diff --git a/compat/atomics.h b/compat/atomics.h index 797992f876..e5fb717a78 100644 --- a/compat/atomics.h +++ b/compat/atomics.h @@ -22,6 +22,8 @@ #include #include "config.h" +#define HAVE_ATOMICS 1 + #if HAVE_STDATOMIC #include #else @@ -58,8 +60,17 @@ typedef struct { volatile unsigned long long v; } atomic_ullong; __sync_fetch_and_add(&(a)->v, b) #else -# error "this should have been a configuration error, report a bug please" -#endif + +// This is extremely wrong. The build system actually disables code that has +// a serious dependency on working atomics, so this is barely ok. +#define atomic_load(p) ((p)->v) +#define atomic_store(p, val) ((p)->v = (val)) +#define atomic_fetch_add(a, b) (((a)->v += (b)) - (b)) + +#undef HAVE_ATOMICS +#define HAVE_ATOMICS 0 + +#endif /* no atomics */ #endif /* else HAVE_STDATOMIC */ diff --git a/wscript b/wscript index b4550a88ec..bb55ba411e 100644 --- a/wscript +++ b/wscript @@ -138,12 +138,10 @@ main_dependencies = [ 'test = __sync_add_and_fetch(&test, 1)'), 'deps_neg': [ 'stdatomic', 'atomic-builtins' ], }, { - 'name': 'thread-synchronization-builtins', + 'name': 'atomics', 'desc': 'compiler support for usable thread synchronization built-ins', 'func': check_true, 'deps_any': ['stdatomic', 'atomic-builtins', 'sync-builtins'], - 'req': True, - 'fmsg': 'your compiler must support either __atomic or __sync built-ins', }, { 'name': 'librt', 'desc': 'linking with -lrt', @@ -419,11 +417,13 @@ audio_output_features = [ { 'name': '--sdl2', 'desc': 'SDL2', + 'deps': ['atomics'], 'func': check_pkg_config('sdl2'), 'default': 'disable' }, { 'name': '--sdl1', 'desc': 'SDL (1.x)', + 'deps': ['atomics'], 'deps_neg': [ 'sdl2' ], 'func': check_pkg_config('sdl'), 'default': 'disable' @@ -478,12 +478,13 @@ audio_output_features = [ }, { 'name': '--portaudio', 'desc': 'PortAudio audio output', - 'deps': [ 'pthreads' ], + 'deps': [ 'atomics' ], 'func': check_pkg_config('portaudio-2.0', '>= 19'), 'default': 'disable', }, { 'name': '--jack', 'desc': 'JACK audio output', + 'deps': ['atomics'], 'func': check_pkg_config('jack'), }, { 'name': '--openal', @@ -497,6 +498,7 @@ audio_output_features = [ }, { 'name': '--coreaudio', 'desc': 'CoreAudio audio output', + 'deps': ['atomics'], 'func': check_cc( fragment=load_fragment('coreaudio.c'), framework_name=['CoreFoundation', 'CoreAudio', 'AudioUnit', 'AudioToolbox']) @@ -507,6 +509,7 @@ audio_output_features = [ }, { 'name': '--wasapi', 'desc': 'WASAPI audio output', + 'deps': ['atomics'], 'func': check_cc(fragment=load_fragment('wasapi.c'), lib='ole32'), } ]