Move libcds 1.6.0 from SVN
[libcds.git] / cds / compiler / gcc / defs.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_COMPILER_GCC_DEFS_H
4 #define __CDS_COMPILER_GCC_DEFS_H
5
6 // Compiler version
7 #define CDS_COMPILER_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
8
9 #if CDS_COMPILER_VERSION < 40300
10 #   error "Compiler version error. GCC version 4.3.0 and above is supported"
11 #endif
12
13 // Compiler name
14 #ifdef __VERSION__
15 #   define  CDS_COMPILER__NAME    ("GNU C++ " __VERSION__)
16 #else
17 #   define  CDS_COMPILER__NAME    "GNU C++"
18 #endif
19 #define  CDS_COMPILER__NICK        "gcc"
20
21 // C++11 atomic support
22 #if CDS_COMPILER_VERSION >= 40700
23 #   define CDS_CXX11_ATOMIC_SUPPORT     1
24 #elif defined(CDS_CXX11_ATOMIC_GCC)
25 #   define CDS_CXX11_ATOMIC_SUPPORT     1
26 #endif
27
28
29 #include <cds/compiler/gcc/compiler_macro.h>
30
31
32 #define alignof __alignof__
33
34 // ***************************************
35 // C++11 features
36
37 // Variadic template support (only if -std=c++0x compile-line option provided)
38 #if CDS_COMPILER_VERSION >= 40300
39 #   define CDS_CXX11_VARIADIC_TEMPLATE_SUPPORT
40 #endif
41
42 // RValue
43 #if CDS_COMPILER_VERSION >= 40300
44 #   define CDS_RVALUE_SUPPORT
45 #   define CDS_MOVE_SEMANTICS_SUPPORT
46 #endif
47
48 // Default template arguments for function templates
49 #if CDS_COMPILER_VERSION >= 40300
50 #   define CDS_CXX11_DEFAULT_FUNCTION_TEMPLATE_ARGS_SUPPORT
51 #endif
52
53 // C++11 inline namespace
54 #if CDS_COMPILER_VERSION >= 40400
55 #   define CDS_CXX11_INLINE_NAMESPACE_SUPPORT
56 #endif
57
58 // Delete definition and explicitly-defaulted function
59 #if CDS_COMPILER_VERSION >= 40400
60 // C++11 delete definition ( function declaration = delete)
61 #   define CDS_CXX11_DELETE_DEFINITION_SUPPORT
62
63 // C++11 explicitly-defaulted function (= default) [std 8.4.2 [dcl.fct.def.default]]
64 #   define CDS_CXX11_EXPLICITLY_DEFAULTED_FUNCTION_SUPPORT
65 #endif
66
67 // Lambda
68 #if CDS_COMPILER_VERSION >= 40500
69 #   define CDS_CXX11_LAMBDA_SUPPORT
70 #   if CDS_COMPILER_VERSION < 40800
71 #       define CDS_BUG_STATIC_MEMBER_IN_LAMBDA
72 #   endif
73 #endif
74
75 // Explicit conversion operator
76 #if CDS_COMPILER_VERSION >= 40500
77 #   define CDS_CXX11_EXPLICIT_CONVERSION_OPERATOR_SUPPORT
78 #endif
79
80 #if CDS_COMPILER_VERSION >= 40600
81 #   define CDS_CONSTEXPR    constexpr
82 #   define CDS_NOEXCEPT_SUPPORT        noexcept
83 #   define CDS_NOEXCEPT_SUPPORT_(expr) noexcept(expr)
84 #   if CDS_COMPILER_VERSION >= 40600 && CDS_COMPILER_VERSION < 40700
85     // GCC 4.6.x does not allow noexcept specification in defaulted function
86     // void foo() noexcept = default
87     // error: function \91foo\92 defaulted on its first declaration must not have an exception-specification
88 #       define CDS_NOEXCEPT_DEFAULTED
89 #       define CDS_NOEXCEPT_DEFAULTED_(expr)
90     // GCC 4.6.x: constexpr and const are incompatible in variable declaration
91 #       define CDS_CONSTEXPR_CONST const
92 #   else
93 #       define CDS_CONSTEXPR_CONST constexpr const
94 #   endif
95 #else
96 #   define CDS_CONSTEXPR
97 #   define CDS_CONSTEXPR_CONST const
98 #   define CDS_NOEXCEPT_SUPPORT
99 #   define CDS_NOEXCEPT_SUPPORT_(expr)
100 #endif
101
102 // C++11 template alias
103 #if CDS_COMPILER_VERSION >= 40700
104 #   define CDS_CXX11_TEMPLATE_ALIAS_SUPPORT
105 #endif
106
107 // C++11 thread_local keyword
108 #if CDS_COMPILER_VERSION >= 40800
109 #   define CDS_CXX11_THREAD_LOCAL_SUPPORT
110 #endif
111
112
113 #if defined( CDS_CXX11_EXPLICITLY_DEFAULTED_FUNCTION_SUPPORT ) && defined(CDS_MOVE_SEMANTICS_SUPPORT) && CDS_COMPILER_VERSION >= 40400 && CDS_COMPILER_VERSION < 40600
114     // GCC 4.4 - 4.5 bug: move ctor & assignment operator cannot be defaulted
115 #   define CDS_DISABLE_DEFAULT_MOVE_CTOR
116 #endif
117
118 #include <cds/compiler/cstdint_std.h>
119
120 // Thread support library (thread, mutex, condition variable, chrono)
121 #if CDS_COMPILER_VERSION >= 40800
122 #   define CDS_CXX11_STDLIB_THREAD
123 #   define CDS_CXX11_STDLIB_MUTEX
124 #   define CDS_CXX11_STDLIB_CONDITION_VARIABLE
125 #   define CDS_CXX11_STDLIB_CHRONO
126 #endif
127
128 // Full SFINAE support
129 #if CDS_COMPILER_VERSION >= 40700
130 #   define CDS_CXX11_SFINAE
131 #endif
132
133 // *************************************************
134 // Alignment macro
135
136 #define CDS_TYPE_ALIGNMENT(n)   __attribute__ ((aligned (n)))
137 #define CDS_CLASS_ALIGNMENT(n)  __attribute__ ((aligned (n)))
138 #define CDS_DATA_ALIGNMENT(n)   __attribute__ ((aligned (n)))
139
140
141 #include <cds/compiler/gcc/compiler_barriers.h>
142
143 #endif // #ifndef __CDS_COMPILER_GCC_DEFS_H