TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
config.hpp
1
2// Copyright (c) Lewis Baker
3// Licenced under MIT license. See LICENSE.txt for details.
5#ifndef CPPCORO_CONFIG_HPP_INCLUDED
6#define CPPCORO_CONFIG_HPP_INCLUDED
7
9// Compiler Detection
10
11#if defined(_MSC_VER)
12# define CPPCORO_COMPILER_MSVC _MSC_FULL_VER
13#else
14# define CPPCORO_COMPILER_MSVC 0
15#endif
16
17#if defined(__clang__)
18# define CPPCORO_COMPILER_CLANG (__clang_major__ * 10000 + \
19 __clang_minor__ * 100 + \
20 __clang_patchlevel__)
21#else
22# define CPPCORO_COMPILER_CLANG 0
23#endif
24
25#if defined(__GNUC__)
26# define CPPCORO_COMPILER_GCC (__GNUC__ * 10000 + \
27 __GNUC_MINOR__ * 100 + \
28 __GNUC_PATCHLEVEL__)
29#else
30# define CPPCORO_COMPILER_GCC 0
31#endif
32
37#if CPPCORO_COMPILER_CLANG
38# if __clang_major__ >= 7
39# define CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER 1
40# endif
41#endif
42#ifndef CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER
43# define CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER 0
44#endif
45
46#if CPPCORO_COMPILER_MSVC
47# define CPPCORO_ASSUME(X) __assume(X)
48#else
49# define CPPCORO_ASSUME(X)
50#endif
51
52#if CPPCORO_COMPILER_MSVC
53# define CPPCORO_NOINLINE __declspec(noinline)
54#elif CPPCORO_COMPILER_CLANG || CPPCORO_COMPILER_GCC
55# define CPPCORO_NOINLINE __attribute__((noinline))
56#else
57# define CPPCORO_NOINLINE
58#endif
59
60#if CPPCORO_COMPILER_MSVC
61# define CPPCORO_FORCE_INLINE __forceinline
62#elif CPPCORO_COMPILER_CLANG
63# define CPPCORO_FORCE_INLINE __attribute__((always_inline))
64#else
65# define CPPCORO_FORCE_INLINE inline
66#endif
67
69// OS Detection
70
81#ifdef __MINGW32__
82#define SCOPEID_UNSPECIFIED_INIT {0}
83#endif
84#if defined(_WIN32_WINNT) || defined(_WIN32)
85# if !defined(_WIN32_WINNT)
86// Default to targeting Windows 10 if not defined.
87# define _WIN32_WINNT 0x0A00
88# endif
89# define CPPCORO_OS_WINNT _WIN32_WINNT
90#else
91# define CPPCORO_OS_WINNT 0
92#endif
93
94#if defined(__linux__)
95# define CPPCORO_OS_LINUX 1
96#else
97# define CPPCORO_OS_LINUX 0
98#endif
99
101// CPU Detection
102
105#if CPPCORO_COMPILER_MSVC
106# if defined(_M_IX86)
107# define CPPCORO_CPU_X86 1
108# endif
109#elif CPPCORO_COMPILER_GCC || CPPCORO_COMPILER_CLANG
110# if defined(__i386__)
111# define CPPCORO_CPU_X86 1
112# endif
113#endif
114#if !defined(CPPCORO_CPU_X86)
115# define CPPCORO_CPU_X86 0
116#endif
117
120#if CPPCORO_COMPILER_MSVC
121# if defined(_M_X64)
122# define CPPCORO_CPU_X64 1
123# endif
124#elif CPPCORO_COMPILER_GCC || CPPCORO_COMPILER_CLANG
125# if defined(__x86_64__)
126# define CPPCORO_CPU_X64 1
127# endif
128#endif
129#if !defined(CPPCORO_CPU_X64)
130# define CPPCORO_CPU_X64 0
131#endif
132
135#if CPPCORO_CPU_X86
136# define CPPCORO_CPU_32BIT 1
137#else
138# define CPPCORO_CPU_32BIT 0
139#endif
140
143#if CPPCORO_CPU_X64
144# define CPPCORO_CPU_64BIT 1
145#else
146# define CPPCORO_CPU_64BIT 0
147#endif
148
149#if CPPCORO_COMPILER_MSVC
150# define CPPCORO_CPU_CACHE_LINE std::hardware_destructive_interference_size
151#else
152// On most architectures we can assume a 64-byte cache line.
153# define CPPCORO_CPU_CACHE_LINE 64
154#endif
155
156#if CPPCORO_COMPILER_MSVC
157 #if __has_include(<coroutine>)
158 #include <yvals_core.h>
159 #ifdef __cpp_lib_coroutine
160 #define CPPCORO_COROHEADER_FOUND_AND_USABLE
161 #endif
162 #endif
163#elif CPPCORO_COMPILER_CLANG
164 # if __clang_major__ >= 14
165 // clang 14 in c++-17 mode has a non-usable coroutine header
166 #if __has_include(<coroutine>)
167 #include <coroutine>
168 #ifdef __cpp_lib_coroutine
169 #define CPPCORO_COROHEADER_FOUND_AND_USABLE
170 #endif
171 #endif
172 # else
173 #if __has_include(<coroutine>)
174 #define CPPCORO_COROHEADER_FOUND_AND_USABLE
175 #endif
176 # endif
177#else
178 #if __has_include(<coroutine>)
179 #define CPPCORO_COROHEADER_FOUND_AND_USABLE
180 #endif
181#endif
182
183#endif