summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2014-01-01 20:42:13 +0100
committerwm4 <wm4@nowhere>2014-01-01 20:57:27 +0100
commit29b68d69c05406460602c40a5222e941547b2f87 (patch)
tree8c6e450881184b114490155fe77e4d984fad18da
parent6c770eb6df068d4c19894e5e64d8d129a843f756 (diff)
downloadmpv-29b68d69c05406460602c40a5222e941547b2f87.tar.bz2
mpv-29b68d69c05406460602c40a5222e941547b2f87.tar.xz
build: make configure fail if both __atomic and __sync are not available
-rw-r--r--compat/atomics.h4
-rwxr-xr-xold-configure18
-rw-r--r--wscript18
3 files changed, 37 insertions, 3 deletions
diff --git a/compat/atomics.h b/compat/atomics.h
index 368476a964..14f0f2720f 100644
--- a/compat/atomics.h
+++ b/compat/atomics.h
@@ -24,7 +24,9 @@
#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
+#elif HAVE_SYNC_BUILTINS
# define mp_memory_barrier() __sync_synchronize()
# define mp_atomic_add_and_fetch(a, b) __sync_add_and_fetch(a, b)
+#else
+# error "this should have been a configuration error, report a bug please"
#endif
diff --git a/old-configure b/old-configure
index 34c553695b..b8c2ed1f7c 100755
--- a/old-configure
+++ b/old-configure
@@ -1343,6 +1343,23 @@ else
fi
echores "$_atomic"
+if test "$_atomic" = no ; then
+ echocheck "compiler support for __sync built-ins"
+ _sync=no
+ statement_check stdint.h 'int64_t test = 0; test = __sync_add_and_fetch(&test, 1)' && _sync=yes
+ if test "$_sync" = yes ; then
+ def_sync="#define HAVE_SYNC_BUILTINS 1"
+ else
+ def_sync="#define HAVE_SYNC_BUILTINS 0"
+ fi
+ echores "$_sync"
+else
+ def_sync="#define HAVE_SYNC_BUILTINS 0"
+fi
+
+if test "$_atomic" = no && test "$_sync" = no ; then
+ die "your compiler must support either __atomic or __aync bult-ins."
+fi
if test "$_pthreads" = yes ; then
@@ -3537,6 +3554,7 @@ $def_avresample_has_set_channel_mapping
$def_fast_64bit
$def_pthreads
$def_atomic
+$def_sync
#define HAVE_INLINE_ASM 1
diff --git a/wscript b/wscript
index 7a6ee4fb02..ae3bb1d8c1 100644
--- a/wscript
+++ b/wscript
@@ -77,7 +77,7 @@ main_dependencies = [
'desc': 'linker support for --nxcompat --no-seh --dynamicbase',
'func': check_cc(linkflags=['-Wl,--nxcompat', '-Wl,--no-seh', '-Wl,--dynamicbase'])
}, {
- 'name': 'ebx_available',
+ 'name': 'ebx-available',
'desc': 'ebx availability',
'func': check_cc(fragment=load_fragment('ebx.c'))
} , {
@@ -99,13 +99,27 @@ main_dependencies = [
'req': True,
'fmsg': 'Unable to find pthreads support.'
}, {
- 'name': 'atomic_builtins',
+ 'name': 'atomic-builtins',
'desc': 'compiler support for __atomic built-ins',
'func': check_libs(['atomic'],
check_statement('stdint.h',
'int64_t test = 0;'
'test = __atomic_add_fetch(&test, 1, __ATOMIC_SEQ_CST)'))
}, {
+ 'name': 'sync-builtins',
+ 'desc': 'compiler support for __sync built-ins',
+ 'func': check_statement('stdint.h',
+ 'int64_t test = 0;'
+ 'test = __sync_add_and_fetch(&test, 1)'),
+ 'deps_neg': [ 'atomic-builtins' ],
+ }, {
+ 'name': 'thread-synchronization-builtins',
+ 'desc': 'compiler support for usable thread synchronization built-ins',
+ 'func': check_true,
+ 'deps_any': ['atomic-builtins', 'sync-builtins'],
+ 'req': True,
+ 'fmsg': 'your compiler must support either __atomic or __aync bult-ins',
+ }, {
'name': 'librt',
'desc': 'linking with -lrt',
'deps': [ 'pthreads' ],