diff --git a/libcxx/include/__config b/libcxx/include/__config index 44653fb697..c96fe80ed8 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -858,6 +858,11 @@ typedef __char32_t char32_t; #define _LIBCUDACXX_HAS_NO_LOGICAL_METAFUNCTION_ALIASES #endif +// MSVC exposed __iso_volatile intrinsics beginning on 1924 for x86 +#if _MSC_VER < 1924 + #define _LIBCUDACXX_HAS_NO_ISO_INTRIN +#endif + #define _LIBCUDACXX_UNDERLYING_TYPE(...) __underlying_type(__VA_ARGS__) #define _LIBCUDACXX_IS_CONSTRUCTIBLE(...) __is_constructible(__VA_ARGS__) #define _LIBCUDACXX_IS_DESTRUCTIBLE(...) __is_destructible(__VA_ARGS__) diff --git a/libcxx/include/support/win32/atomic_msvc.h b/libcxx/include/support/win32/atomic_msvc.h index 342add4afb..73a12d1f40 100644 --- a/libcxx/include/support/win32/atomic_msvc.h +++ b/libcxx/include/support/win32/atomic_msvc.h @@ -1,3 +1,4 @@ +// -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of libcu++, the C++ Standard Library for your entire system, @@ -45,22 +46,38 @@ namespace detail { template = 0> void __atomic_load_relaxed(const volatile _Type *__ptr, _Type *__ret) { +#ifdef _LIBCUDACXX_HAS_NO_ISO_INTRIN + __int8 __tmp = *(const volatile __int8 *)__ptr; +#else __int8 __tmp = __iso_volatile_load8((const volatile __int8 *)__ptr); +#endif *__ret = reinterpret_cast<_Type&>(__tmp); } template = 0> void __atomic_load_relaxed(const volatile _Type *__ptr, _Type *__ret) { +#ifdef _LIBCUDACXX_HAS_NO_ISO_INTRIN + __int16 __tmp = *(const volatile __int8 *)__ptr; +#else __int16 __tmp = __iso_volatile_load16((const volatile __int16 *)__ptr); +#endif *__ret = reinterpret_cast<_Type&>(__tmp); } template = 0> void __atomic_load_relaxed(const volatile _Type *__ptr, _Type *__ret) { +#ifdef _LIBCUDACXX_HAS_NO_ISO_INTRIN + __int32 __tmp = *(const volatile __int8 *)__ptr; +#else __int32 __tmp = __iso_volatile_load32((const volatile __int32 *)__ptr); +#endif *__ret = reinterpret_cast<_Type&>(__tmp); } template = 0> void __atomic_load_relaxed(const volatile _Type *__ptr, _Type *__ret) { +#ifdef _LIBCUDACXX_HAS_NO_ISO_INTRIN + __int64 __tmp = *(const volatile __int8 *)__ptr; +#else __int64 __tmp = __iso_volatile_load64((const volatile __int64 *)__ptr); +#endif *__ret = reinterpret_cast<_Type&>(__tmp); } @@ -75,6 +92,7 @@ void __atomic_load(const volatile _Type *__ptr, _Type *__ret, int __memorder) { } } + template = 0> void __atomic_store_relaxed(const volatile _Type *__ptr, _Type *__val) { __int8 __tmp = reinterpret_cast<__int8&>(*__val);