Move libcds 1.6.0 from SVN
[libcds.git] / cds / compiler / gcc / compiler_macro.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_COMPILER_GCC_COMPILER_MACRO_H
4 #define __CDS_COMPILER_GCC_COMPILER_MACRO_H
5
6 // OS interface && OS name
7 #if defined( __linux__ )
8 #   define CDS_OS_INTERFACE     CDS_OSI_UNIX
9 #   define CDS_OS_TYPE          CDS_OS_LINUX
10 #   define CDS_OS__NAME         "linux"
11 #   define CDS_OS__NICK         "linux"
12 #elif defined( __sun__ )
13 #   define CDS_OS_INTERFACE     CDS_OSI_UNIX
14 #   define CDS_OS_TYPE          CDS_OS_SUN_SOLARIS
15 #   define CDS_OS__NAME         "Sun Solaris"
16 #   define CDS_OS__NICK         "sun"
17 #elif defined( __hpux__ )
18 #   define CDS_OS_INTERFACE     CDS_OSI_UNIX
19 #   define CDS_OS_TYPE          CDS_OS_HPUX
20 #   define CDS_OS__NAME         "HP-UX"
21 #   define CDS_OS__NICK         "hpux"
22 #elif defined( _AIX )
23 #   define CDS_OS_INTERFACE     CDS_OSI_UNIX
24 #   define CDS_OS_TYPE          CDS_OS_AIX
25 #   define CDS_OS__NAME         "AIX"
26 #   define CDS_OS__NICK         "aix"
27 #elif defined( __FreeBSD__ )
28 #   define CDS_OS_INTERFACE     CDS_OSI_UNIX
29 #   define CDS_OS_TYPE          CDS_OS_FREE_BSD
30 #   define CDS_OS__NAME         "FreeBSD"
31 #   define CDS_OS__NICK         "freebsd"
32 #elif defined( __OpenBSD__ )
33 #   define CDS_OS_INTERFACE     CDS_OSI_UNIX
34 #   define CDS_OS_TYPE          CDS_OS_OPEN_BSD
35 #   define CDS_OS__NAME         "OpenBSD"
36 #   define CDS_OS__NICK         "openbsd"
37 #elif defined( __NetBSD__ )
38 #   define CDS_OS_INTERFACE     CDS_OSI_UNIX
39 #   define CDS_OS_TYPE          CDS_OS_NET_BSD
40 #   define CDS_OS__NAME         "NetBSD"
41 #   define CDS_OS__NICK         "netbsd"
42 #elif defined(__MINGW32__) || defined( __MINGW64__)
43 #   define CDS_OS_INTERFACE     CDS_OSI_WINDOWS
44 #   define CDS_OS_TYPE          CDS_OS_MINGW
45 #   define CDS_OS__NAME         "MinGW"
46 #   define CDS_OS__NICK         "mingw"
47 #elif defined(__MACH__)
48 #   define CDS_OS_INTERFACE     CDS_OSI_UNIX
49 #   define CDS_OS_TYPE          CDS_OS_OSX
50 #   define CDS_OS__NAME         "OS X"
51 #   define CDS_OS__NICK         "osx"
52 #else
53 #   define CDS_OS_INTERFACE     CDS_OSI_UNIX
54 #   define CDS_OS_TYPE          CDS_OS_PTHREAD
55 #   define CDS_OS__NAME         "pthread"
56 #   define CDS_OS__NICK         "pthread"
57 #endif
58
59 // Processor architecture
60
61 #if defined(__arm__) && !defined(__ARM_ARCH)
62     // GCC 4.6 does not defined __ARM_ARCH
63 #   if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__)
64 #       define __ARM_ARCH   7
65 #   else
66 #       define __ARM_ARCH   5
67 #   endif
68 #endif
69
70 #if defined(__x86_64__) || defined(__amd64__) || defined(__amd64)
71 #   define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_AMD64
72 #   define CDS_BUILD_BITS        64
73 #   define CDS_PROCESSOR__NAME   "Intel x86-64"
74 #   define CDS_PROCESSOR__NICK   "amd64"
75 #elif defined(__i386__)
76 #   define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_X86
77 #   define CDS_BUILD_BITS        32
78 #   define CDS_PROCESSOR__NAME   "Intel x86"
79 #   define CDS_PROCESSOR__NICK   "x86"
80 #elif defined(sparc) || defined (__sparc__)
81 #   define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_SPARC
82 #   define CDS_PROCESSOR__NAME   "Sparc"
83 #   define CDS_PROCESSOR__NICK   "sparc"
84 #   ifdef __arch64__
85 #       define CDS_BUILD_BITS   64
86 #    else
87 #       error Sparc 32bit is not supported
88 #    endif
89 #elif defined( __ia64__)
90 #    define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_IA64
91 #    define CDS_BUILD_BITS        64
92 #    define CDS_PROCESSOR__NAME   "Intel IA64"
93 #    define CDS_PROCESSOR__NICK   "ia64"
94 #elif defined(_ARCH_PPC64)
95 #    define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_PPC64
96 #    define CDS_BUILD_BITS        64
97 #    define CDS_PROCESSOR__NAME   "IBM PowerPC64"
98 #    define CDS_PROCESSOR__NICK   "ppc64"
99 #elif defined(__arm__) && __SIZEOF_POINTER__ == 4 && __ARM_ARCH >= 7
100 #    define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_ARM7
101 #    define CDS_BUILD_BITS        32
102 #    define CDS_PROCESSOR__NAME   "ARM v7"
103 #    define CDS_PROCESSOR__NICK   "arm7"
104 #else
105 #   if defined(CDS_USE_LIBCDS_ATOMIC)
106 #       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"
107 #   elif !defined(CDS_USE_BOOST_ATOMIC) && !defined(CDS_CXX11_ATOMIC_SUPPORT)
108 #       error "The current compiler does not support C++11 atomic. Try to use boost.atomic (-DCDS_USE_BOOST_ATOMIC) or C++11 compiler"
109 #   else
110 #       define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_UNKNOWN
111 #       define CDS_BUILD_BITS        32
112 #       define CDS_PROCESSOR__NAME   "unknown"
113 #       define CDS_PROCESSOR__NICK   "unknown"
114 #   endif
115 #endif
116
117 #if CDS_OS_TYPE == CDS_OS_MINGW
118 #   ifdef CDS_BUILD_LIB
119 #       define CDS_EXPORT_API          __declspec(dllexport)
120 #   else
121 #       define CDS_EXPORT_API          __declspec(dllimport)
122 #   endif
123 #else
124 #   ifndef __declspec
125 #       define __declspec( _x )
126 #   endif
127 #endif
128
129 #if CDS_PROCESSOR_ARCH == CDS_PROCESSOR_X86
130 #   define CDS_STDCALL __attribute__((stdcall))
131 #else
132 #   define CDS_STDCALL
133 #endif
134
135
136 #endif // #ifndef __CDS_COMPILER_GCC_COMPILER_MACRO_H