2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
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.
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.
31 #ifndef CDSLIB_COMPILER_GCC_COMPILER_MACRO_H
32 #define CDSLIB_COMPILER_GCC_COMPILER_MACRO_H
34 // OS interface && OS name
36 # if defined( __linux__ )
37 # define CDS_OS_INTERFACE CDS_OSI_UNIX
38 # define CDS_OS_TYPE CDS_OS_LINUX
39 # define CDS_OS__NAME "linux"
40 # define CDS_OS__NICK "linux"
41 # elif defined( __sun__ )
42 # define CDS_OS_INTERFACE CDS_OSI_UNIX
43 # define CDS_OS_TYPE CDS_OS_SUN_SOLARIS
44 # define CDS_OS__NAME "Sun Solaris"
45 # define CDS_OS__NICK "sun"
46 # elif defined( __hpux__ )
47 # define CDS_OS_INTERFACE CDS_OSI_UNIX
48 # define CDS_OS_TYPE CDS_OS_HPUX
49 # define CDS_OS__NAME "HP-UX"
50 # define CDS_OS__NICK "hpux"
51 # elif defined( _AIX )
52 # define CDS_OS_INTERFACE CDS_OSI_UNIX
53 # define CDS_OS_TYPE CDS_OS_AIX
54 # define CDS_OS__NAME "AIX"
55 # define CDS_OS__NICK "aix"
56 # elif defined( __FreeBSD__ )
57 # define CDS_OS_INTERFACE CDS_OSI_UNIX
58 # define CDS_OS_TYPE CDS_OS_FREE_BSD
59 # define CDS_OS__NAME "FreeBSD"
60 # define CDS_OS__NICK "freebsd"
61 # elif defined( __OpenBSD__ )
62 # define CDS_OS_INTERFACE CDS_OSI_UNIX
63 # define CDS_OS_TYPE CDS_OS_OPEN_BSD
64 # define CDS_OS__NAME "OpenBSD"
65 # define CDS_OS__NICK "openbsd"
66 # elif defined( __NetBSD__ )
67 # define CDS_OS_INTERFACE CDS_OSI_UNIX
68 # define CDS_OS_TYPE CDS_OS_NET_BSD
69 # define CDS_OS__NAME "NetBSD"
70 # define CDS_OS__NICK "netbsd"
71 # elif defined(__MINGW32__) || defined( __MINGW64__)
72 # define CDS_OS_INTERFACE CDS_OSI_WINDOWS
73 # define CDS_OS_TYPE CDS_OS_MINGW
74 # define CDS_OS__NAME "MinGW"
75 # define CDS_OS__NICK "mingw"
76 # elif defined(__MACH__)
77 # define CDS_OS_INTERFACE CDS_OSI_UNIX
78 # define CDS_OS_TYPE CDS_OS_OSX
79 # define CDS_OS__NAME "OS X"
80 # define CDS_OS__NICK "osx"
82 # define CDS_OS_INTERFACE CDS_OSI_UNIX
83 # define CDS_OS_TYPE CDS_OS_PTHREAD
84 # define CDS_OS__NAME "pthread"
85 # define CDS_OS__NICK "pthread"
87 #endif // #ifndef CDS_OS_TYPE
89 // Processor architecture
91 #if defined(__arm__) && !defined(__ARM_ARCH)
92 // GCC 4.6 does not defined __ARM_ARCH
93 # if defined(__ARM_ARCH_8A__) || defined(__ARM_ARCH_8S__) || defined(__aarch64__) || defined(__ARM_ARCH_ISA_A64)
95 # elif defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7S__)
102 #if defined(__x86_64__) || defined(__amd64__) || defined(__amd64)
103 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_AMD64
104 # define CDS_BUILD_BITS 64
105 # define CDS_PROCESSOR__NAME "Intel x86-64"
106 # define CDS_PROCESSOR__NICK "amd64"
107 #elif defined(__i386__)
108 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_X86
109 # define CDS_BUILD_BITS 32
110 # define CDS_PROCESSOR__NAME "Intel x86"
111 # define CDS_PROCESSOR__NICK "x86"
112 #elif defined(sparc) || defined (__sparc__)
113 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_SPARC
114 # define CDS_PROCESSOR__NAME "Sparc"
115 # define CDS_PROCESSOR__NICK "sparc"
117 # define CDS_BUILD_BITS 64
119 # error Sparc 32bit is not supported
121 #elif defined( __ia64__)
122 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_IA64
123 # define CDS_BUILD_BITS 64
124 # define CDS_PROCESSOR__NAME "Intel IA64"
125 # define CDS_PROCESSOR__NICK "ia64"
126 #elif defined(_ARCH_PPC64)
127 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_PPC64
128 # define CDS_BUILD_BITS 64
129 # define CDS_PROCESSOR__NAME "IBM PowerPC64"
130 # define CDS_PROCESSOR__NICK "ppc64"
131 #elif defined(__arm__) && __SIZEOF_POINTER__ == 4 && __ARM_ARCH >= 7 && __ARM_ARCH < 8
132 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_ARM7
133 # define CDS_BUILD_BITS 32
134 # define CDS_PROCESSOR__NAME "ARM v7"
135 # define CDS_PROCESSOR__NICK "arm7"
136 #elif ( defined(__arm__) || defined(__aarch64__)) && __ARM_ARCH >= 8
137 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_ARM8
138 # define CDS_BUILD_BITS 64
139 # define CDS_PROCESSOR__NAME "ARM v8"
140 # define CDS_PROCESSOR__NICK "arm8"
142 # if defined(CDS_USE_LIBCDS_ATOMIC)
143 # error "Libcds does not support atomic implementation for the processor architecture. Try to use C++11-compatible compiler and remove CDS_USE_LIBCDS_ATOMIC flag from compiler command line"
145 # define CDS_PROCESSOR_ARCH CDS_PROCESSOR_UNKNOWN
146 # define CDS_BUILD_BITS 32
147 # define CDS_PROCESSOR__NAME "unknown"
148 # define CDS_PROCESSOR__NICK "unknown"
152 #if CDS_OS_TYPE == CDS_OS_MINGW
153 # ifdef CDS_BUILD_LIB
154 # define CDS_EXPORT_API __declspec(dllexport)
156 # define CDS_EXPORT_API __declspec(dllimport)
160 # define __declspec(_x)
165 #if !defined(CDS_ARCH_LITTLE_ENDIAN) && !defined(CDS_ARCH_BIG_ENDIAN)
166 # ifdef __BYTE_ORDER__
167 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
168 # define CDS_ARCH_LITTLE_ENDIAN
169 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
170 # define CDS_ARCH_BIG_ENDIAN
173 # warning "Undefined byte order for current architecture (no __BYTE_ORDER__ preprocessor definition)"
177 // Sanitizer attributes
178 // Example: CDS_DISABLE_SANITIZE( "function" )
179 #ifdef CDS_ADDRESS_SANITIZER_ENABLED
180 # define CDS_SUPPRESS_SANITIZE( ... ) __attribute__(( no_sanitize( __VA_ARGS__ )))
182 # define CDS_SUPPRESS_SANITIZE( ... )
186 #endif // #ifndef CDSLIB_COMPILER_GCC_COMPILER_MACRO_H