12a2ab4e63c0d018e9040d03c76d140784dd3e5e
[libcds.git] / cds / compiler / clang / defs.h
1 //$$CDS-header$$
2
3 #ifndef CDSLIB_COMPILER_CLANG_DEFS_H
4 #define CDSLIB_COMPILER_CLANG_DEFS_H
5
6 /*
7     Known issues:
8         Error compiling 64bit boost.atomic on clang 3.4 - 3.5, see https://svn.boost.org/trac/boost/ticket/9610
9         Solution: use boost 1.56 +
10 */
11
12 // Compiler version
13 #define CDS_COMPILER_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
14
15 // Compiler name
16 #define  CDS_COMPILER__NAME    ("clang " __clang_version__)
17 #define  CDS_COMPILER__NICK    "clang"
18
19 #if CDS_COMPILER_VERSION < 30300
20 #   error "Compiler version error. Clang version 3.3.0 and above is supported"
21 #endif
22
23 #if defined(_LIBCPP_VERSION) && !defined(CDS_USE_BOOST_ATOMIC)
24     // Note: Clang libc++ atomic leads to program crash.
25     // So, we use libcds atomic implementation
26 #   define CDS_USE_LIBCDS_ATOMIC
27 #endif
28
29 // clang for Windows
30 #if defined( _MSC_VER )
31 #   define CDS_OS_INTERFACE     CDS_OSI_WINDOWS
32 #   if defined(_WIN64)
33 #       define CDS_OS_TYPE      CDS_OS_WIN64
34 #       define CDS_OS__NAME     "Win64"
35 #       define CDS_OS__NICK     "Win64"
36 #   elif defined(_WIN32)
37 #       define CDS_OS_TYPE      CDS_OS_WIN32
38 #       define CDS_OS__NAME     "Win32"
39 #       define CDS_OS__NICK     "Win32"
40 #   endif
41 #endif
42
43 #include <cds/compiler/gcc/compiler_macro.h>
44
45 #define alignof __alignof__
46
47 // C++11 inline namespace
48 #define CDS_CXX11_INLINE_NAMESPACE_SUPPORT
49
50 #define CDS_CONSTEXPR    constexpr
51
52 #define CDS_NOEXCEPT_SUPPORT        noexcept
53 #define CDS_NOEXCEPT_SUPPORT_(expr) noexcept(expr)
54
55 // C++11 thread_local keyword
56 #if !(CDS_OS_TYPE == CDS_OS_OSX && CDS_COMPILER_VERSION < 30600)
57     // OS X error?
58     // See http://stackoverflow.com/questions/23791060/c-thread-local-storage-clang-503-0-40-mac-osx
59     // http://stackoverflow.com/questions/28094794/why-does-apple-clang-disallow-c11-thread-local-when-official-clang-supports
60     // clang 3.6 ok?..
61 #   define CDS_CXX11_THREAD_LOCAL_SUPPORT
62 #endif
63
64 // Full SFINAE support
65 #define CDS_CXX11_SFINAE
66
67 // Inheriting constructors
68 #define CDS_CXX11_INHERITING_CTOR
69
70 // Attributes
71 #if CDS_COMPILER_VERSION >= 30400
72 #   if __cplusplus < 201103
73 #       define CDS_DEPRECATED( reason ) __attribute__((deprecated( reason )))
74 #   elif __cplusplus == 201103 // C++11
75 #       define CDS_DEPRECATED( reason ) [[gnu::deprecated(reason)]]
76 #   else  // C++14
77 #       define CDS_DEPRECATED( reason ) [[deprecated(reason)]]
78 #   endif
79 #else
80 #   define CDS_DEPRECATED( reason ) __attribute__((deprecated( reason )))
81 #endif
82
83 // *************************************************
84 // Features
85 #if defined(__has_feature) && __has_feature(thread_sanitizer)
86 #   define CDS_THREAD_SANITIZER_ENABLED
87 #endif
88
89 // *************************************************
90 // Alignment macro
91
92 #define CDS_TYPE_ALIGNMENT(n)   __attribute__ ((aligned (n)))
93 #define CDS_CLASS_ALIGNMENT(n)  __attribute__ ((aligned (n)))
94 #define CDS_DATA_ALIGNMENT(n)   __attribute__ ((aligned (n)))
95
96
97 #include <cds/compiler/gcc/compiler_barriers.h>
98
99 #endif // #ifndef CDSLIB_COMPILER_GCC_DEFS_H