Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:51

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // Copyright (c) Lewis Baker
0003 // Licenced under MIT license. See LICENSE.txt for details.
0004 ///////////////////////////////////////////////////////////////////////////////
0005 #ifndef CPPCORO_CONFIG_HPP_INCLUDED
0006 #define CPPCORO_CONFIG_HPP_INCLUDED
0007 
0008 /////////////////////////////////////////////////////////////////////////////
0009 // Compiler Detection
0010 
0011 #if defined(_MSC_VER)
0012 # define CPPCORO_COMPILER_MSVC _MSC_FULL_VER
0013 #else
0014 # define CPPCORO_COMPILER_MSVC 0
0015 #endif
0016 
0017 #if defined(__clang__)
0018 # define CPPCORO_COMPILER_CLANG (__clang_major__ * 10000 + \
0019                                  __clang_minor__ * 100 + \
0020                                  __clang_patchlevel__)
0021 #else
0022 # define CPPCORO_COMPILER_CLANG 0
0023 #endif
0024 
0025 #if defined(__GNUC__)
0026 # define CPPCORO_COMPILER_GCC (__GNUC__ * 10000 + \
0027                                __GNUC_MINOR__ * 100 + \
0028                                __GNUC_PATCHLEVEL__)
0029 #else
0030 # define CPPCORO_COMPILER_GCC 0
0031 #endif
0032 
0033 /// \def CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER
0034 /// Defined to 1 if the compiler supports returning a coroutine_handle from
0035 /// the await_suspend() method as a way of transferring execution
0036 /// to another coroutine with a guaranteed tail-call.
0037 #if CPPCORO_COMPILER_CLANG
0038 # if __clang_major__ >= 7
0039 #  define CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER 1
0040 # endif
0041 #endif
0042 #ifndef CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER
0043 # define CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER 0
0044 #endif
0045 
0046 #if CPPCORO_COMPILER_MSVC
0047 # define CPPCORO_ASSUME(X) __assume(X)
0048 #else
0049 # define CPPCORO_ASSUME(X)
0050 #endif
0051 
0052 #if CPPCORO_COMPILER_MSVC
0053 # define CPPCORO_NOINLINE __declspec(noinline)
0054 #elif CPPCORO_COMPILER_CLANG || CPPCORO_COMPILER_GCC
0055 # define CPPCORO_NOINLINE __attribute__((noinline))
0056 #else
0057 # define CPPCORO_NOINLINE
0058 #endif
0059 
0060 #if CPPCORO_COMPILER_MSVC
0061 # define CPPCORO_FORCE_INLINE __forceinline
0062 #elif CPPCORO_COMPILER_CLANG
0063 # define CPPCORO_FORCE_INLINE __attribute__((always_inline))
0064 #else
0065 # define CPPCORO_FORCE_INLINE inline
0066 #endif
0067 
0068 /////////////////////////////////////////////////////////////////////////////
0069 // OS Detection
0070 
0071 /// \def CPPCORO_OS_WINNT
0072 /// Defined to non-zero if the target platform is a WindowsNT variant.
0073 /// 0x0500 - Windows 2000
0074 /// 0x0501 - Windows XP/Server 2003
0075 /// 0x0502 - Windows XP SP2/Server 2003 SP1
0076 /// 0x0600 - Windows Vista/Server 2008
0077 /// 0x0601 - Windows 7
0078 /// 0x0602 - Windows 8
0079 /// 0x0603 - Windows 8.1
0080 /// 0x0A00 - Windows 10
0081 #if defined(_WIN32_WINNT) || defined(_WIN32)
0082 # if !defined(_WIN32_WINNT)
0083 // Default to targeting Windows 10 if not defined.
0084 #  define _WIN32_WINNT 0x0A00
0085 # endif
0086 # define CPPCORO_OS_WINNT _WIN32_WINNT
0087 #else
0088 # define CPPCORO_OS_WINNT 0
0089 #endif
0090 
0091 #if defined(__linux__)
0092 # define CPPCORO_OS_LINUX 1
0093 #else
0094 # define CPPCORO_OS_LINUX 0
0095 #endif
0096 
0097 /////////////////////////////////////////////////////////////////////////////
0098 // CPU Detection
0099 
0100 /// \def CPPCORO_CPU_X86
0101 /// Defined to 1 if target CPU is of x86 family.
0102 #if CPPCORO_COMPILER_MSVC
0103 # if defined(_M_IX86)
0104 #  define CPPCORO_CPU_X86 1
0105 # endif
0106 #elif CPPCORO_COMPILER_GCC || CPPCORO_COMPILER_CLANG
0107 # if defined(__i386__)
0108 #  define CPPCORO_CPU_X86 1
0109 # endif
0110 #endif
0111 #if !defined(CPPCORO_CPU_X86)
0112 # define CPPCORO_CPU_X86 0
0113 #endif
0114 
0115 /// \def CPPCORO_CPU_X64
0116 /// Defined to 1 if the target CPU is x64 family.
0117 #if CPPCORO_COMPILER_MSVC
0118 # if defined(_M_X64)
0119 #  define CPPCORO_CPU_X64 1
0120 # endif
0121 #elif CPPCORO_COMPILER_GCC || CPPCORO_COMPILER_CLANG
0122 # if defined(__x86_64__)
0123 #  define CPPCORO_CPU_X64 1
0124 # endif
0125 #endif
0126 #if !defined(CPPCORO_CPU_X64)
0127 # define CPPCORO_CPU_X64 0
0128 #endif
0129 
0130 /// \def CPPCORO_CPU_32BIT
0131 /// Defined if compiling for a 32-bit CPU architecture.
0132 #if CPPCORO_CPU_X86
0133 # define CPPCORO_CPU_32BIT 1
0134 #else
0135 # define CPPCORO_CPU_32BIT 0
0136 #endif
0137 
0138 /// \def CPPCORO_CPU_64BIT
0139 /// Defined if compiling for a 64-bit CPU architecture.
0140 #if CPPCORO_CPU_X64
0141 # define CPPCORO_CPU_64BIT 1
0142 #else
0143 # define CPPCORO_CPU_64BIT 0
0144 #endif
0145 
0146 #if CPPCORO_COMPILER_MSVC
0147 # define CPPCORO_CPU_CACHE_LINE std::hardware_destructive_interference_size
0148 #else
0149 // On most architectures we can assume a 64-byte cache line.
0150 # define CPPCORO_CPU_CACHE_LINE 64
0151 #endif
0152 
0153 #if CPPCORO_COMPILER_MSVC
0154     #if __has_include(<coroutine>)
0155     #include <yvals_core.h>
0156     #ifdef __cpp_lib_coroutine
0157     #define CPPCORO_COROHEADER_FOUND_AND_USABLE
0158     #endif
0159     #endif
0160 #elif CPPCORO_COMPILER_CLANG
0161     # if __clang_major__ >= 14
0162         // clang 14 in c++-17 mode has a non-usable coroutine header
0163         #if __has_include(<coroutine>)
0164         #include <coroutine>
0165         #ifdef __cpp_lib_coroutine
0166         #define CPPCORO_COROHEADER_FOUND_AND_USABLE
0167         #endif
0168         #endif
0169     # else
0170         #if __has_include(<coroutine>)
0171         #define CPPCORO_COROHEADER_FOUND_AND_USABLE
0172         #endif
0173     # endif
0174 #else
0175     #if __has_include(<coroutine>)
0176     #define CPPCORO_COROHEADER_FOUND_AND_USABLE
0177     #endif
0178 #endif
0179 
0180 #endif