Merge branch 'flat_combinig_add_stress_and_unint_tests' of https://github.com/mgalimu...
[libcds.git] / cds / compiler / gcc / compiler_macro.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_GCC_COMPILER_MACRO_H
32 #define CDSLIB_COMPILER_GCC_COMPILER_MACRO_H
33
34 // OS interface && OS name
35 #ifndef CDS_OS_TYPE
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"
81 #   else
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"
86 #   endif
87 #endif // #ifndef CDS_OS_TYPE
88
89 // Processor architecture
90
91 #if defined(__arm__) && !defined(__ARM_ARCH)
92     // GCC 4.6 does not defined __ARM_ARCH
93 #   if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__)
94 #       define __ARM_ARCH   7
95 #   else
96 #       define __ARM_ARCH   5
97 #   endif
98 #endif
99
100 #if defined(__x86_64__) || defined(__amd64__) || defined(__amd64)
101 #   define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_AMD64
102 #   define CDS_BUILD_BITS        64
103 #   define CDS_PROCESSOR__NAME   "Intel x86-64"
104 #   define CDS_PROCESSOR__NICK   "amd64"
105 #elif defined(__i386__)
106 #   define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_X86
107 #   define CDS_BUILD_BITS        32
108 #   define CDS_PROCESSOR__NAME   "Intel x86"
109 #   define CDS_PROCESSOR__NICK   "x86"
110 #elif defined(sparc) || defined (__sparc__)
111 #   define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_SPARC
112 #   define CDS_PROCESSOR__NAME   "Sparc"
113 #   define CDS_PROCESSOR__NICK   "sparc"
114 #   ifdef __arch64__
115 #       define CDS_BUILD_BITS   64
116 #    else
117 #       error Sparc 32bit is not supported
118 #    endif
119 #elif defined( __ia64__)
120 #    define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_IA64
121 #    define CDS_BUILD_BITS        64
122 #    define CDS_PROCESSOR__NAME   "Intel IA64"
123 #    define CDS_PROCESSOR__NICK   "ia64"
124 #elif defined(_ARCH_PPC64)
125 #    define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_PPC64
126 #    define CDS_BUILD_BITS        64
127 #    define CDS_PROCESSOR__NAME   "IBM PowerPC64"
128 #    define CDS_PROCESSOR__NICK   "ppc64"
129 #elif defined(__arm__) && __SIZEOF_POINTER__ == 4 && __ARM_ARCH >= 7
130 #    define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_ARM7
131 #    define CDS_BUILD_BITS        32
132 #    define CDS_PROCESSOR__NAME   "ARM v7"
133 #    define CDS_PROCESSOR__NICK   "arm7"
134 #else
135 #   if defined(CDS_USE_LIBCDS_ATOMIC)
136 #       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"
137 #   else
138 #       define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_UNKNOWN
139 #       define CDS_BUILD_BITS        32
140 #       define CDS_PROCESSOR__NAME   "unknown"
141 #       define CDS_PROCESSOR__NICK   "unknown"
142 #   endif
143 #endif
144
145 #if CDS_OS_TYPE == CDS_OS_MINGW
146 #   ifdef CDS_BUILD_LIB
147 #       define CDS_EXPORT_API          __declspec(dllexport)
148 #   else
149 #       define CDS_EXPORT_API          __declspec(dllimport)
150 #   endif
151 #else
152 #   ifndef __declspec
153 #       define __declspec( _x )
154 #   endif
155 #endif
156
157 #if CDS_PROCESSOR_ARCH == CDS_PROCESSOR_X86
158 #   define CDS_STDCALL __attribute__((stdcall))
159 #else
160 #   define CDS_STDCALL
161 #endif
162
163
164 #endif // #ifndef CDSLIB_COMPILER_GCC_COMPILER_MACRO_H