[UBsan] Added macro CDS_SUPPRESS_SANITIZE for sanitizers to suppress some warnings
[libcds.git] / cds / compiler / icl / 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-2017
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_ICL_DEFS_H
32 #define CDSLIB_COMPILER_ICL_DEFS_H
33 //@cond
34
35 // Compiler version
36 #ifdef __ICL
37 #   define CDS_COMPILER_VERSION    __ICL
38 #else
39 #   define CDS_COMPILER_VERSION    __INTEL_COMPILER
40 #endif
41
42 // Compiler name
43 // Supported compilers: MS VC 2008, 2010, 2012
44 //
45 #   define  CDS_COMPILER__NAME  "Intel C++"
46 #   define  CDS_COMPILER__NICK  "icl"
47
48 // OS name
49 #if defined(_WIN64)
50 #   define CDS_OS_INTERFACE CDS_OSI_WINDOWS
51 #   define CDS_OS_TYPE      CDS_OS_WIN64
52 #   define CDS_OS__NAME     "Win64"
53 #   define CDS_OS__NICK     "Win64"
54 #elif defined(_WIN32)
55 #   define CDS_OS_INTERFACE CDS_OSI_WINDOWS
56 #   define CDS_OS_TYPE      CDS_OS_WIN32
57 #   define CDS_OS__NAME     "Win32"
58 #   define CDS_OS__NICK     "Win32"
59 #elif defined( __linux__ )
60 #   define CDS_OS_INTERFACE     CDS_OSI_UNIX
61 #   define CDS_OS_TYPE          CDS_OS_LINUX
62 #   define CDS_OS__NAME         "linux"
63 #   define CDS_OS__NICK         "linux"
64 #endif
65
66 // Processor architecture
67 #if defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__) || defined(__amd64)
68 #   define CDS_BUILD_BITS       64
69 #   define CDS_PROCESSOR_ARCH   CDS_PROCESSOR_AMD64
70 #   define CDS_PROCESSOR__NAME  "AMD64"
71 #   define CDS_PROCESSOR__NICK  "amd64"
72 #elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
73 #   define CDS_BUILD_BITS       32
74 #   define CDS_PROCESSOR_ARCH   CDS_PROCESSOR_X86
75 #   define CDS_PROCESSOR__NAME  "Intel x86"
76 #   define CDS_PROCESSOR__NICK  "x86"
77 #else
78 #   define CDS_BUILD_BITS        -1
79 #   define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_UNKNOWN
80 #   define CDS_PROCESSOR__NAME    "<<Undefined>>"
81 #   error Intel C++ compiler is supported for x86 only
82 #endif
83
84 #if CDS_OS_INTERFACE == CDS_OSI_WINDOWS
85 #   define  __attribute__( _x )
86 #endif
87
88 #if CDS_OS_INTERFACE == CDS_OSI_WINDOWS
89 #   ifdef CDS_BUILD_LIB
90 #       define CDS_EXPORT_API          __declspec(dllexport)
91 #   else
92 #       define CDS_EXPORT_API          __declspec(dllimport)
93 #   endif
94 #endif
95
96 #if CDS_OS_INTERFACE == CDS_OSI_WINDOWS
97 #   define alignof     __alignof
98 #else
99 #   define alignof __alignof__
100 #endif
101
102 #define CDS_CONSTEXPR    constexpr
103
104 #define CDS_NOEXCEPT_SUPPORT        noexcept
105 #define CDS_NOEXCEPT_SUPPORT_(expr) noexcept(expr)
106
107 // C++11 inline namespace
108 #define CDS_CXX11_INLINE_NAMESPACE_SUPPORT
109
110 // Inheriting constructors
111 #define CDS_CXX11_INHERITING_CTOR
112
113 // *************************************************
114 // Alignment macro
115
116 #if CDS_OS_INTERFACE == CDS_OSI_WINDOWS
117 #   define CDS_TYPE_ALIGNMENT(n)     __declspec( align(n))
118 #   define CDS_DATA_ALIGNMENT(n)     __declspec( align(n))
119 #   define CDS_CLASS_ALIGNMENT(n)    __declspec( align(n))
120 #else
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 #endif
125
126 // Attributes
127 #if CDS_OS_INTERFACE == CDS_OSI_WINDOWS
128 #   define CDS_DEPRECATED( reason ) __declspec(deprecated( reason ))
129 #   define CDS_NORETURN __declspec(noreturn)
130 #else
131 #   define CDS_DEPRECATED( reason ) __attribute__((deprecated( reason )))
132 #   define CDS_NORETURN __attribute__((__noreturn__))
133 #endif
134
135 // Exceptions
136
137 #if CDS_OS_INTERFACE == CDS_OSI_WINDOWS
138 #   if defined( _CPPUNWIND )
139 #       define CDS_EXCEPTION_ENABLED
140 #   endif
141 #else
142 #   if defined( __EXCEPTIONS ) && __EXCEPTIONS == 1
143 #       define CDS_EXCEPTION_ENABLED
144 #   endif
145 #endif
146
147 // Byte order
148 #if !defined(CDS_ARCH_LITTLE_ENDIAN) && !defined(CDS_ARCH_BIG_ENDIAN)
149 #   if CDS_OS_INTERFACE == CDS_OSI_WINDOWS
150 #       define CDS_ARCH_LITTLE_ENDIAN
151 #   else
152 #       ifdef __BYTE_ORDER__
153 #           if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
154 #               define CDS_ARCH_LITTLE_ENDIAN
155 #           elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
156 #               define CDS_ARCH_BIG_ENDIAN
157 #           endif
158 #       else
159 #           warning "Undefined byte order for current architecture (no __BYTE_ORDER__ preprocessor definition)"
160 #       endif
161 #   endif
162 #endif
163
164 // Sanitizer attributes (not supported)
165 #define CDS_SUPPRESS_SANITIZE( ... )
166
167 #include <cds/compiler/icl/compiler_barriers.h>
168
169 //@endcond
170 #endif // #ifndef CDSLIB_COMPILER_VC_DEFS_H