diff options
author | Andrey Khalyavin <halyavin@gmail.com> | 2022-02-10 16:46:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:30 +0300 |
commit | 4b839d0704ee9be1dabb0310a1f03af24963637b (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/cxxsupp/libcxx/src/support/win32/atomic_win32.cpp | |
parent | f773626848a7c7456803654292e716b83d69cc12 (diff) | |
download | ydb-4b839d0704ee9be1dabb0310a1f03af24963637b.tar.gz |
Restoring authorship annotation for Andrey Khalyavin <halyavin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src/support/win32/atomic_win32.cpp')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/src/support/win32/atomic_win32.cpp | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/win32/atomic_win32.cpp b/contrib/libs/cxxsupp/libcxx/src/support/win32/atomic_win32.cpp index 04717c8c87..28cb0722ce 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/win32/atomic_win32.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/support/win32/atomic_win32.cpp @@ -1,31 +1,31 @@ -#include <intrin.h> -#include <cstdint> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace { -static const int __msvc_locks_size = 1024; -volatile long __msvc_locks[__msvc_locks_size]; - -size_t __msvc_lock_hash(void* __p) { - uintptr_t __num = reinterpret_cast<uintptr_t>(__p); - return (__num ^ (__num >> 10)) & (__msvc_locks_size - 1); -} -} - -void __msvc_lock(void* __p) { - volatile long& __lock = __msvc_locks[__msvc_lock_hash(__p)]; - while (_InterlockedExchange(&__lock, 1) == 0) { -#if defined(_M_ARM) || defined(_M_ARM64) - __yield(); -#endif - } -} - -void __msvc_unlock(void* __p) { - volatile long& __lock = __msvc_locks[__msvc_lock_hash(__p)]; - _InterlockedExchange(&__lock, 0); -} - -_LIBCPP_END_NAMESPACE_STD
\ No newline at end of file +#include <intrin.h> +#include <cstdint> + + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace { +static const int __msvc_locks_size = 1024; +volatile long __msvc_locks[__msvc_locks_size]; + +size_t __msvc_lock_hash(void* __p) { + uintptr_t __num = reinterpret_cast<uintptr_t>(__p); + return (__num ^ (__num >> 10)) & (__msvc_locks_size - 1); +} +} + +void __msvc_lock(void* __p) { + volatile long& __lock = __msvc_locks[__msvc_lock_hash(__p)]; + while (_InterlockedExchange(&__lock, 1) == 0) { +#if defined(_M_ARM) || defined(_M_ARM64) + __yield(); +#endif + } +} + +void __msvc_unlock(void* __p) { + volatile long& __lock = __msvc_locks[__msvc_lock_hash(__p)]; + _InterlockedExchange(&__lock, 0); +} + +_LIBCPP_END_NAMESPACE_STD
\ No newline at end of file |