casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
aipsenv.h
Go to the documentation of this file.
1 //# aipsenv.h: Global initialization for special Casacore macros
2 //# Copyright (C) 2000,2001,2002,2003,2004,2016
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 // this file contains all the compiler specific defines
29 
30 #ifndef CASA_AIPSENV_H
31 #define CASA_AIPSENV_H
32 
33 namespace casacore { //# NAMESPACE CASACORE - BEGIN
34 
35 // Set if compiler supports C++11 or newer
36 #if __cplusplus >= 201103L
37 #define AIPS_CXX11
38 #endif
39 
40 // Set if compiler supports C++14 or newer
41 #if __cplusplus >= 201402L
42 #define AIPS_CXX11
43 #define AIPS_CXX14
44 #endif
45 
46 // Set if GCC compiler is used.
47 #if defined(AIPS_GCC)
48 #undef AIPS_GCC
49 #endif
50 #if defined(__GNUC__)
51 #define AIPS_GCC
52 #endif
53 
54 /* ONLY USE IF CODE WILL _NOT_ WORK WITH NEWER VERSIONS */
55 #if defined(AIPS_GCC2)
56 #undef AIPS_GCC2
57 #endif
58 #if (defined(AIPS_GCC) && __GNUC_CC == 2)
59 #define AIPS_GCC2
60 #endif
61 
62 /* ONLY USE IF CODE WILL _NOT_ WORK WITH NEWER VERSIONS */
63 #if defined(AIPS_GCC295)
64 #undef AIPS_GCC295
65 #endif
66 #if (defined(AIPS_GCC2) && __GNUC_MINOR__ == 95)
67 #define AIPS_GCC295
68 #endif
69 
70 /* ONLY USE IF CODE WILL _NOT_ WORK WITH NEWER VERSIONS */
71 #if defined(AIPS_GCC3)
72 #undef AIPS_GCC3
73 #endif
74 #if (defined(AIPS_GCC) && __GNUC__ == 3)
75 #define AIPS_GCC3
76 #endif
77 
78 /* ONLY USE IF CODE WILL _NOT_ WORK WITH NEWER VERSIONS */
79 #if defined(AIPS_GCC4)
80 #undef AIPS_GCC4
81 #endif
82 #if (defined(AIPS_GCC) && __GNUC__ == 4)
83 #define AIPS_GCC4
84 #endif
85 
86 // Alternate project compiler
87 #if defined(AIPS_SGI)
88 #undef AIPS_SGI
89 #endif
90 #if defined(__sgi)
91 #define AIPS_SGI
92 #if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
93 #define AIPS_64B
94 #define SGI64
95 #endif
96 #endif
97 
98 // Alternate project compiler
99 #if defined(AIPS_SUN_NATIVE)
100 #undef AIPS_SUN_NATIVE
101 #endif
102 #if defined(__SUNPRO_CC)
103 #define AIPS_SUN_NATIVE
104 #endif
105 
106 #if defined(AIPS_SOLARIS)
107 #undef AIPS_SOLARIS
108 #endif
109 #if defined(__sun)
110 #define AIPS_SOLARIS
111 #endif
112 
113 #if defined(AIPS_HP)
114 #undef AIPS_HP
115 #endif
116 #if defined(__hp)
117 #define AIPS_HP
118 #endif
119 
120 #if defined(AIPS_ALPHA)
121 #undef AIPS_ALPHA
122 #endif
123 #if defined(__alpha)
124 #define AIPS_ALPHA
125 #define AIPS_64B
126 #endif
127 
128 #if defined(AIPS_BSD)
129 #undef AIPS_BSD
130 #endif
131 #if defined(__FreeBSD__)
132 #define AIPS_BSD
133 #define AIPS_NOLARGEFILE
134 #endif
135 
136 #if defined(AIPS_LINUX)
137 #undef AIPS_LINUX
138 #endif
139 #if defined(__linux__)
140 #define AIPS_LINUX
141 #endif
142 
143 #if defined(AIPS_KAI)
144 #undef AIPS_KAI
145 #endif
146 #if defined(__kai)
147 #define AIPS_KAI
148 #endif
149 
150 #if defined(AIPS_AIX)
151 #undef AIPS_AIX
152 #endif
153 #if defined(_AIX)
154 #define AIPS_AIX
155 #endif
156 
157 #if defined(AIPS_INTELCC)
158 #undef AIPS_INTELCC
159 #endif
160 #if defined(__INTEL_COMPILER)
161 #define AIPS_INTELCC
162 #endif
163 
164 #if defined(AIPS_CRAY_PGI)
165 #undef AIPS_CRAY_PGI
166 #endif
167 #if defined(__QK_USER__)
168 #define AIPS_CRAY_PGI
169 #if !defined(AIPS_NOLARGEFILE)
170 #define AIPS_NOLARGEFILE
171 #endif
172 #if !defined(AIPS_NO_LEA_MALLOC)
173 #define AIPS_NO_LEA_MALLOC
174 #endif
175 #endif
176 
177 #if defined(AIPS_CRAY_CATAMOUNT)
178 #undef AIPS_CRAY_CATAMOUNT
179 #endif
180 #if defined(__LIB_CATAMOUNT__)
181 #define AIPS_CRAY_CATAMOUNT
182 #endif
183 
184 #if (defined(__ia64) || defined(__x86_64__) || defined(__aarch64__))
185 # if !defined(AIPS_64B)
186 # define AIPS_64B
187 # endif
188 #endif
189 
190 #if defined(AIPS_I386)
191 #undef AIPS_I386
192 #endif
193 #if defined(i386)
194 #define AIPS_I386
195 #endif
196 
197 #if defined(AIPS_DARWIN)
198 #undef AIPS_DARWIN
199 #endif
200 #if defined(__APPLE__)
201 #define AIPS_DARWIN
202 // No need for largefile definition as it is the default under DARWIN
203 #define AIPS_NOLARGEFILE
204  // Don't use AIPS_LITTLE_ENDIAN as this would prevent universal builds
205  // from working. Auto-detect from AIPS_I386 for intel Macs
206 #define AIPS_NO_LEA_MALLOC
207 # if defined(AIPS_LITTLE_ENDIAN)
208 # undef AIPS_LITTLE_ENDIAN
209 # endif
210 #endif
211 
212 // If the compiler specifies endianness, use that
213 #if !(defined(AIPS_LITTLE_ENDIAN))
214 #if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__))
215 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
216 #define AIPS_LITTLE_ENDIAN
217 #endif
218 #else
219 // Automatically configure for known LITTLE ENDIAN systems
220 #if (defined(AIPS_ALPHA) || defined(AIPS_I386) || defined(__x86_64__) || defined(__ARMEL__) || defined(__AARCH64EL__))
221 #define AIPS_LITTLE_ENDIAN
222 #endif
223 #endif
224 #endif
225 
226 
227 // If needed, define the LFS variables (needed in code using cfitsio).
228 #ifndef AIPS_NOLARGEFILE
229 # undef _FILE_OFFSET_BITS
230 # define _FILE_OFFSET_BITS 64
231 # ifndef _LARGEFILE_SOURCE
232 # define _LARGEFILE_SOURCE
233 # endif
234 # ifndef _LARGEFILE64_SOURCE
235 # define _LARGEFILE64_SOURCE
236 # endif
237 #endif
238 
239 
240 // Compiler hints for branch prediction (and code layout).
241 // Use only after profiling performance critical code,
242 // or on checks for exceptional conditions.
243 #if defined __GNUC__ || defined __clang__
244 #define AIPS_LIKELY(x) __builtin_expect(!!(x), 1)
245 #define AIPS_UNLIKELY(x) __builtin_expect(!!(x), 0)
246 #else
247 #define AIPS_LIKELY(x) (x)
248 #define AIPS_UNLIKELY(x) (x)
249 #endif
250 
251 } //# NAMESPACE CASACORE - END
252 #endif