diff mbox

[FFmpeg-devel] configure: check for stdatomic.h

Message ID 1479966893-87403-1-git-send-email-wtc@google.com
State Accepted
Commit 6a4e24280dd7f15c41628ebfb01ee25661d8b258
Headers show

Commit Message

Wan-Teh Chang Nov. 24, 2016, 5:54 a.m. UTC
From: Anton Khirnov <anton@khirnov.net>

Since this is a C11 feature, it requires -std=c11.

Not actually used for anything yet, that will be added in the following
commits.

This merges libav commit 13f5d2bf75b95a0bfdb9940a5e359a719e242bed.

Signed-off-by: Wan-Teh Chang <wtc@google.com>
---
 configure | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 27, 2016, 11:57 a.m. UTC | #1
On Wed, Nov 23, 2016 at 09:54:53PM -0800, Wan-Teh Chang wrote:
> From: Anton Khirnov <anton@khirnov.net>
> 
> Since this is a C11 feature, it requires -std=c11.
> 
> Not actually used for anything yet, that will be added in the following
> commits.
> 
> This merges libav commit 13f5d2bf75b95a0bfdb9940a5e359a719e242bed.
> 
> Signed-off-by: Wan-Teh Chang <wtc@google.com>
> ---
>  configure | 29 ++++++++++++++++++++++++++++-
>  1 file changed, 28 insertions(+), 1 deletion(-)

applied

thx

[...]
diff mbox

Patch

diff --git a/configure b/configure
index 875fbf3..0176f9c 100755
--- a/configure
+++ b/configure
@@ -1189,6 +1189,19 @@  check_cpp_condition(){
 EOF
 }
 
+test_cflags_cpp(){
+    log test_cflags_cpp "$@"
+    flags=$1
+    condition=$2
+    shift 2
+    set -- $($cflags_filter "$flags")
+    check_cpp "$@" <<EOF
+#if !($condition)
+#error "unsatisfied condition: $condition"
+#endif
+EOF
+}
+
 check_lib(){
     log check_lib "$@"
     header="$1"
@@ -1835,6 +1848,7 @@  HEADERS_LIST="
     poll_h
     sndio_h
     soundcard_h
+    stdatomic_h
     sys_mman_h
     sys_param_h
     sys_resource_h
@@ -4578,7 +4592,15 @@  fi
 add_cppflags -D_ISOC99_SOURCE
 add_cxxflags -D__STDC_CONSTANT_MACROS
 add_cxxflags -std=c++98
-check_cflags -std=c99
+
+# some compilers silently accept -std=c11, so we also need to check that the
+# version macro is defined properly
+if test_cflags_cpp -std=c11 "__STDC_VERSION__ >= 201112L"; then
+    add_cflags -std=c11
+else
+    check_cflags -std=c99
+fi
+
 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
 #include <stdlib.h>
 EOF
@@ -5568,6 +5590,11 @@  check_header windows.h
 check_header X11/extensions/XvMClib.h
 check_header asm/types.h
 
+# it seems there are versions of clang in some distros that try to use the
+# gcc headers, which explodes for stdatomic
+# so we also check that atomics actually work here
+check_builtin stdatomic_h stdatomic.h "atomic_int foo; atomic_store(&foo, 0)"
+
 check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
 check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi