1/* Copyright 2009-2016 Francesco Biscani (bluescarni@gmail.com)
2
3This file is part of the Piranha library.
4
5The Piranha library is free software; you can redistribute it and/or modify
6it under the terms of either:
7
8  * the GNU Lesser General Public License as published by the Free
9    Software Foundation; either version 3 of the License, or (at your
10    option) any later version.
11
12or
13
14  * the GNU General Public License as published by the Free Software
15    Foundation; either version 3 of the License, or (at your option) any
16    later version.
17
18or both in parallel, as here.
19
20The Piranha library is distributed in the hope that it will be useful, but
21WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23for more details.
24
25You should have received copies of the GNU General Public License and the
26GNU Lesser General Public License along with the Piranha library.  If not,
27see https://www.gnu.org/licenses/. */
28
29#ifndef PIRANHA_CONFIG_HPP
30#define PIRANHA_CONFIG_HPP
31
32// Start of defines instantiated by CMake.
33// clang-format off
34@PIRANHA_PTHREAD_AFFINITY@
35@PIRANHA_POSIX_MEMALIGN@
36#define PIRANHA_VERSION @piranha_VERSION@
37#define PIRANHA_GIT_REVISION @PIRANHA_GIT_REVISION@
38@PIRANHA_SYSTEM_LOGICAL_PROCESSOR_INFORMATION@
39@PIRANHA_HAVE_UINT128_T@
40@PIRANHA_THREAD_LOCAL@
41@PIRANHA_ENABLE_MSGPACK@
42@PIRANHA_ENABLE_ZLIB@
43@PIRANHA_ENABLE_BZIP2@
44// clang-format on
45// End of defines instantiated by CMake.
46
47// NOTE: testing indicates that the thread_local keyword on MinGW is not currently
48// reliable (i.e., parallel initialization of function-level thread-local statics
49// sometimes leads to heap corruption). Disable it for now.
50#if defined(__MINGW32__) && defined(PIRANHA_HAVE_THREAD_LOCAL)
51#undef PIRANHA_HAVE_THREAD_LOCAL
52#endif
53
54// A handy macro to qualify a variable as static thread-local,
55// but only if the keyword is available (otherwise the variable will not
56// be TLS).
57#if defined(PIRANHA_HAVE_THREAD_LOCAL)
58#define PIRANHA_MAYBE_TLS static thread_local
59#else
60#define PIRANHA_MAYBE_TLS
61#endif
62
63#include <cassert>
64
65#define piranha_assert assert
66
67// NOTE: clang has to go first, as it might define __GNUC__ internally.
68// Same thing could happen with ICC.
69#if defined(__clang__)
70#include "detail/config_clang.hpp"
71#elif defined(__INTEL_COMPILER)
72#include "detail/config_intel.hpp"
73#elif defined(__GNUC__)
74#include "detail/config_gcc.hpp"
75#else
76// NOTE: additional compiler configurations go here or in separate file as above.
77#define likely(x) (x)
78#define unlikely(x) (x)
79#endif
80
81#endif
82