diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-09-02 00:01:09 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-09-02 00:09:17 +0300 |
commit | b5c4ec42ac2cc59dc3b104277ce2e85f5f77c88e (patch) | |
tree | 9b37605b78a3d2398da4addca3ee37899621c38e /contrib/libs/cxxsupp | |
parent | 88fb7b5c334c3afdffacd104ee20efda4400d1bc (diff) | |
download | ydb-b5c4ec42ac2cc59dc3b104277ce2e85f5f77c88e.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/libs/cxxsupp')
-rw-r--r-- | contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/atomic_win32.h | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/atomic_win32.h b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/atomic_win32.h index e32bcf9073..1862997f17 100644 --- a/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/atomic_win32.h +++ b/contrib/libs/cxxsupp/libcxxmsvc/include/__support/win32/atomic_win32.h @@ -86,14 +86,14 @@ void __msvc_unlock(void* p); template<class _Out, class _Tp> static inline _Out __msvc_cast(_Tp __val) { - _Out __result; + alignas(_Out) char __result[sizeof(_Out)]; volatile char* to = reinterpret_cast<volatile char*>(&__result); volatile char* end = to + sizeof(_Tp); char* from = reinterpret_cast<char*>(&__val); while (to != end) { *to++ = *from++; } - return __result; + return *reinterpret_cast<_Out*>(&__result); } @@ -368,21 +368,20 @@ static inline __int64 __msvc_atomic_load64(volatile __int64* __a, memory_order _ template<typename _Tp> static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a, int __order) { - _Tp __result; if (sizeof(_Tp) == 1) { - __result = __msvc_cast<_Tp>(__msvc_atomic_load8((volatile char*)__a, (memory_order)__order)); + return __msvc_cast<_Tp>(__msvc_atomic_load8((volatile char*)__a, (memory_order)__order)); } else if (sizeof(_Tp) == 2 && alignof(_Tp) % 2 == 0) { - __result = __msvc_cast<_Tp>(__msvc_atomic_load16((volatile short*)__a, (memory_order)__order)); + return __msvc_cast<_Tp>(__msvc_atomic_load16((volatile short*)__a, (memory_order)__order)); } else if (sizeof(_Tp) == 4 && alignof(_Tp) % 4 == 0) { - __result = __msvc_cast<_Tp>(__msvc_atomic_load32((volatile long*)__a, (memory_order)__order)); + return __msvc_cast<_Tp>(__msvc_atomic_load32((volatile long*)__a, (memory_order)__order)); } else if (sizeof(_Tp) == 8 && alignof(_Tp) % 8 == 0) { - __result = __msvc_cast<_Tp>(__msvc_atomic_load64((volatile __int64*)__a, (memory_order)__order)); + return __msvc_cast<_Tp>(__msvc_atomic_load64((volatile __int64*)__a, (memory_order)__order)); } else { __msvc_lock((void*)__a); - __result = *(_Atomic(_Tp)*)__a; + _Tp __result = *(_Atomic(_Tp)*)__a; __msvc_unlock((void*)__a); + return __result; } - return __result; } template<typename _Tp> |