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