codekingpro/portable-devtools
114k
1// -*- C++ -*-2//===--------------------------- __config ---------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX_CONFIG11#define _LIBCUDACXX_CONFIG12 13#include "__cccl_config"14 15#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)16# pragma GCC system_header17#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)18# pragma clang system_header19#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)20# pragma system_header21#endif // no system header22 23#if defined(__INTEL_LLVM_COMPILER)24# define _LIBCUDACXX_COMPILER_ICC_LLVM25#elif defined(__INTEL_COMPILER)26# define _LIBCUDACXX_COMPILER_ICC27#elif defined(__NVCOMPILER)28# define _LIBCUDACXX_COMPILER_NVHPC29#elif defined(__clang__)30# define _LIBCUDACXX_COMPILER_CLANG31# ifndef __apple_build_version__32# define _LIBCUDACXX_CLANG_VER (__clang_major__ * 100 + __clang_minor__)33# endif34#elif defined(__GNUC__)35# define _LIBCUDACXX_COMPILER_GCC36#elif defined(_MSC_VER)37# define _LIBCUDACXX_COMPILER_MSVC38#elif defined(__IBMCPP__)39# define _LIBCUDACXX_COMPILER_IBM40#elif defined(__CUDACC_RTC__)41# define _LIBCUDACXX_COMPILER_NVRTC42#endif43 44#if defined(_LIBCUDACXX_COMPILER_MSVC)45#if _MSC_VER < 191746#define _LIBCUDACXX_COMPILER_MSVC_201747#elif _MSC_VER < 193048#define _LIBCUDACXX_COMPILER_MSVC_201949#else50#define _LIBCUDACXX_COMPILER_MSVC_202251#endif52#endif // defined(_LIBCUDACXX_COMPILER_MSVC)53 54#if defined(__NVCC__)55// This is not mutually exclusive with other compilers, as NVCC uses a host56// compiler.57# define _LIBCUDACXX_COMPILER_NVCC58#elif defined(_NVHPC_CUDA)59# define _LIBCUDACXX_COMPILER_NVHPC_CUDA60#elif defined(__CUDA__) && defined(_LIBCUDACXX_COMPILER_CLANG)61# define _LIBCUDACXX_COMPILER_CLANG_CUDA62#endif63 64#ifdef __CUDACC__65# define _LIBCUDACXX_CUDACC66# define _LIBCUDACXX_CUDACC_VER_MAJOR __CUDACC_VER_MAJOR__67# define _LIBCUDACXX_CUDACC_VER_MINOR __CUDACC_VER_MINOR__68# define _LIBCUDACXX_CUDACC_VER_BUILD __CUDACC_VER_BUILD__69# define _LIBCUDACXX_CUDACC_VER \70 _LIBCUDACXX_CUDACC_VER_MAJOR * 100000 + _LIBCUDACXX_CUDACC_VER_MINOR * 1000 + \71 _LIBCUDACXX_CUDACC_VER_BUILD72 73// TODO: Determine if this is necessary, I don't know why we automatically include this in <config>74# if defined(__clang__) || defined(__FLT16_MANT_DIG__)75# include <cuda_fp16.h>76# endif77#endif78 79// Some convenience macros to filter CUDACC versions80#if defined(_LIBCUDACXX_CUDACC) && _LIBCUDACXX_CUDACC_VER < 110200081#define _LIBCUDACXX_CUDACC_BELOW_11_282#endif // defined(_LIBCUDACXX_CUDACC) && _LIBCUDACXX_CUDACC_VER < 110200083#if defined(_LIBCUDACXX_CUDACC) && _LIBCUDACXX_CUDACC_VER < 110300084#define _LIBCUDACXX_CUDACC_BELOW_11_385#endif // defined(_LIBCUDACXX_CUDACC) && _LIBCUDACXX_CUDACC_VER < 110300086#if defined(_LIBCUDACXX_CUDACC) && _LIBCUDACXX_CUDACC_VER < 110800087#define _LIBCUDACXX_CUDACC_BELOW_11_888#endif // defined(_LIBCUDACXX_CUDACC) && _LIBCUDACXX_CUDACC_VER < 110800089#if defined(_LIBCUDACXX_CUDACC) && _LIBCUDACXX_CUDACC_VER < 120300090#define _LIBCUDACXX_CUDACC_BELOW_12_391#endif // defined(_LIBCUDACXX_CUDACC) && _LIBCUDACXX_CUDACC_VER < 120300092 93#if defined(_LIBCUDACXX_COMPILER_MSVC)94# define _LIBCUDACXX_HAS_PRAGMA_MSVC_WARNING95# if !defined(_LIBCUDACXX_DISABLE_PRAGMA_MSVC_WARNING)96# define _LIBCUDACXX_USE_PRAGMA_MSVC_WARNING97# endif // !_LIBCUDACXX_DISABLE_PRAGMA_MSVC_WARNING98#endif // _LIBCUDACXX_COMPILER_MSVC99 100#ifdef __cplusplus101 102// __config may be included in `extern "C"` contexts, switch back to include <nv/target>103extern "C++" {104#include <nv/target>105}106 107#ifdef __GNUC__108# define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)109#else110# define _GNUC_VER 0111#endif112 113#define _LIBCUDACXX_VERSION 10000114 115#ifndef _LIBCUDACXX_ABI_VERSION116# define _LIBCUDACXX_ABI_VERSION 1117#endif118 119#ifndef _LIBCUDACXX_STD_VER120# if defined(_MSC_VER)121# if _MSVC_LANG <= 201103L122# define _LIBCUDACXX_STD_VER 11123# elif _MSVC_LANG <= 201402L124# define _LIBCUDACXX_STD_VER 14125# elif _MSVC_LANG <= 201703L126# define _LIBCUDACXX_STD_VER 17127# elif _MSVC_LANG <= 202002L128# define _LIBCUDACXX_STD_VER 20129# else130# define _LIBCUDACXX_STD_VER 23 // current year, or date of c++2b ratification131# endif132# else133# if __cplusplus <= 201103L134# define _LIBCUDACXX_STD_VER 11135# elif __cplusplus <= 201402L136# define _LIBCUDACXX_STD_VER 14137# elif __cplusplus <= 201703L138# define _LIBCUDACXX_STD_VER 17139# elif __cplusplus <= 202002L140# define _LIBCUDACXX_STD_VER 20141# else142# define _LIBCUDACXX_STD_VER 23 // current year, or date of c++2b ratification143# endif144# endif145#endif // _LIBCUDACXX_STD_VER146 147#if _LIBCUDACXX_STD_VER < 11148# error libcu++ requires C++11 or later149#endif150 151#if (defined(_LIBCUDACXX_COMPILER_NVHPC) && defined(__linux__)) \152 || defined(_LIBCUDACXX_COMPILER_NVRTC)153 #define __ELF__154#endif155 156#if defined(__ELF__)157# define _LIBCUDACXX_OBJECT_FORMAT_ELF 1158#elif defined(__MACH__)159# define _LIBCUDACXX_OBJECT_FORMAT_MACHO 1160#elif defined(_WIN32)161# define _LIBCUDACXX_OBJECT_FORMAT_COFF 1162#elif defined(__wasm__)163# define _LIBCUDACXX_OBJECT_FORMAT_WASM 1164#else165# error Unknown object file format166#endif167 168#if defined(_LIBCUDACXX_ABI_UNSTABLE) || _LIBCUDACXX_ABI_VERSION >= 2 || defined(__cuda_std__)169// Change short string representation so that string data starts at offset 0,170// improving its alignment in some cases.171# define _LIBCUDACXX_ABI_ALTERNATE_STRING_LAYOUT172// Fix deque iterator type in order to support incomplete types.173# define _LIBCUDACXX_ABI_INCOMPLETE_TYPES_IN_DEQUE174// Fix undefined behavior in how std::list stores its linked nodes.175# define _LIBCUDACXX_ABI_LIST_REMOVE_NODE_POINTER_UB176// Fix undefined behavior in how __tree stores its end and parent nodes.177# define _LIBCUDACXX_ABI_TREE_REMOVE_NODE_POINTER_UB178// Fix undefined behavior in how __hash_table stores its pointer types.179# define _LIBCUDACXX_ABI_FIX_UNORDERED_NODE_POINTER_UB180# define _LIBCUDACXX_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB181# define _LIBCUDACXX_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE182// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr183// provided under the alternate keyword __nullptr, which changes the mangling184// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.185# define _LIBCUDACXX_ABI_ALWAYS_USE_CXX11_NULLPTR186// Define the `pointer_safety` enum as a C++11 strongly typed enumeration187// instead of as a class simulating an enum. If this option is enabled188// `pointer_safety` and `get_pointer_safety()` will no longer be available189// in C++03.190# define _LIBCUDACXX_ABI_POINTER_SAFETY_ENUM_TYPE191// Define a key function for `bad_function_call` in the library, to centralize192// its vtable and typeinfo to libc++ rather than having all other libraries193// using that class define their own copies.194# define _LIBCUDACXX_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION195// Enable optimized version of __do_get_(un)signed which avoids redundant copies.196# define _LIBCUDACXX_ABI_OPTIMIZED_LOCALE_NUM_GET197// Use the smallest possible integer type to represent the index of the variant.198// Previously libc++ used "unsigned int" exclusively.199# define _LIBCUDACXX_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION200// Unstable attempt to provide a more optimized std::function201# define _LIBCUDACXX_ABI_OPTIMIZED_FUNCTION202// All the regex constants must be distinct and nonzero.203# define _LIBCUDACXX_ABI_REGEX_CONSTANTS_NONZERO204#elif _LIBCUDACXX_ABI_VERSION == 1205# if !defined(_LIBCUDACXX_OBJECT_FORMAT_COFF)206// Enable compiling copies of now inline methods into the dylib to support207// applications compiled against older libraries. This is unnecessary with208// COFF dllexport semantics, since dllexport forces a non-inline definition209// of inline functions to be emitted anyway. Our own non-inline copy would210// conflict with the dllexport-emitted copy, so we disable it.211# define _LIBCUDACXX_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS212# endif213#endif214 215#ifndef __has_attribute216#define __has_attribute(__x) 0217#endif218 219#ifndef __has_builtin220#define __has_builtin(__x) 0221#endif222 223#ifndef __has_extension224#define __has_extension(__x) 0225#endif226 227#ifndef __has_feature228#define __has_feature(__x) 0229#endif230 231#ifndef __has_cpp_attribute232#define __has_cpp_attribute(__x) 0233#endif234 235// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by236// the compiler and '1' otherwise.237#ifndef __is_identifier238#define __is_identifier(__x) 1239#endif240 241#ifndef __has_declspec_attribute242#define __has_declspec_attribute(__x) 0243#endif244 245#define __has_keyword(__x) !(__is_identifier(__x))246 247#ifndef __has_include248#define __has_include(...) 0249#endif250 251#if !defined(_LIBCUDACXX_COMPILER_NVCC) && !defined(_LIBCUDACXX_COMPILER_NVRTC)252// If NVCC is not being used <complex> can safely use `long double` without warnings253# define _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE254// NVCC does not have a way of silencing non '_' prefixed UDLs255# define _LIBCUDACXX_HAS_STL_LITERALS256#endif257 258#if defined(_LIBCUDACXX_COMPILER_GCC) && __cplusplus < 201103L259#error "libc++ does not support using GCC with C++03. Please enable C++11"260#endif261 262// FIXME: ABI detection should be done via compiler builtin macros. This263// is just a placeholder until Clang implements such macros. For now assume264// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,265// and allow the user to explicitly specify the ABI to handle cases where this266// heuristic falls short.267#if defined(_LIBCUDACXX_ABI_FORCE_ITANIUM) && defined(_LIBCUDACXX_ABI_FORCE_MICROSOFT)268# error "Only one of _LIBCUDACXX_ABI_FORCE_ITANIUM and _LIBCUDACXX_ABI_FORCE_MICROSOFT can be defined"269#elif defined(_LIBCUDACXX_ABI_FORCE_ITANIUM)270# define _LIBCUDACXX_ABI_ITANIUM271#elif defined(_LIBCUDACXX_ABI_FORCE_MICROSOFT)272# define _LIBCUDACXX_ABI_MICROSOFT273#else274# if defined(_WIN32) && defined(_LIBCUDACXX_COMPILER_MSVC)275# define _LIBCUDACXX_ABI_MICROSOFT276# else277# define _LIBCUDACXX_ABI_ITANIUM278# endif279#endif280 281#if defined(_LIBCUDACXX_ABI_MICROSOFT) && !defined(_LIBCUDACXX_NO_VCRUNTIME)282# define _LIBCUDACXX_ABI_VCRUNTIME283#endif284 285// Need to detect which libc we're using if we're on Linux.286#if defined(__linux__)287# include <features.h>288# if defined(__GLIBC_PREREQ)289# define _LIBCUDACXX_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)290# else291# define _LIBCUDACXX_GLIBC_PREREQ(a, b) 0292# endif // defined(__GLIBC_PREREQ)293#endif // defined(__linux__)294 295#ifdef __LITTLE_ENDIAN__296# if __LITTLE_ENDIAN__297# define _LIBCUDACXX_LITTLE_ENDIAN298# endif // __LITTLE_ENDIAN__299#endif // __LITTLE_ENDIAN__300 301#ifdef __BIG_ENDIAN__302# if __BIG_ENDIAN__303# define _LIBCUDACXX_BIG_ENDIAN304# endif // __BIG_ENDIAN__305#endif // __BIG_ENDIAN__306 307#ifdef __BYTE_ORDER__308# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__309# define _LIBCUDACXX_LITTLE_ENDIAN310# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__311# define _LIBCUDACXX_BIG_ENDIAN312# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__313#endif // __BYTE_ORDER__314 315#ifdef __FreeBSD__316# include <sys/endian.h>317# if _BYTE_ORDER == _LITTLE_ENDIAN318# define _LIBCUDACXX_LITTLE_ENDIAN319# else // _BYTE_ORDER == _LITTLE_ENDIAN320# define _LIBCUDACXX_BIG_ENDIAN321# endif // _BYTE_ORDER == _LITTLE_ENDIAN322# ifndef __LONG_LONG_SUPPORTED323# define _LIBCUDACXX_HAS_NO_LONG_LONG324# endif // __LONG_LONG_SUPPORTED325#endif // __FreeBSD__326 327#ifdef __NetBSD__328# include <sys/endian.h>329# if _BYTE_ORDER == _LITTLE_ENDIAN330# define _LIBCUDACXX_LITTLE_ENDIAN331# else // _BYTE_ORDER == _LITTLE_ENDIAN332# define _LIBCUDACXX_BIG_ENDIAN333# endif // _BYTE_ORDER == _LITTLE_ENDIAN334# define _LIBCUDACXX_HAS_QUICK_EXIT335#endif // __NetBSD__336 337#if defined(_WIN32)338# define _LIBCUDACXX_WIN32API339# define _LIBCUDACXX_LITTLE_ENDIAN340# define _LIBCUDACXX_SHORT_WCHAR 1341// Both MinGW and native MSVC provide a "MSVC"-like environment342# define _LIBCUDACXX_MSVCRT_LIKE343// If mingw not explicitly detected, assume using MS C runtime only if344// a MS compatibility version is specified.345# if defined(_LIBCUDACXX_COMPILER_MSVC) && !defined(__MINGW32__)346# define _LIBCUDACXX_MSVCRT // Using Microsoft's C Runtime library347# endif348# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))349# define _LIBCUDACXX_HAS_BITSCAN64350# endif351# define _LIBCUDACXX_HAS_OPEN_WITH_WCHAR352# if defined(_LIBCUDACXX_MSVCRT)353# define _LIBCUDACXX_HAS_QUICK_EXIT354# endif355 356// Some CRT APIs are unavailable to store apps357# if defined(WINAPI_FAMILY)358# include <winapifamily.h>359# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \360 (!defined(WINAPI_PARTITION_SYSTEM) || \361 !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))362# define _LIBCUDACXX_WINDOWS_STORE_APP363# endif364# endif365#endif // defined(_WIN32)366 367#ifdef __sun__368# include <sys/isa_defs.h>369# ifdef _LITTLE_ENDIAN370# define _LIBCUDACXX_LITTLE_ENDIAN371# else372# define _LIBCUDACXX_BIG_ENDIAN373# endif374#endif // __sun__375 376#if defined(__CloudABI__)377 // Certain architectures provide arc4random(). Prefer using378 // arc4random() over /dev/{u,}random to make it possible to obtain379 // random data even when using sandboxing mechanisms such as chroots,380 // Capsicum, etc.381# define _LIBCUDACXX_USING_ARC4_RANDOM382#elif defined(__Fuchsia__) || defined(__wasi__)383# define _LIBCUDACXX_USING_GETENTROPY384#elif defined(__native_client__)385 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,386 // including accesses to the special files under /dev. C++11's387 // std::random_device is instead exposed through a NaCl syscall.388# define _LIBCUDACXX_USING_NACL_RANDOM389#elif defined(_LIBCUDACXX_WIN32API)390# define _LIBCUDACXX_USING_WIN32_RANDOM391#else392# define _LIBCUDACXX_USING_DEV_RANDOM393#endif394 395#ifndef _LIBCUDACXX_LITTLE_ENDIAN396#if defined(_LIBCUDACXX_COMPILER_NVRTC)397# define _LIBCUDACXX_LITTLE_ENDIAN398#endif399#endif // _LIBCUDACXX_LITTLE_ENDIAN400 401#if !defined(_LIBCUDACXX_LITTLE_ENDIAN) && !defined(_LIBCUDACXX_BIG_ENDIAN)402# include <endian.h>403# if __BYTE_ORDER == __LITTLE_ENDIAN404# define _LIBCUDACXX_LITTLE_ENDIAN405# elif __BYTE_ORDER == __BIG_ENDIAN406# define _LIBCUDACXX_BIG_ENDIAN407# else // __BYTE_ORDER == __BIG_ENDIAN408# error unable to determine endian409# endif410#endif // !defined(_LIBCUDACXX_LITTLE_ENDIAN) && !defined(_LIBCUDACXX_BIG_ENDIAN)411 412#if __has_attribute(__no_sanitize__) && !defined(_LIBCUDACXX_COMPILER_GCC)413# define _LIBCUDACXX_NO_CFI __attribute__((__no_sanitize__("cfi")))414#else415# define _LIBCUDACXX_NO_CFI416#endif417 418#if (defined(__ISO_C_VISIBLE) && __ISO_C_VISIBLE >= 2011) || __cplusplus >= 201103L419# if defined(__FreeBSD__)420# define _LIBCUDACXX_HAS_QUICK_EXIT421# define _LIBCUDACXX_HAS_C11_FEATURES422# elif defined(__Fuchsia__) || defined(__wasi__)423# define _LIBCUDACXX_HAS_QUICK_EXIT424# define _LIBCUDACXX_HAS_TIMESPEC_GET425# define _LIBCUDACXX_HAS_C11_FEATURES426# elif defined(__linux__)427# if !defined(_LIBCUDACXX_HAS_MUSL_LIBC)428# if _LIBCUDACXX_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)429# define _LIBCUDACXX_HAS_QUICK_EXIT430# endif431# if _LIBCUDACXX_GLIBC_PREREQ(2, 17)432# define _LIBCUDACXX_HAS_C11_FEATURES433# define _LIBCUDACXX_HAS_TIMESPEC_GET434# endif435# else // defined(_LIBCUDACXX_HAS_MUSL_LIBC)436# define _LIBCUDACXX_HAS_QUICK_EXIT437# define _LIBCUDACXX_HAS_TIMESPEC_GET438# define _LIBCUDACXX_HAS_C11_FEATURES439# endif440# endif // __linux__441#endif442 443#if defined(_LIBCUDACXX_COMPILER_NVRTC)444# define __alignof(x) alignof(x)445#endif // _LIBCUDACXX_COMPILER_NVRTC446 447#if defined(_LIBCUDACXX_COMPILER_MSVC)448# define __alignof__ __alignof449#endif450 451#define _LIBCUDACXX_ALIGNOF(_Tp) alignof(_Tp)452#define _LIBCUDACXX_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)453 454#if defined(_LIBCUDACXX_COMPILER_MSVC)455# define _ALIGNAS_TYPE(x) alignas(x)456# define _ALIGNAS(x) __declspec(align(x))457#elif __has_feature(cxx_alignas)458# define _ALIGNAS_TYPE(x) alignas(x)459# define _ALIGNAS(x) alignas(x)460#else461# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCUDACXX_ALIGNOF(x))))462# define _ALIGNAS(x) __attribute__((__aligned__(x)))463#endif // !_LIBCUDACXX_COMPILER_MSVC && !__has_feature(cxx_alignas)464 465// This is wrapped in __CUDA_ARCH__ to prevent error: "ignoring '#pragma unroll'466// [-Werror=unknown-pragmas]"467#if defined(__CUDA_ARCH__)468#if defined(_LIBCUDACXX_COMPILER_MSVC)469# define _LIBCUDACXX_PRAGMA_UNROLL(_N) __pragma(_LIBCUDACXX_TOSTRING(unroll _N))470#else // ^^^ _LIBCUDACXX_COMPILER_MSVC ^^^ / vvv !_LIBCUDACXX_COMPILER_MSVC vvv471# define _LIBCUDACXX_PRAGMA_UNROLL(_N) _Pragma(_LIBCUDACXX_TOSTRING(unroll _N))472#endif // !_LIBCUDACXX_COMPILER_MSVC473#else // ^^^ _LIBCUDACXX_CUDACC ^^^ / vvv !_LIBCUDACXX_CUDACCvvv474# define _LIBCUDACXX_PRAGMA_UNROLL(_N)475#endif // !__CUDA_ARCH__476 477#if defined(_LIBCUDACXX_COMPILER_MSVC)478#define _LIBCUDACXX_ALWAYS_INLINE __forceinline479#else480#define _LIBCUDACXX_ALWAYS_INLINE __attribute__ ((__always_inline__))481#endif // !_LIBCUDACXX_COMPILER_MSVC482 483#if defined(__cuda_std__)484#define _LIBCUDACXX_ATOMIC_ALWAYS_LOCK_FREE(size, ptr) (size <= 8)485#elif defined(_LIBCUDACXX_COMPILER_CLANG) || defined(_LIBCUDACXX_COMPILER_GCC)486#define _LIBCUDACXX_ATOMIC_ALWAYS_LOCK_FREE(...) __atomic_always_lock_free(__VA_ARGS__)487#endif // __cuda_std__488 489// https://bugs.llvm.org/show_bug.cgi?id=44517490#define __check_builtin(__x) (__has_builtin(__##__x) || \491 __has_keyword(__##__x) || \492 __has_feature(__x))493 494// We work around old clang versions (before clang-10) not supporting __has_builtin via __check_builtin495// We work around old intel versions (before 2021.3) not supporting __has_builtin via __check_builtin496// We work around old nvhpc versions (before 2022.11) not supporting __has_builtin via __check_builtin497// MSVC needs manual handling, has no real way of checking builtins so all is manual498// GCC needs manual handling, before gcc-10 as that finally supports __has_builtin499 500#if __check_builtin(array_rank)501#define _LIBCUDACXX_ARRAY_RANK(...) __array_rank(__VA_ARGS__)502#endif // __check_builtin(array_rank)503 504// nvhpc has a bug where it supports __builtin_addressof but does not mark it via __check_builtin505#if __check_builtin(builtin_addressof) \506 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 700) \507 || defined(_LIBCUDACXX_COMPILER_MSVC) \508 || defined(_LIBCUDACXX_COMPILER_NVHPC)509#define _LIBCUDACXX_ADDRESSOF(...) __builtin_addressof(__VA_ARGS__)510#endif // __check_builtin(builtin_addressof)511 512#if __check_builtin(builtin_bit_cast) \513 || (defined(_LIBCUDACXX_COMPILER_MSVC) && _MSC_VER > 1925)514#define _LIBCUDACXX_BIT_CAST(...) __builtin_bit_cast(__VA_ARGS__)515#endif // __check_builtin(builtin_bit_cast)516 517#if __check_builtin(builtin_is_constant_evaluated) \518 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 900) \519 || (defined(_LIBCUDACXX_COMPILER_MSVC) && _MSC_VER > 1924 && !defined(_LIBCUDACXX_CUDACC_BELOW_11_3))520#define _LIBCUDACXX_IS_CONSTANT_EVALUATED(...) __builtin_is_constant_evaluated(__VA_ARGS__)521#endif // __check_builtin(builtin_is_constant_evaluated)522 523// NVCC and NVRTC in C++11 mode freaks out about `__builtin_is_constant_evaluated`.524#if _LIBCUDACXX_STD_VER < 14 \525 && (defined(_LIBCUDACXX_COMPILER_NVCC) \526 || defined(_LIBCUDACXX_COMPILER_NVRTC) \527 || defined(_LIBCUDACXX_COMPILER_NVHPC))528#undef _LIBCUDACXX_IS_CONSTANT_EVALUATED529#endif // _LIBCUDACXX_STD_VER < 14 && defined(_LIBCUDACXX_COMPILER_NVCC)530 531#if __check_builtin(builtin_launder) \532 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 700)533#define _LIBCUDACXX_LAUNDER(...) __builtin_launder(__VA_ARGS__)534#endif // __check_builtin(builtin_launder)535 536// Disabled due to libstdc++ conflict537#if 0 // __check_builtin(decay)538#define _LIBCUDACXX_DECAY(...) __decay(__VA_ARGS__)539#endif // __check_builtin(decay)540 541#if __check_builtin(has_nothrow_assign) \542 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \543 || defined(_LIBCUDACXX_COMPILER_MSVC) \544 || defined(_LIBCUDACXX_COMPILER_NVRTC)545#define _LIBCUDACXX_HAS_NOTHROW_ASSIGN(...) __has_nothrow_assign(__VA_ARGS__)546#endif // __check_builtin(has_nothrow_assign)547 548#if __check_builtin(has_nothrow_constructor) \549 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \550 || defined(_LIBCUDACXX_COMPILER_MSVC) \551 || defined(_LIBCUDACXX_COMPILER_NVRTC)552#define _LIBCUDACXX_HAS_NOTHROW_CONSTRUCTOR(...) __has_nothrow_constructor(__VA_ARGS__)553#endif // __check_builtin(has_nothrow_constructor)554 555#if __check_builtin(has_nothrow_copy) \556 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \557 || defined(_LIBCUDACXX_COMPILER_MSVC) \558 || defined(_LIBCUDACXX_COMPILER_NVRTC)559#define _LIBCUDACXX_HAS_NOTHROW_COPY(...) __has_nothrow_copy(__VA_ARGS__)560#endif // __check_builtin(has_nothrow_copy)561 562#if __check_builtin(has_trivial_constructor) \563 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \564 || defined(_LIBCUDACXX_COMPILER_MSVC) \565 || defined(_LIBCUDACXX_COMPILER_NVRTC)566#define _LIBCUDACXX_HAS_TRIVIAL_CONSTRUCTOR(...) __has_trivial_constructor(__VA_ARGS__)567#endif // __check_builtin(has_trivial_constructor)568 569#if __check_builtin(has_trivial_destructor) \570 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \571 || defined(_LIBCUDACXX_COMPILER_MSVC) \572 || defined(_LIBCUDACXX_COMPILER_NVRTC)573#define _LIBCUDACXX_HAS_TRIVIAL_DESTRUCTOR(...) __has_trivial_destructor(__VA_ARGS__)574#endif // __check_builtin(has_trivial_destructor)575 576#if __check_builtin(has_unique_object_representations) \577 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 700)578#define _LIBCUDACXX_HAS_UNIQUE_OBJECT_REPRESENTATIONS(...) __has_unique_object_representations(__VA_ARGS__)579#endif // __check_builtin(has_unique_object_representations)580 581#if __check_builtin(has_virtual_destructor) \582 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \583 || defined(_LIBCUDACXX_COMPILER_MSVC) \584 || defined(_LIBCUDACXX_COMPILER_NVRTC)585#define _LIBCUDACXX_HAS_VIRTUAL_DESTRUCTOR(...) __has_virtual_destructor(__VA_ARGS__)586#endif // __check_builtin(has_virtual_destructor)587 588#if __check_builtin(is_aggregate) \589 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 700) \590 || (defined(_LIBCUDACXX_COMPILER_MSVC) && _MSC_VER > 1914) \591 || defined(_LIBCUDACXX_COMPILER_NVRTC)592#define _LIBCUDACXX_IS_AGGREGATE(...) __is_aggregate(__VA_ARGS__)593#endif // __check_builtin(is_aggregate)594 595#if __check_builtin(is_array)596#define _LIBCUDACXX_IS_ARRAY(...) __is_array(__VA_ARGS__)597#endif // __check_builtin(is_array)598 599// TODO: Clang incorrectly reports that __is_array is true for T[0].600// Re-enable the branch once https://llvm.org/PR54705 is fixed.601#ifndef _LIBCUDACXX_USE_IS_ARRAY_FALLBACK602#if defined(_LIBCUDACXX_COMPILER_CLANG)603#define _LIBCUDACXX_USE_IS_ARRAY_FALLBACK604#endif // _LIBCUDACXX_COMPILER_CLANG605#endif // !_LIBCUDACXX_USE_IS_ARRAY_FALLBACK606 607#if __check_builtin(is_assignable) \608 || defined(_LIBCUDACXX_COMPILER_MSVC)609#define _LIBCUDACXX_IS_ASSIGNABLE(...) __is_assignable(__VA_ARGS__)610#endif // __check_builtin(is_assignable)611 612#if __check_builtin(is_base_of) \613 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \614 || defined(_LIBCUDACXX_COMPILER_MSVC) \615 || defined(_LIBCUDACXX_COMPILER_NVRTC)616#define _LIBCUDACXX_IS_BASE_OF(...) __is_base_of(__VA_ARGS__)617#endif // __check_builtin(is_base_of)618 619#if __check_builtin(is_class) \620 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \621 || defined(_LIBCUDACXX_COMPILER_MSVC) \622 || defined(_LIBCUDACXX_COMPILER_NVRTC)623#define _LIBCUDACXX_IS_CLASS(...) __is_class(__VA_ARGS__)624#endif // __check_builtin(is_class)625 626#if __check_builtin(is_constructible) \627 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 800) \628 || defined(_LIBCUDACXX_COMPILER_MSVC) \629 || defined(_LIBCUDACXX_COMPILER_NVRTC)630#define _LIBCUDACXX_IS_CONSTRUCTIBLE(...) __is_constructible(__VA_ARGS__)631#endif // __check_builtin(is_constructible)632 633#if __check_builtin(is_convertible_to) \634 || defined(_LIBCUDACXX_COMPILER_MSVC) \635 || defined(_LIBCUDACXX_COMPILER_NVRTC)636#define _LIBCUDACXX_IS_CONVERTIBLE_TO(...) __is_convertible_to(__VA_ARGS__)637#endif // __check_builtin(is_convertible_to)638 639#if __check_builtin(is_destructible) \640 || defined(_LIBCUDACXX_COMPILER_MSVC)641#define _LIBCUDACXX_IS_DESTRUCTIBLE(...) __is_destructible(__VA_ARGS__)642#endif // __check_builtin(is_destructible)643 644#if __check_builtin(is_empty) \645 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \646 || defined(_LIBCUDACXX_COMPILER_MSVC) \647 || defined(_LIBCUDACXX_COMPILER_NVRTC)648#define _LIBCUDACXX_IS_EMPTY(...) __is_empty(__VA_ARGS__)649#endif // __check_builtin(is_empty)650 651#if __check_builtin(is_enum) \652 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \653 || defined(_LIBCUDACXX_COMPILER_MSVC) \654 || defined(_LIBCUDACXX_COMPILER_NVRTC)655#define _LIBCUDACXX_IS_ENUM(...) __is_enum(__VA_ARGS__)656#endif // __check_builtin(is_enum)657 658#if __check_builtin(is_final) \659 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 407) \660 || defined(_LIBCUDACXX_COMPILER_MSVC) \661 || defined(_LIBCUDACXX_COMPILER_NVRTC)662#define _LIBCUDACXX_IS_FINAL(...) __is_final(__VA_ARGS__)663#endif // __check_builtin(is_final)664 665#if __check_builtin(is_function) \666 && !defined(_LIBCUDACXX_COMPILER_NVCC)667#define _LIBCUDACXX_IS_FUNCTION(...) __is_function(__VA_ARGS__)668#endif // __check_builtin(is_function)669 670#if __check_builtin(is_literal_type) \671 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 406) \672 || defined(_LIBCUDACXX_COMPILER_MSVC) \673 || defined(_LIBCUDACXX_COMPILER_NVRTC)674#define _LIBCUDACXX_IS_LITERAL(...) __is_literal_type(__VA_ARGS__)675#endif // __check_builtin(is_literal_type)676 677#if __check_builtin(is_lvalue_reference)678#define _LIBCUDACXX_IS_LVALUE_REFERENCE(...) __is_lvalue_reference(__VA_ARGS__)679#endif // __check_builtin(is_lvalue_reference)680 681#ifndef _LIBCUDACXX_USE_IS_LVALUE_REFERENCE_FALLBACK682#if defined(_LIBCUDACXX_CUDACC_BELOW_11_3)683#define _LIBCUDACXX_USE_IS_LVALUE_REFERENCE_FALLBACK684#endif // nvcc < 11.3685#endif // !_LIBCUDACXX_USE_IS_LVALUE_REFERENCE_FALLBACK686 687#if __check_builtin(is_nothrow_assignable) \688 || defined(_LIBCUDACXX_COMPILER_MSVC) \689 || defined(_LIBCUDACXX_COMPILER_NVRTC)690#define _LIBCUDACXX_IS_NOTHROW_ASSIGNABLE(...) __is_nothrow_assignable(__VA_ARGS__)691#endif // __check_builtin(is_nothrow_assignable)692 693#if __check_builtin(is_nothrow_constructible) \694 || defined(_LIBCUDACXX_COMPILER_MSVC) \695 || defined(_LIBCUDACXX_COMPILER_NVRTC)696#define _LIBCUDACXX_IS_NOTHROW_CONSTRUCTIBLE(...) __is_nothrow_constructible(__VA_ARGS__)697#endif // __check_builtin(is_nothrow_constructible)698 699#if __check_builtin(is_nothrow_destructible) \700 || defined(_LIBCUDACXX_COMPILER_MSVC) \701 || defined(_LIBCUDACXX_COMPILER_NVRTC)702#define _LIBCUDACXX_IS_NOTHROW_DESTRUCTIBLE(...) __is_nothrow_destructible(__VA_ARGS__)703#endif // __check_builtin(is_nothrow_destructible)704 705#if __check_builtin(is_object)706#define _LIBCUDACXX_IS_OBJECT(...) __is_object(__VA_ARGS__)707#endif // __check_builtin(is_object)708 709#ifndef _LIBCUDACXX_USE_IS_OBJECT_FALLBACK710#if defined(_LIBCUDACXX_CUDACC_BELOW_11_3)711#define _LIBCUDACXX_USE_IS_OBJECT_FALLBACK712#endif // nvcc < 11.3713#endif // !_LIBCUDACXX_USE_IS_OBJECT_FALLBACK714 715#if __check_builtin(is_pod) \716 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \717 || defined(_LIBCUDACXX_COMPILER_MSVC) \718 || defined(_LIBCUDACXX_COMPILER_NVRTC)719#define _LIBCUDACXX_IS_POD(...) __is_pod(__VA_ARGS__)720#endif // __check_builtin(is_pod)721 722// libstdc++ defines this as a function, breaking functionality723#if 0 // __check_builtin(is_pointer)724#define _LIBCUDACXX_IS_POINTER(...) __is_pointer(__VA_ARGS__)725#endif // __check_builtin(is_pointer)726 727#if __check_builtin(is_polymorphic) \728 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \729 || defined(_LIBCUDACXX_COMPILER_MSVC) \730 || defined(_LIBCUDACXX_COMPILER_NVRTC)731#define _LIBCUDACXX_IS_POLYMORPHIC(...) __is_polymorphic(__VA_ARGS__)732#endif // __check_builtin(is_polymorphic)733 734#if __check_builtin(is_reference)735#define _LIBCUDACXX_IS_REFERENCE(...) __is_reference(__VA_ARGS__)736#endif // __check_builtin(is_reference)737 738// Disabled due to libstdc++ conflict739#if 0 // __check_builtin(is_referenceable)740#define _LIBCUDACXX_IS_REFERENCEABLE(...) __is_referenceable(__VA_ARGS__)741#endif // __check_builtin(is_referenceable)742 743#if __check_builtin(is_rvalue_reference)744#define _LIBCUDACXX_IS_RVALUE_REFERENCE(...) __is_rvalue_reference(__VA_ARGS__)745#endif // __check_builtin(is_rvalue_reference)746 747#if __check_builtin(is_same) \748 && !defined(_LIBCUDACXX_COMPILER_NVCC)749#define _LIBCUDACXX_IS_SAME(...) __is_same(__VA_ARGS__)750#endif // __check_builtin(is_same)751 752// libstdc++ defines this as a function, breaking functionality753#if 0 // __check_builtin(is_scalar)754#define _LIBCUDACXX_IS_SCALAR(...) __is_scalar(__VA_ARGS__)755#endif // __check_builtin(is_scalar)756 757// libstdc++ defines this as a function, breaking functionality758#if 0 // __check_builtin(is_signed)759#define _LIBCUDACXX_IS_SIGNED(...) __is_signed(__VA_ARGS__)760#endif // __check_builtin(is_signed)761 762#if __check_builtin(is_standard_layout) \763 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 407) \764 || defined(_LIBCUDACXX_COMPILER_MSVC) \765 || defined(_LIBCUDACXX_COMPILER_NVRTC)766#define _LIBCUDACXX_IS_STANDARD_LAYOUT(...) __is_standard_layout(__VA_ARGS__)767#endif // __check_builtin(is_standard_layout)768 769#if __check_builtin(is_trivial) \770 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 405) \771 || defined(_LIBCUDACXX_COMPILER_MSVC) \772 || defined(_LIBCUDACXX_COMPILER_NVRTC)773#define _LIBCUDACXX_IS_TRIVIAL(...) __is_trivial(__VA_ARGS__)774#endif // __check_builtin(is_trivial)775 776#if __check_builtin(is_trivially_assignable) \777 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 501) \778 || defined(_LIBCUDACXX_COMPILER_MSVC) \779 || defined(_LIBCUDACXX_COMPILER_NVRTC)780#define _LIBCUDACXX_IS_TRIVIALLY_ASSIGNABLE(...) __is_trivially_assignable(__VA_ARGS__)781#endif // __check_builtin(is_trivially_assignable)782 783#if __check_builtin(is_trivially_constructible) \784 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 501) \785 || defined(_LIBCUDACXX_COMPILER_MSVC) \786 || defined(_LIBCUDACXX_COMPILER_NVRTC)787#define _LIBCUDACXX_IS_TRIVIALLY_CONSTRUCTIBLE(...) __is_trivially_constructible(__VA_ARGS__)788#endif // __check_builtin(is_trivially_constructible)789 790#if __check_builtin(is_trivially_copyable) \791 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 501) \792 || defined(_LIBCUDACXX_COMPILER_MSVC) \793 || defined(_LIBCUDACXX_COMPILER_NVRTC)794#define _LIBCUDACXX_IS_TRIVIALLY_COPYABLE(...) __is_trivially_copyable(__VA_ARGS__)795#endif // __check_builtin(is_trivially_copyable)796 797#if __check_builtin(is_trivially_destructible) \798 || defined(_LIBCUDACXX_COMPILER_MSVC)799#define _LIBCUDACXX_IS_TRIVIALLY_DESTRUCTIBLE(...) __is_trivially_destructible(__VA_ARGS__)800#endif // __check_builtin(is_trivially_destructible)801 802#if __check_builtin(is_union) \803 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 403) \804 || defined(_LIBCUDACXX_COMPILER_MSVC) \805 || defined(_LIBCUDACXX_COMPILER_NVRTC)806#define _LIBCUDACXX_IS_UNION(...) __is_union(__VA_ARGS__)807#endif // __check_builtin(is_union)808 809#if __check_builtin(is_unsigned)810#define _LIBCUDACXX_IS_UNSIGNED(...) __is_unsigned(__VA_ARGS__)811#endif // __check_builtin(is_unsigned)812 813#ifndef _LIBCUDACXX_USE_IS_UNSIGNED_FALLBACK814#if defined(_LIBCUDACXX_CUDACC_BELOW_11_3)815#define _LIBCUDACXX_USE_IS_UNSIGNED_FALLBACK816#endif // nvcc < 11.3817#endif // !_LIBCUDACXX_USE_IS_UNSIGNED_FALLBACK818 819// libstdc++ defines this as a function, breaking functionality820#if 0 // __check_builtin(is_void)821#define _LIBCUDACXX_IS_VOID(...) __is_void(__VA_ARGS__)822#endif // __check_builtin(is_void)823 824// Disabled due to libstdc++ conflict825#if 0 // __check_builtin(make_signed)826#define _LIBCUDACXX_MAKE_SIGNED(...) __make_signed(__VA_ARGS__)827#endif // __check_builtin(make_signed)828 829// Disabled due to libstdc++ conflict830#if 0 // __check_builtin(make_unsigned)831#define _LIBCUDACXX_MAKE_UNSIGNED(...) __make_unsigned(__VA_ARGS__)832#endif // __check_builtin(make_unsigned)833 834// Disabled due to libstdc++ conflict835#if 0 // __check_builtin(remove_all_extents)836#define _LIBCUDACXX_REMOVE_ALL_EXTENTS(...) __remove_all_extents(__VA_ARGS__)837#endif // __check_builtin(remove_all_extents)838 839// Disabled due to libstdc++ conflict840#if 0 // __check_builtin(remove_const)841#define _LIBCUDACXX_REMOVE_CONST(...) __remove_const(__VA_ARGS__)842#endif // __check_builtin(remove_const)843 844// Disabled due to libstdc++ conflict845#if 0 // __check_builtin(remove_cv)846#define _LIBCUDACXX_REMOVE_CV(...) __remove_cv(__VA_ARGS__)847#endif // __check_builtin(remove_cv)848 849// Disabled due to libstdc++ conflict850#if 0 // __check_builtin(remove_cvref)851#define _LIBCUDACXX_REMOVE_CVREF(...) __remove_cvref(__VA_ARGS__)852#endif // __check_builtin(remove_cvref)853 854// Disabled due to libstdc++ conflict855#if 0 // __check_builtin(remove_extent)856#define _LIBCUDACXX_REMOVE_EXTENT(...) __remove_extent(__VA_ARGS__)857#endif // __check_builtin(remove_extent)858 859// Disabled due to libstdc++ conflict860#if 0 // __check_builtin(remove_pointer)861#define _LIBCUDACXX_REMOVE_POINTER(...) __remove_pointer(__VA_ARGS__)862#endif // __check_builtin(remove_pointer)863 864// Disabled due to libstdc++ conflict865#if 0 // __check_builtin(remove_reference_t)866#define _LIBCUDACXX_REMOVE_REFERENCE_T(...) __remove_reference_t(__VA_ARGS__)867#endif // __check_builtin(remove_reference_t)868 869// Disabled due to libstdc++ conflict870#if 0 // __check_builtin(remove_volatile)871#define _LIBCUDACXX_REMOVE_VOLATILE(...) __remove_volatile(__VA_ARGS__)872#endif // __check_builtin(remove_volatile)873 874#if __check_builtin(underlying_type) \875 || (defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER >= 407) \876 || defined(_LIBCUDACXX_COMPILER_MSVC) \877 || defined(_LIBCUDACXX_COMPILER_NVRTC)878#define _LIBCUDACXX_UNDERLYING_TYPE(...) __underlying_type(__VA_ARGS__)879#endif // __check_builtin(underlying_type)880 881#define _LIBCUDACXX_TOSTRING2(_STR) #_STR882#define _LIBCUDACXX_TOSTRING(_STR) _LIBCUDACXX_TOSTRING2(_STR)883#if defined(_LIBCUDACXX_CUDACC) && !defined(_LIBCUDACXX_COMPILER_CLANG_CUDA)884# if defined(__NVCC_DIAG_PRAGMA_SUPPORT__)885# if defined(_LIBCUDACXX_COMPILER_MSVC)886# define _LIBCUDACXX_NV_DIAG_SUPPRESS(_WARNING) __pragma(_LIBCUDACXX_TOSTRING(nv_diag_suppress _WARNING))887# define _LIBCUDACXX_NV_DIAG_DEFAULT(_WARNING) __pragma(_LIBCUDACXX_TOSTRING(nv_diag_default _WARNING))888# else // ^^^ MSVC ^^^ / vvv not MSVC889# define _LIBCUDACXX_NV_DIAG_SUPPRESS(_WARNING) \890 _Pragma(_LIBCUDACXX_TOSTRING(nv_diagnostic push)) \891 _Pragma(_LIBCUDACXX_TOSTRING(nv_diag_suppress _WARNING))892# define _LIBCUDACXX_NV_DIAG_DEFAULT(_WARNING) _Pragma(_LIBCUDACXX_TOSTRING(nv_diagnostic pop))893# endif // not MSVC894# elif defined(_LIBCUDACXX_COMPILER_NVHPC)895# define _LIBCUDACXX_NV_DIAG_SUPPRESS(_WARNING) \896 _Pragma(_LIBCUDACXX_TOSTRING(diagnostic push)) \897 _Pragma(_LIBCUDACXX_TOSTRING(diag_suppress _WARNING))898# define _LIBCUDACXX_NV_DIAG_DEFAULT(_WARNING) _Pragma(_LIBCUDACXX_TOSTRING(diagnostic pop))899# else // _LIBCUDACXX_CUDACC_BELOW_11_3900# if defined(_LIBCUDACXX_COMPILER_MSVC_2017) // MSVC 2017 has issues with restoring the warning901# define _LIBCUDACXX_NV_DIAG_SUPPRESS(_WARNING) __pragma(_LIBCUDACXX_TOSTRING(diag_suppress _WARNING))902# define _LIBCUDACXX_NV_DIAG_DEFAULT(_WARNING)903# elif defined(_LIBCUDACXX_COMPILER_MSVC)904# define _LIBCUDACXX_NV_DIAG_SUPPRESS(_WARNING) __pragma(_LIBCUDACXX_TOSTRING(diag_suppress _WARNING))905# define _LIBCUDACXX_NV_DIAG_DEFAULT(_WARNING) __pragma(_LIBCUDACXX_TOSTRING(diag_default _WARNING))906# else // ^^^ MSVC ^^^ / vvv not MSVC907# define _LIBCUDACXX_NV_DIAG_SUPPRESS(_WARNING) _Pragma(_LIBCUDACXX_TOSTRING(diag_suppress _WARNING))908# define _LIBCUDACXX_NV_DIAG_DEFAULT(_WARNING) _Pragma(_LIBCUDACXX_TOSTRING(diag_default _WARNING))909# endif // not MSVC910# endif // !__NVCC_DIAG_PRAGMA_SUPPORT__911#else // ^^^ _LIBCUDACXX_CUDACC ^^^ / vvv other compiler vvv912# define _LIBCUDACXX_NV_DIAG_SUPPRESS(_WARNING)913# define _LIBCUDACXX_NV_DIAG_DEFAULT(_WARNING)914#endif // other compilers915 916#if defined(_LIBCUDACXX_COMPILER_CLANG)917 918// _LIBCUDACXX_ALTERNATE_STRING_LAYOUT is an old name for919// _LIBCUDACXX_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.920#if defined(_LIBCUDACXX_ALTERNATE_STRING_LAYOUT)921#define _LIBCUDACXX_ABI_ALTERNATE_STRING_LAYOUT922#endif923 924#if __cplusplus < 201103L925typedef __char16_t char16_t;926typedef __char32_t char32_t;927#endif928 929#if !(__has_feature(cxx_strong_enums))930#define _LIBCUDACXX_HAS_NO_STRONG_ENUMS931#endif932 933#if !(__has_feature(cxx_lambdas))934#define _LIBCUDACXX_HAS_NO_LAMBDAS935#endif936 937#if !(__has_feature(cxx_nullptr))938# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCUDACXX_ABI_ALWAYS_USE_CXX11_NULLPTR)939# define nullptr __nullptr940# else941# define _LIBCUDACXX_HAS_NO_NULLPTR942# endif943#endif944 945#if !(__has_feature(cxx_rvalue_references))946#define _LIBCUDACXX_HAS_NO_RVALUE_REFERENCES947#endif948 949#if !(__has_feature(cxx_auto_type))950#define _LIBCUDACXX_HAS_NO_AUTO_TYPE951#endif952 953#if !(__has_feature(cxx_variadic_templates))954#define _LIBCUDACXX_HAS_NO_VARIADICS955#endif956 957#if !(__has_feature(cxx_generalized_initializers))958#define _LIBCUDACXX_HAS_NO_GENERALIZED_INITIALIZERS959#endif960 961// Objective-C++ features (opt-in)962#if __has_feature(objc_arc)963#define _LIBCUDACXX_HAS_OBJC_ARC964#endif965 966#if __has_feature(objc_arc_weak)967#define _LIBCUDACXX_HAS_OBJC_ARC_WEAK968#endif969 970#if !(__has_feature(cxx_relaxed_constexpr))971#define _LIBCUDACXX_HAS_NO_CXX14_CONSTEXPR972#endif973 974#if !(__has_feature(cxx_variable_templates))975#define _LIBCUDACXX_HAS_NO_VARIABLE_TEMPLATES976#endif977 978#if !(__has_feature(cxx_noexcept))979#define _LIBCUDACXX_HAS_NO_NOEXCEPT980#endif981 982// Allow for build-time disabling of unsigned integer sanitization983#if !defined(_LIBCUDACXX_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)984#define _LIBCUDACXX_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))985#endif986 987#define _LIBCUDACXX_DISABLE_EXTENSION_WARNING __extension__988 989#elif defined(_LIBCUDACXX_COMPILER_GCC)990 991#ifndef _LIBCUDACXX_USE_IS_ASSIGNABLE_FALLBACK992// FIXME: GCC 8.0 supports this trait, but it has a bug.993// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91592994// https://godbolt.org/z/IljfIw995#define _LIBCUDACXX_USE_IS_ASSIGNABLE_FALLBACK996#endif // _LIBCUDACXX_USE_IS_ASSIGNABLE_FALLBACK997 998// Determine if GCC supports relaxed constexpr999#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L1000#define _LIBCUDACXX_HAS_NO_CXX14_CONSTEXPR1001#endif1002 1003// GCC 5 supports variable templates1004#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L1005#define _LIBCUDACXX_HAS_NO_VARIABLE_TEMPLATES1006#endif1007 1008#if _GNUC_VER < 6001009#define _LIBCUDACXX_GCC_MATH_IN_STD1010#endif1011 1012// NVCC cannot properly handle some deductions occuring within NOEXCEPT1013// C++17 mode causes reference instatiation errors in tuple1014#if (_GNUC_VER >= 702 && _GNUC_VER <= 805)1015#if defined(_LIBCUDACXX_COMPILER_NVCC) && _LIBCUDACXX_STD_VER == 171016#define _LIBCUDACXX_NO_TUPLE_NOEXCEPT1017#endif1018#endif1019 1020#define _LIBCUDACXX_DISABLE_EXTENSION_WARNING __extension__1021 1022#elif defined(_LIBCUDACXX_COMPILER_MSVC)1023 1024#define _LIBCUDACXX_WARNING(x) __pragma(message(__FILE__ "(" _LIBCUDACXX_TOSTRING(__LINE__) ") : warning note: " x))1025 1026// https://github.com/microsoft/STL/blob/master/stl/inc/yvals_core.h#L3531027// warning C4100: 'quack': unreferenced formal parameter1028// warning C4127: conditional expression is constant1029// warning C4180: qualifier applied to function type has no meaning; ignored1030// warning C4197: 'purr': top-level volatile in cast is ignored1031// warning C4324: 'roar': structure was padded due to alignment specifier1032// warning C4455: literal suffix identifiers that do not start with an underscore are reserved1033// warning C4503: 'hum': decorated name length exceeded, name was truncated1034// warning C4522: 'woof' : multiple assignment operators specified1035// warning C4668: 'meow' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'1036// warning C4800: 'boo': forcing value to bool 'true' or 'false' (performance warning)1037// warning C4996: 'meow': was declared deprecated1038#define _LIBCUDACXX_MSVC_DISABLED_WARNINGS \1039 4100 \1040 4127 \1041 4180 \1042 4197 \1043 4296 \1044 4324 \1045 4455 \1046 4503 \1047 4522 \1048 4668 \1049 4800 \1050 4996 \1051 /**/1052 1053#if _MSC_VER < 19001054#error "MSVC versions prior to Visual Studio 2015 are not supported"1055#endif1056 1057// MSVC implemented P0030R1 in 15.7, only available under C++171058#if _MSC_VER < 19141059#define _LIBCUDACXX_NO_HOST_CPP17_HYPOT1060#endif1061 1062#if _MSC_VER < 19201063#define _LIBCUDACXX_HAS_NO_NOEXCEPT_SFINAE1064#define _LIBCUDACXX_HAS_NO_LOGICAL_METAFUNCTION_ALIASES1065#endif1066 1067// MSVC exposed __iso_volatile intrinsics beginning on 1924 for x861068#if _MSC_VER < 19241069 #define _LIBCUDACXX_MSVC_HAS_NO_ISO_INTRIN1070#endif1071 1072#if _LIBCUDACXX_STD_VER < 141073#define _LIBCUDACXX_HAS_NO_CXX14_CONSTEXPR1074#define _LIBCUDACXX_HAS_NO_VARIABLE_TEMPLATES1075#endif1076 1077#define _LIBCUDACXX_WEAK1078 1079#define _LIBCUDACXX_HAS_NO_VECTOR_EXTENSION1080 1081#define _LIBCUDACXX_DISABLE_EXTENSION_WARNING1082 1083#elif defined(_LIBCUDACXX_COMPILER_IBM)1084 1085#define _ATTRIBUTE(x) __attribute__((x))1086 1087#define _LIBCUDACXX_HAS_NO_UNICODE_CHARS1088#define _LIBCUDACXX_HAS_NO_VARIABLE_TEMPLATES1089 1090#if defined(_AIX)1091#define __MULTILOCALE_API1092#endif1093 1094#define _LIBCUDACXX_HAS_NO_VECTOR_EXTENSION1095 1096#elif defined(_LIBCUDACXX_COMPILER_NVRTC) || defined(_LIBCUDACXX_COMPILER_NVHPC)1097 1098#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L1099#define _LIBCUDACXX_HAS_NO_CXX14_CONSTEXPR1100#endif1101 1102#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L1103#define _LIBCUDACXX_HAS_NO_VARIABLE_TEMPLATES1104#endif1105 1106#define _LIBCUDACXX_DISABLE_EXTENSION_WARNING1107 1108#endif // _LIBCUDACXX_COMPILER_[CLANG|GCC|MSVC|IBM|NVRTC]1109 1110#if defined(_LIBCUDACXX_COMPILER_NVHPC) && !defined(__cuda_std__)1111// Forcefully disable visibility controls when used as the standard library with NVC++.1112// TODO: reevaluate.1113#define _LIBCUDACXX_HIDE_FROM_ABI1114#ifndef _LIBCUDACXX_DISABLE_EXTERN_TEMPLATE1115#define _LIBCUDACXX_DISABLE_EXTERN_TEMPLATE1116#endif1117#endif1118 1119#ifndef _LIBCUDACXX_FREESTANDING1120#if defined(__cuda_std__) \1121 || !defined(__STDC_HOSTED__)1122# define _LIBCUDACXX_FREESTANDING1123#endif1124#endif // !_LIBCUDACXX_FREESTANDING1125 1126#ifndef _LIBCUDACXX_DISABLE_VISIBILITY_ANNOTATIONS1127#if defined(_LIBCUDACXX_COMPILER_NVRTC) \1128 || (defined(_LIBCUDACXX_COMPILER_NVHPC) && !defined(__cuda_std__))1129# define _LIBCUDACXX_DISABLE_VISIBILITY_ANNOTATIONS1130#endif1131#endif // _LIBCUDACXX_DISABLE_VISIBILITY_ANNOTATIONS1132 1133#ifndef _LIBCUDACXX_HAS_CUDA_ATOMIC_EXT1134#if defined(__cuda_std__)1135# define _LIBCUDACXX_HAS_CUDA_ATOMIC_EXT1136#endif1137#endif // _LIBCUDACXX_HAS_CUDA_ATOMIC_EXT1138 1139#ifndef _LIBCUDACXX_HAS_EXTERNAL_ATOMIC_IMP1140#if defined(__cuda_std__)1141# define _LIBCUDACXX_HAS_EXTERNAL_ATOMIC_IMP1142#endif1143#endif // _LIBCUDACXX_HAS_EXTERNAL_ATOMIC_IMP1144 1145#ifndef _LIBCUDACXX_HAS_NO_ASAN1146#if defined(_LIBCUDACXX_COMPILER_GCC)1147# if !defined(__SANITIZE_ADDRESS__)1148# define _LIBCUDACXX_HAS_NO_ASAN1149# endif // !__SANITIZE_ADDRESS__1150#elif defined(_LIBCUDACXX_COMPILER_CLANG)1151# if !__has_feature(address_sanitizer)1152# define _LIBCUDACXX_HAS_NO_ASAN1153# endif // !__has_feature(address_sanitizer)1154#else1155# define _LIBCUDACXX_HAS_NO_ASAN1156#endif // _LIBCUDACXX_COMPILER[MSVC|IBM|NVHPC|NVRTC]1157#endif // _LIBCUDACXX_HAS_NO_ASAN1158 1159#ifndef _LIBCUDACXX_HAS_NO_CXX20_CHRONO_LITERALS1160#if defined(__cuda_std__) \1161 || (defined(_LIBCUDACXX_COMPILER_CLANG) && _LIBCUDACXX_CLANG_VER < 800)1162# define _LIBCUDACXX_HAS_NO_CXX20_CHRONO_LITERALS1163#endif // __cuda_std__1164#endif // _LIBCUDACXX_HAS_NO_CXX20_CHRONO_LITERALS1165 1166#ifndef _LIBCUDACXX_HAS_NO_INT1281167#if defined(_LIBCUDACXX_COMPILER_MSVC) \1168 || (defined(_LIBCUDACXX_COMPILER_NVRTC) && !defined(__CUDACC_RTC_INT128__)) \1169 || (defined(_LIBCUDACXX_COMPILER_NVCC) && (_LIBCUDACXX_CUDACC_VER < 1105000)) \1170 || !defined(__SIZEOF_INT128__)1171# define _LIBCUDACXX_HAS_NO_INT1281172#endif1173#endif // !_LIBCUDACXX_HAS_NO_INT1281174 1175#ifndef _LIBCUDACXX_HAS_NO_LONG_DOUBLE1176#if defined(_LIBCUDACXX_CUDACC)1177# define _LIBCUDACXX_HAS_NO_LONG_DOUBLE1178#endif1179#endif // _LIBCUDACXX_HAS_NO_LONG_DOUBLE1180 1181#ifndef _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS1182#if __has_cpp_attribute(msvc::no_unique_address)1183// MSVC implements [[no_unique_address]] as a silent no-op currently.1184// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)1185// However, MSVC implements [[msvc::no_unique_address]] which does what1186// [[no_unique_address]] is supposed to do, in general.1187 1188// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or1189// [[msvc::no_unique_address]] though. If/when it does implement1190// [[msvc::no_unique_address]], this should be preferred though.1191# define _LIBCUDACXX_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]1192#elif defined(_LIBCUDACXX_CUDACC_BELOW_11_3) \1193 || (__has_cpp_attribute(no_unique_address) < 201803L)1194# define _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS1195# define _LIBCUDACXX_NO_UNIQUE_ADDRESS1196#elif __has_cpp_attribute(no_unique_address)1197# define _LIBCUDACXX_NO_UNIQUE_ADDRESS [[no_unique_address]]1198#else1199# define _LIBCUDACXX_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS1200# define _LIBCUDACXX_NO_UNIQUE_ADDRESS