fixed adding file problem
[c11concurrency-benchmarks.git] / gdax-orderbook-hpp / demo / dependencies / libcds-2.3.2 / cds / compiler / clang / 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_CLANG_DEFS_H
32 #define CDSLIB_COMPILER_CLANG_DEFS_H
33
34 // Compiler version
35 #define CDS_COMPILER_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
36
37 // Compiler name
38 #define  CDS_COMPILER__NAME    ("clang " __clang_version__)
39 #define  CDS_COMPILER__NICK    "clang"
40
41 #if CDS_COMPILER_VERSION < 30600
42 #   error "Compiler version error. Clang version 3.6.0 and above is supported"
43 #endif
44
45 #if __cplusplus < CDS_CPLUSPLUS_11
46 #   error C++11 and above is required
47 #endif
48
49 #if defined(_LIBCPP_VERSION) && !defined(CDS_USE_BOOST_ATOMIC) && CDS_COMPILER_VERSION < 30700
50     // Note: Clang libc++ atomic leads to program crash.
51     // So, we use libcds atomic implementation
52 #   define CDS_USE_LIBCDS_ATOMIC
53 #endif
54
55 // clang for Windows
56 #if defined( _MSC_VER )
57 #   define CDS_OS_INTERFACE     CDS_OSI_WINDOWS
58 #   if defined(_WIN64)
59 #       define CDS_OS_TYPE      CDS_OS_WIN64
60 #       define CDS_OS__NAME     "Win64"
61 #       define CDS_OS__NICK     "Win64"
62 #   elif defined(_WIN32)
63 #       define CDS_OS_TYPE      CDS_OS_WIN32
64 #       define CDS_OS__NAME     "Win32"
65 #       define CDS_OS__NICK     "Win32"
66 #   endif
67 #endif
68
69 #include <cds/compiler/gcc/compiler_macro.h>
70
71 #define alignof __alignof__
72
73 // C++11 thread_local keyword
74 #if !(CDS_OS_TYPE == CDS_OS_OSX && CDS_COMPILER_VERSION < 30600)
75     // OS X error?
76     // See http://stackoverflow.com/questions/23791060/c-thread-local-storage-clang-503-0-40-mac-osx
77     // http://stackoverflow.com/questions/28094794/why-does-apple-clang-disallow-c11-thread-local-when-official-clang-supports
78     // clang 3.6 ok?..
79 #   define CDS_CXX11_THREAD_LOCAL_SUPPORT
80 #endif
81
82 // Attributes
83 #if CDS_COMPILER_VERSION >= 30600
84 #   if __cplusplus == CDS_CPLUSPLUS_11 // C++11
85 #       define CDS_DEPRECATED( reason ) [[gnu::deprecated(reason)]]
86 #   else  // C++14
87 #       define CDS_DEPRECATED( reason ) [[deprecated(reason)]]
88 #   endif
89 #endif
90
91 #define CDS_NORETURN __attribute__((__noreturn__))
92
93 // *************************************************
94 // Features
95 #if defined(__has_feature) && __has_feature(thread_sanitizer)
96 #   ifndef CDS_THREAD_SANITIZER_ENABLED
97 #       define CDS_THREAD_SANITIZER_ENABLED
98 #   endif
99 #endif
100
101 #if defined(__has_feature) && __has_feature(address_sanitizer)
102 #   ifndef CDS_ADDRESS_SANITIZER_ENABLED
103 #       define CDS_ADDRESS_SANITIZER_ENABLED
104 #   endif
105 #endif
106
107
108 // *************************************************
109 // Alignment macro
110
111 #define CDS_TYPE_ALIGNMENT(n)   __attribute__ ((aligned (n)))
112 #define CDS_CLASS_ALIGNMENT(n)  __attribute__ ((aligned (n)))
113 #define CDS_DATA_ALIGNMENT(n)   __attribute__ ((aligned (n)))
114
115
116 // likely/unlikely
117
118 #define cds_likely( expr )   __builtin_expect( !!( expr ), 1 )
119 #define cds_unlikely( expr ) __builtin_expect( !!( expr ), 0 )
120
121 // Exceptions
122 #if defined( __EXCEPTIONS ) && __EXCEPTIONS == 1
123 #   define CDS_EXCEPTION_ENABLED
124 #endif
125
126
127 // double-width CAS support - only for libc++
128 // You can manually suppress wide-atomic support by defining in compiler command line:
129 //  for 64bit platform: -DCDS_DISABLE_128BIT_ATOMIC
130 //  for 32bit platform: -DCDS_DISABLE_64BIT_ATOMIC
131 #ifdef _LIBCPP_VERSION
132 #   if CDS_BUILD_BITS == 64
133 #       if !defined( CDS_DISABLE_128BIT_ATOMIC ) && defined( __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 )
134 #           define CDS_DCAS_SUPPORT
135 #       endif
136 #   else
137 #       if !defined( CDS_DISABLE_64BIT_ATOMIC ) && defined( __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 )
138 #           define CDS_DCAS_SUPPORT
139 #       endif
140 #   endif
141 #endif
142
143 //if constexpr support (C++17)
144 #ifndef constexpr_if
145 #   if defined( __cpp_if_constexpr ) && __cpp_if_constexpr >= 201606
146 #       define constexpr_if if constexpr
147 #   endif
148 #endif
149
150 #include <cds/compiler/gcc/compiler_barriers.h>
151
152 #endif // #ifndef CDSLIB_COMPILER_GCC_DEFS_H