Improved management of SkipList auxiliary nodes: now aux nodes are allocated from...
[libcds.git] / cds / compiler / vc / defs.h
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
5
6     Source code repo: http://github.com/khizmax/libcds/
7     Download: http://sourceforge.net/projects/libcds/files/
8
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions are met:
11
12     * Redistributions of source code must retain the above copyright notice, this
13       list of conditions and the following disclaimer.
14
15     * Redistributions in binary form must reproduce the above copyright notice,
16       this list of conditions and the following disclaimer in the documentation
17       and/or other materials provided with the distribution.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef CDSLIB_COMPILER_VC_DEFS_H
32 #define CDSLIB_COMPILER_VC_DEFS_H
33 //@cond
34
35 // Compiler version
36 #define CDS_COMPILER_VERSION    _MSC_VER
37
38 // Compiler name
39 // Supported compilers: MS VC 2013
40 // C++ compiler versions:
41 #define CDS_COMPILER_MSVC12 1800    // 2013 vc12
42 #define CDS_COMPILER_MSVC14 1900    // 2015 vc14
43
44 #if CDS_COMPILER_VERSION < CDS_COMPILER_MSVC12
45 #   error "Only MS Visual C++ 12 (2013) Update 4 and above is supported"
46 #endif
47
48 #if _MSC_VER == 1800
49 #   define  CDS_COMPILER__NAME  "MS Visual C++ 2013"
50 #   define  CDS_COMPILER__NICK  "vc12"
51 #   define  CDS_COMPILER_LIBCDS_SUFFIX "vc12"
52 #elif _MSC_VER == 1900
53 #   define  CDS_COMPILER__NAME  "MS Visual C++ 2015"
54 #   define  CDS_COMPILER__NICK  "vc14"
55 #   define  CDS_COMPILER_LIBCDS_SUFFIX "vcv140"
56 #else
57 #   define  CDS_COMPILER__NAME  "MS Visual C++"
58 #   define  CDS_COMPILER__NICK  "msvc"
59 #   define  CDS_COMPILER_LIBCDS_SUFFIX "vc"
60 #endif
61
62 // OS interface
63 #define CDS_OS_INTERFACE CDS_OSI_WINDOWS
64
65 // OS name
66 #if defined(_WIN64)
67 #   define CDS_OS_TYPE      CDS_OS_WIN64
68 #   define CDS_OS__NAME     "Win64"
69 #   define CDS_OS__NICK     "Win64"
70 #elif defined(_WIN32)
71 #   define CDS_OS_TYPE      CDS_OS_WIN32
72 #   define CDS_OS__NAME     "Win32"
73 #   define CDS_OS__NICK     "Win32"
74 #endif
75
76 // Processor architecture
77 #ifdef _M_IX86
78 #   define CDS_BUILD_BITS       32
79 #   define CDS_PROCESSOR_ARCH   CDS_PROCESSOR_X86
80 #   define CDS_PROCESSOR__NAME  "Intel x86"
81 #   define CDS_PROCESSOR__NICK  "x86"
82 #elif _M_X64
83 #   define CDS_BUILD_BITS       64
84 #   define CDS_PROCESSOR_ARCH   CDS_PROCESSOR_AMD64
85 #   define CDS_PROCESSOR__NAME  "AMD64"
86 #   define CDS_PROCESSOR__NICK  "amd64"
87 #else
88 #   define CDS_BUILD_BITS        -1
89 #   define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_UNKNOWN
90 #   define CDS_PROCESSOR__NAME    "<<Undefined>>"
91 #   error Microsoft Visual C++ compiler is supported for x86 only
92 #endif
93
94 #define  __attribute__( _x )
95
96 #define  CDS_STDCALL    __stdcall
97
98 #ifdef CDS_BUILD_LIB
99 #   define CDS_EXPORT_API          __declspec(dllexport)
100 #else
101 #   define CDS_EXPORT_API          __declspec(dllimport)
102 #endif
103
104 #define alignof     __alignof
105
106 // Memory leaks detection (debug build only)
107 #ifdef _DEBUG
108 #   define _CRTDBG_MAP_ALLOC
109 #   define _CRTDBG_MAPALLOC
110 #   include <stdlib.h>
111 #   include <crtdbg.h>
112 #   define CDS_MSVC_MEMORY_LEAKS_DETECTING_ENABLED
113 #endif
114
115 // constexpr is not yet supported
116 #define CDS_CONSTEXPR
117
118 // noexcept - vc14 +
119 #if CDS_COMPILER_VERSION > CDS_COMPILER_MSVC12
120 #   define CDS_NOEXCEPT_SUPPORT        noexcept
121 #   define CDS_NOEXCEPT_SUPPORT_(expr) noexcept(expr)
122 #else
123 #   define CDS_NOEXCEPT_SUPPORT
124 #   define CDS_NOEXCEPT_SUPPORT_(expr)
125 #endif
126
127 // C++11 inline namespace
128 #if CDS_COMPILER_VERSION > CDS_COMPILER_MSVC12
129 #   define CDS_CXX11_INLINE_NAMESPACE_SUPPORT
130 #endif
131
132 #if CDS_COMPILER_VERSION == CDS_COMPILER_MSVC12
133     // VC12: move ctor cannot be defaulted
134     // Error: C2610 [move ctor] is not a special member function which can be defaulted
135 #   define CDS_DISABLE_DEFAULT_MOVE_CTOR
136 #endif
137
138 // Full SFINAE support
139 #if CDS_COMPILER_VERSION > CDS_COMPILER_MSVC12
140 #   define CDS_CXX11_SFINAE
141 #endif
142
143 // Inheriting constructors
144 #if CDS_COMPILER_VERSION > CDS_COMPILER_MSVC12
145 #   define CDS_CXX11_INHERITING_CTOR
146 #endif
147
148 // *************************************************
149 // Alignment macro
150
151 #define CDS_TYPE_ALIGNMENT(n)     __declspec( align(n) )
152 #define CDS_DATA_ALIGNMENT(n)     __declspec( align(n) )
153 #define CDS_CLASS_ALIGNMENT(n)    __declspec( align(n) )
154
155 // Attributes
156 #if CDS_COMPILER_VERSION >= CDS_COMPILER_MSVC14
157 #   define CDS_DEPRECATED( reason ) [[deprecated( reason )]]
158 #else
159 #   define CDS_DEPRECATED( reason ) __declspec(deprecated( reason ))
160 #endif
161
162 // double-width CAS support
163 //#define CDS_DCAS_SUPPORT
164
165 #include <cds/compiler/vc/compiler_barriers.h>
166
167 //@endcond
168 #endif // #ifndef CDSLIB_COMPILER_VC_DEFS_H