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