blktrace: needs MMU support
[buildroot-gz.git] / package / openal / 0001-Fix-detection-of-C11-atomics.patch
blobc6b98409086a40744e3fa944849fa92b50377af7
1 From 10fee6d71a1f7d6e6319005196562b4a30b4e8ff Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Tue, 2 Feb 2016 14:58:52 +0100
4 Subject: [PATCH] Fix detection of C11 atomics
6 Currently, the CMakeLists.txt logic to detect the availability of C11
7 atomics is based on building a small program that uses the
8 atomic_load().
10 However, atomic_load() does not need to use any function from
11 libatomic (part of the gcc runtime). So even if libatomic is missing,
12 this test concludes that C11 atomic support is available. For example
13 on SPARC, the example program builds fine without linking to
14 libatomic, but calling other functions of the atomic_*() APIs fail
15 without linking to libatomic.
17 So, this patch adjusts the CMakeLists.txt test to use a function that
18 is known to require the libatomic run-time library (on architectures
19 where it is needed). This way, openal will only use the __atomic_*()
20 built-ins when they are actually functional.
22 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
23 ---
24 CMakeLists.txt | 7 +++++--
25 1 file changed, 5 insertions(+), 2 deletions(-)
27 diff --git a/CMakeLists.txt b/CMakeLists.txt
28 index 5784d35..a53f996 100644
29 --- a/CMakeLists.txt
30 +++ b/CMakeLists.txt
31 @@ -209,14 +209,17 @@ CHECK_C_SOURCE_COMPILES(
32 HAVE_C11_ALIGNAS)
34 # Check if we have C11 _Atomic
35 +set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
36 +set(CMAKE_REQUIRED_LIBRARIES ${EXTRA_LIBS})
37 CHECK_C_SOURCE_COMPILES(
38 "#include <stdatomic.h>
39 - const int _Atomic foo = ATOMIC_VAR_INIT(~0);
40 + int _Atomic foo = ATOMIC_VAR_INIT(~0);
41 int main()
43 - return atomic_load(&foo);
44 + return atomic_fetch_add(&foo, 2);
46 HAVE_C11_ATOMIC)
47 +set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
49 # Add definitions, compiler switches, etc.
50 INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
51 --
52 2.6.4