summaryrefslogtreecommitdiffstats
path: root/compat
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-05 17:02:06 +0200
committerAlessandro Ghedini <alessandro@ghedini.me>2014-07-05 19:04:00 +0200
commit00997484f1127c96ed4080aaec33745b0f10badf (patch)
tree8e639ea4fddd73d2f4be0655d6a56e10b487a2a4 /compat
parentea556e5398e7281a0874bc3ba634a1b76d79a35d (diff)
downloadmpv-00997484f1127c96ed4080aaec33745b0f10badf.tar.bz2
mpv-00997484f1127c96ed4080aaec33745b0f10badf.tar.xz
build: allow compilation without any atomics
Not all compilers on all platforms have atomics available (even if they could, technically speaking). We don't use atomics that much, only the following things rely on it: 1. the audio pull code, and all audio outputs using it 2. updating global msg levels 3. reading log messages through the client API Just disable 1. and 3. if atomics are not available. For 2., using fake- atomics isn't too bad; at worst, message levels won't properly update under certain situations (but most likely, it will work just fine). This means if atomics are not available, the client API function mpv_request_log_messages() will do nothing. CC: @mpv-player/stable
Diffstat (limited to 'compat')
-rw-r--r--compat/atomics.h15
1 files changed, 13 insertions, 2 deletions
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 <inttypes.h>
#include "config.h"
+#define HAVE_ATOMICS 1
+
#if HAVE_STDATOMIC
#include <stdatomic.h>
#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 */