diff options
Diffstat (limited to 'libcxx/include')
| -rw-r--r-- | libcxx/include/mutex | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libcxx/include/mutex b/libcxx/include/mutex index 98bd581eb86..20c3ffc38b6 100644 --- a/libcxx/include/mutex +++ b/libcxx/include/mutex @@ -188,6 +188,7 @@ template<class Callable, class ...Args> #include <__config> #include <__mutex_base> +#include <cstdint> #include <functional> #include <memory> #ifndef _LIBCPP_CXX03_LANG @@ -575,11 +576,18 @@ struct _LIBCPP_TEMPLATE_VIS once_flag _LIBCPP_CONSTEXPR once_flag() _NOEXCEPT : __state_(0) {} +#if defined(_LIBCPP_ABI_MICROSOFT) + typedef uintptr_t _State_type; +#else + typedef unsigned long _State_type; +#endif + + private: once_flag(const once_flag&); // = delete; once_flag& operator=(const once_flag&); // = delete; - unsigned long __state_; + _State_type __state_; #ifndef _LIBCPP_CXX03_LANG template<class _Callable, class... _Args> @@ -649,7 +657,8 @@ __call_once_proxy(void* __vp) (*__p)(); } -_LIBCPP_FUNC_VIS void __call_once(volatile unsigned long&, void*, void(*)(void*)); +_LIBCPP_FUNC_VIS void __call_once(volatile once_flag::_State_type&, void*, + void (*)(void*)); #ifndef _LIBCPP_CXX03_LANG @@ -658,7 +667,7 @@ inline _LIBCPP_INLINE_VISIBILITY void call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) { - if (__libcpp_acquire_load(&__flag.__state_) != ~0ul) + if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0)) { typedef tuple<_Callable&&, _Args&&...> _Gp; _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...); @@ -674,7 +683,7 @@ inline _LIBCPP_INLINE_VISIBILITY void call_once(once_flag& __flag, _Callable& __func) { - if (__libcpp_acquire_load(&__flag.__state_) != ~0ul) + if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0)) { __call_once_param<_Callable> __p(__func); __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>); @@ -686,7 +695,7 @@ inline _LIBCPP_INLINE_VISIBILITY void call_once(once_flag& __flag, const _Callable& __func) { - if (__libcpp_acquire_load(&__flag.__state_) != ~0ul) + if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0)) { __call_once_param<const _Callable> __p(__func); __call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>); |

