c17115ac462a1400547193df83bc0712b346d89a
[libcds.git] / cds / compiler / clang / defs.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_COMPILER_CLANG_DEFS_H
4 #define __CDS_COMPILER_CLANG_DEFS_H
5
6 // Compiler version
7 #define CDS_COMPILER_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
8
9 // Compiler name
10 #define  CDS_COMPILER__NAME    ("clang " __clang_version__)
11 #define  CDS_COMPILER__NICK    "clang"
12
13 #if defined(_LIBCPP_VERSION)
14     // Note: Clang libc++ atomic leads to program crash.
15     // So, we use libcds atomic implementation
16 #   define CDS_USE_LIBCDS_ATOMIC
17 #endif
18
19 #include <cds/compiler/gcc/compiler_macro.h>
20
21 #define alignof __alignof__
22
23 // Variadic template support (only if -std=c++0x compile-line option provided)
24 #if __has_feature(cxx_variadic_templates)
25 #   define CDS_CXX11_VARIADIC_TEMPLATE_SUPPORT
26 #endif
27
28 // Default template arguments for function templates
29 #if __has_feature(cxx_default_function_template_args)
30 #   define CDS_CXX11_DEFAULT_FUNCTION_TEMPLATE_ARGS_SUPPORT
31 #endif
32
33 #if __has_feature(cxx_deleted_functions)
34 // C++11 delete definition ( function declaration = delete)
35 #   define CDS_CXX11_DELETE_DEFINITION_SUPPORT
36 #endif
37
38 #if __has_feature(cxx_defaulted_functions)
39 // C++11 explicitly-defaulted function (= default) [std 8.4.2 [dcl.fct.def.default]]
40 #   define CDS_CXX11_EXPLICITLY_DEFAULTED_FUNCTION_SUPPORT
41 #endif
42
43 // Explicit conversion operators
44 #if __has_feature(cxx_explicit_conversions)
45 #   define CDS_CXX11_EXPLICIT_CONVERSION_OPERATOR_SUPPORT
46 #endif
47
48 // C++11 template alias
49 #if __has_feature(cxx_alias_templates)
50 #   define CDS_CXX11_TEMPLATE_ALIAS_SUPPORT
51 #endif
52
53 // C++11 inline namespace
54 #if __has_feature(cxx_inline_namespaces)
55 #   define CDS_CXX11_INLINE_NAMESPACE_SUPPORT
56 #endif
57
58 // Lambda
59 #if __has_feature(cxx_lambdas)
60 #   define CDS_CXX11_LAMBDA_SUPPORT
61 #endif
62
63 // RValue
64 #if __has_feature(cxx_rvalue_references)
65 #   define CDS_RVALUE_SUPPORT
66 #   define CDS_MOVE_SEMANTICS_SUPPORT
67 #endif
68
69 #if __has_feature(cxx_constexpr)
70 #   define CDS_CONSTEXPR    constexpr
71 #   define CDS_CONSTEXPR_CONST constexpr const
72 #else
73 #   define CDS_CONSTEXPR
74 #   define CDS_CONSTEXPR_CONST const
75 #endif
76
77 #if __has_feature(cxx_noexcept)
78 #   define CDS_NOEXCEPT_SUPPORT        noexcept
79 #   define CDS_NOEXCEPT_SUPPORT_(expr) noexcept(expr)
80 #else
81 #   define CDS_NOEXCEPT_SUPPORT
82 #   define CDS_NOEXCEPT_SUPPORT_(expr)
83 #endif
84
85 // C++11 thread_local keyword
86 #if __has_feature(cxx_thread_local)         // CLang 3.3
87 #   define CDS_CXX11_THREAD_LOCAL_SUPPORT
88 #endif
89
90 // Thread support library (thread, mutex, condition variable, chrono)
91 #if CDS_COMPILER_VERSION >= 30100
92 #   if __has_include(<thread>)
93 #       define CDS_CXX11_STDLIB_THREAD
94 #   endif
95
96 #   if __has_include(<chrono>)
97 #       define CDS_CXX11_STDLIB_CHRONO
98 #   endif
99
100 #   if __has_include(<mutex>)
101 #       define CDS_CXX11_STDLIB_MUTEX
102 #   endif
103
104 #   if __has_include(<condition_variable>)
105 #       define CDS_CXX11_STDLIB_CONDITION_VARIABLE
106 #   endif
107 #endif
108
109 // Full SFINAE support
110 #define CDS_CXX11_SFINAE
111
112 // *************************************************
113 // Alignment macro
114
115 #define CDS_TYPE_ALIGNMENT(n)   __attribute__ ((aligned (n)))
116 #define CDS_CLASS_ALIGNMENT(n)  __attribute__ ((aligned (n)))
117 #define CDS_DATA_ALIGNMENT(n)   __attribute__ ((aligned (n)))
118
119
120 #include <cds/compiler/gcc/compiler_barriers.h>
121
122 #endif // #ifndef __CDS_COMPILER_GCC_DEFS_H