Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Fixup atomic msvc intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
wmaxey committed Nov 19, 2020
1 parent 38de998 commit 78034a2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
18 changes: 18 additions & 0 deletions libcxx/include/support/win32/atomic_msvc.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
Expand Down Expand Up @@ -45,22 +46,38 @@ namespace detail {

template<class _Type, detail::_enable_if_sized_as<_Type,1> = 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<class _Type, detail::_enable_if_sized_as<_Type,2> = 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<class _Type, detail::_enable_if_sized_as<_Type,4> = 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<class _Type, detail::_enable_if_sized_as<_Type,8> = 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);
}

Expand All @@ -75,6 +92,7 @@ void __atomic_load(const volatile _Type *__ptr, _Type *__ret, int __memorder) {
}
}


template<class _Type, detail::_enable_if_sized_as<_Type,1> = 0>
void __atomic_store_relaxed(const volatile _Type *__ptr, _Type *__val) {
__int8 __tmp = reinterpret_cast<__int8&>(*__val);
Expand Down

0 comments on commit 78034a2

Please sign in to comment.