/search.css" rel="stylesheet" type="text/css"/> /search.js">
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
compilerfeatures.h
Go to the documentation of this file.
1 /*
2 Copyright 2010-2011, D. E. Shaw Research.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8 
9 * Redistributions of source code must retain the above copyright
10  notice, this list of conditions, and the following disclaimer.
11 
12 * Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions, and the following disclaimer in the
14  documentation and/or other materials provided with the distribution.
15 
16 * Neither the name of D. E. Shaw Research nor the names of its
17  contributors may be used to endorse or promote products derived from
18  this software without specific prior written permission.
19 
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
191 /*
192 N.B. When something is added to the list of features, it should be
193 added to each of the *features.h files, AND to examples/ut_features.cpp.
194 */
195 
196 /* N.B. most other compilers (icc, nvcc, open64, llvm) will also define __GNUC__, so order matters. */
197 #if defined(__OPENCL_VERSION__) && __OPENCL_VERSION__ > 0
198 #include "openclfeatures.h"
199 #elif defined(__CUDACC__)
200 #include "nvccfeatures.h"
201 #elif defined(__ICC)
202 #include "iccfeatures.h"
203 #elif defined(__xlC__)
204 #include "xlcfeatures.h"
205 #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
206 #include "sunprofeatures.h"
207 #elif defined(__OPEN64__)
208 #include "open64features.h"
209 #elif defined(__clang__)
210 #include "clangfeatures.h"
211 #elif defined(__GNUC__)
212 #include "gccfeatures.h"
213 #elif defined(__PGI)
214 #include "pgccfeatures.h"
215 #elif defined(_MSC_FULL_VER)
216 #include "msvcfeatures.h"
217 #else
218 #error "Can't identify compiler. You'll need to add a new xxfeatures.hpp"
219 { /* maybe an unbalanced brace will terminate the compilation */
220 #endif
221 
222 #ifndef R123_USE_CXX11
223 #define R123_USE_CXX11 (__cplusplus >= 201103L)
224 #endif
225 
226 #ifndef R123_USE_CXX11_UNRESTRICTED_UNIONS
227 #define R123_USE_CXX11_UNRESTRICTED_UNIONS R123_USE_CXX11
228 #endif
229 
230 #ifndef R123_USE_CXX11_STATIC_ASSERT
231 #define R123_USE_CXX11_STATIC_ASSERT R123_USE_CXX11
232 #endif
233 
234 #ifndef R123_USE_CXX11_CONSTEXPR
235 #define R123_USE_CXX11_CONSTEXPR R123_USE_CXX11
236 #endif
237 
238 #ifndef R123_USE_CXX11_EXPLICIT_CONVERSIONS
239 #define R123_USE_CXX11_EXPLICIT_CONVERSIONS R123_USE_CXX11
240 #endif
241 
242 #ifndef R123_USE_CXX11_RANDOM
243 #define R123_USE_CXX11_RANDOM R123_USE_CXX11
244 #endif
245 
246 #ifndef R123_USE_CXX11_TYPE_TRAITS
247 #define R123_USE_CXX11_TYPE_TRAITS R123_USE_CXX11
248 #endif
249 
250 #ifndef R123_USE_CXX11_LONG_LONG
251 #define R123_USE_CXX11_LONG_LONG R123_USE_CXX11
252 #endif
253 
254 #ifndef R123_USE_CXX11_STD_ARRAY
255 #define R123_USE_CXX11_STD_ARRAY R123_USE_CXX11
256 #endif
257 
258 #ifndef R123_USE_MULHILO64_C99
259 #define R123_USE_MULHILO64_C99 0
260 #endif
261 
262 #ifndef R123_USE_MULHILO64_MULHI_INTRIN
263 #define R123_USE_MULHILO64_MULHI_INTRIN 0
264 #endif
265 
266 #ifndef R123_USE_MULHILO32_MULHI_INTRIN
267 #define R123_USE_MULHILO32_MULHI_INTRIN 0
268 #endif
269 
270 #ifndef R123_STATIC_ASSERT
271 #if R123_USE_CXX11_STATIC_ASSERT
272 #define R123_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
273 #else
274  /* if msg always_looked_like_this, we could paste it into the name. Worth it? */
275 #define R123_STATIC_ASSERT(expr, msg) typedef char static_assertion[(!!(expr))*2-1]
276 #endif
277 #endif
278 
279 #ifndef R123_CONSTEXPR
280 #if R123_USE_CXX11_CONSTEXPR
281 #define R123_CONSTEXPR constexpr
282 #else
283 #define R123_CONSTEXPR
284 #endif
285 #endif
286 
287 #ifndef R123_USE_PHILOX_64BIT
288 #define R123_USE_PHILOX_64BIT (R123_USE_MULHILO64_ASM || R123_USE_MULHILO64_MSVC_INTRIN || R123_USE_MULHILO64_CUDA_INTRIN || R123_USE_GNU_UINT128 || R123_USE_MULHILO64_C99 || R123_USE_MULHILO64_OPENCL_INTRIN || R123_USE_MULHILO64_MULHI_INTRIN)
289 #endif
290 
291 #ifndef R123_ULONG_LONG
292 #if defined(__cplusplus) && !R123_USE_CXX11_LONG_LONG
293 /* C++98 doesn't have long long. It doesn't have uint64_t either, but
294  we will have typedef'ed uint64_t to something in the xxxfeatures.h.
295  With luck, it won't elicit complaints from -pedantic. Cross your
296  fingers... */
297 #define R123_ULONG_LONG uint64_t
298 #else
299 #define R123_ULONG_LONG unsigned long long
300 #endif
301 #endif
302 
303 /* UINT64_C should have been #defined by XXXfeatures.h, either by
304  #include <stdint.h> or through compiler-dependent hacks */
305 #ifndef R123_64BIT
306 #define R123_64BIT(x) UINT64_C(x)
307 #endif
308 
309 #ifndef R123_THROW
310 #define R123_THROW(x) throw (x)
311 #endif
312 
313 /*
314  * Windows.h (and perhaps other "well-meaning" code define min and
315  * max, so there's a high chance that our definition of min, max
316  * methods or use of std::numeric_limits min and max will cause
317  * complaints in any program that happened to include Windows.h or
318  * suchlike first. We use the null macro below in our own header
319  * files definition or use of min, max to defensively preclude
320  * this problem. It may not be enough; one might need to #define
321  * NOMINMAX before including Windows.h or compile with -DNOMINMAX.
322  */
323 #define R123_NO_MACRO_SUBST
324