diff options
author | Andrey Khalyavin <halyavin@gmail.com> | 2022-02-10 16:46:29 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:29 +0300 |
commit | f773626848a7c7456803654292e716b83d69cc12 (patch) | |
tree | db052dfcf9134f492bdbb962cb6c16cea58e1ed3 /contrib/libs/cxxsupp/libcxx/src/support/win32/atomic_win32.cpp | |
parent | f43ab775d197d300eb67bd4497632b909cd7c2a5 (diff) | |
download | ydb-f773626848a7c7456803654292e716b83d69cc12.tar.gz |
Restoring authorship annotation for Andrey Khalyavin <halyavin@gmail.com>. Commit 1 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 28cb0722ce..04717c8c87 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 |