aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/patches/37-mutex.patch
diff options
context:
space:
mode:
authormaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 12:29:46 +0300
committermaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 13:14:22 +0300
commit9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch)
treea8fb3181d5947c0d78cf402aa56e686130179049 /contrib/libs/cxxsupp/libcxx/patches/37-mutex.patch
parenta44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff)
downloadydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz
publishFullContrib: true for ydb
<HIDDEN_URL> commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/patches/37-mutex.patch')
-rw-r--r--contrib/libs/cxxsupp/libcxx/patches/37-mutex.patch73
1 files changed, 73 insertions, 0 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/patches/37-mutex.patch b/contrib/libs/cxxsupp/libcxx/patches/37-mutex.patch
new file mode 100644
index 0000000000..eb49c1d5f5
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/patches/37-mutex.patch
@@ -0,0 +1,73 @@
+diff --git a/include/__mutex/once_flag.h b/include/__mutex/once_flag.h
+index 086f75c..d66bb87 100644
+--- a/include/__mutex/once_flag.h
++++ b/include/__mutex/once_flag.h
+@@ -21,6 +21,10 @@
+ # include <tuple>
+ #endif
+
++#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_CXX03_LANG)
++#include <atomic>
++#endif
++
+ #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+ # pragma GCC system_header
+ #endif
+@@ -60,7 +64,11 @@ struct _LIBCPP_TEMPLATE_VIS once_flag {
+ static const _State_type _Complete = ~_State_type(0);
+
+ private:
++#if defined(_LIBCPP_ABI_MICROSOFT)
++ atomic<_State_type> __state_;
++#else
+ _State_type __state_;
++#endif
+
+ #ifndef _LIBCPP_CXX03_LANG
+ template <class _Callable, class... _Args>
+@@ -115,13 +123,21 @@ void _LIBCPP_HIDE_FROM_ABI __call_once_proxy(void* __vp) {
+ (*__p)();
+ }
+
++#ifdef _LIBCPP_ABI_MICROSOFT
++_LIBCPP_EXPORTED_FROM_ABI void __call_once(volatile atomic<once_flag::_State_type>&, void*, void (*)(void*));
++#else
+ _LIBCPP_EXPORTED_FROM_ABI void __call_once(volatile once_flag::_State_type&, void*, void (*)(void*));
++#endif
+
+ #ifndef _LIBCPP_CXX03_LANG
+
+ template <class _Callable, class... _Args>
+ inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) {
++#if defined(_LIBCPP_ABI_MICROSOFT)
++ if (__flag.__state_.load(memory_order_acquire) != ~once_flag::_State_type(0)) {
++#else
+ if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {
++#endif
+ typedef tuple<_Callable&&, _Args&&...> _Gp;
+ _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...);
+ __call_once_param<_Gp> __p(__f);
+@@ -133,7 +149,11 @@ inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable&& __fun
+
+ template <class _Callable>
+ inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable& __func) {
++#if defined(_LIBCPP_ABI_MICROSOFT)
++ if (__flag.__state_.load(memory_order_acquire) != ~once_flag::_State_type(0)) {
++#else
+ if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {
++#endif
+ __call_once_param<_Callable> __p(__func);
+ std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
+ }
+@@ -141,7 +161,11 @@ inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable& __func
+
+ template <class _Callable>
+ inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, const _Callable& __func) {
++#if defined(_LIBCPP_ABI_MICROSOFT)
++ if (__flag.__state_.load(memory_order_relaxed) != ~once_flag::_State_type(0)) {
++#else
+ if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {
++#endif
+ __call_once_param<const _Callable> __p(__func);
+ std::__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);
+ }