Index: libcxx/include/mutex =================================================================== --- libcxx/include/mutex +++ libcxx/include/mutex @@ -188,6 +188,7 @@ #include <__config> #include <__mutex_base> +#include #include #include #ifndef _LIBCPP_CXX03_LANG @@ -579,7 +580,7 @@ once_flag(const once_flag&); // = delete; once_flag& operator=(const once_flag&); // = delete; - unsigned long __state_; + uintptr_t __state_; #ifndef _LIBCPP_CXX03_LANG template @@ -649,7 +650,7 @@ (*__p)(); } -_LIBCPP_FUNC_VIS void __call_once(volatile unsigned long&, void*, void(*)(void*)); +_LIBCPP_FUNC_VIS void __call_once(volatile uintptr_t&, void*, void(*)(void*)); #ifndef _LIBCPP_CXX03_LANG @@ -658,7 +659,7 @@ void call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) { - if (__libcpp_acquire_load(&__flag.__state_) != ~0ul) + if (__libcpp_acquire_load(&__flag.__state_) != ~uintptr_t(0)) { typedef tuple<_Callable&&, _Args&&...> _Gp; _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...); @@ -674,7 +675,7 @@ void call_once(once_flag& __flag, _Callable& __func) { - if (__libcpp_acquire_load(&__flag.__state_) != ~0ul) + if (__libcpp_acquire_load(&__flag.__state_) != ~uintptr_t(0)) { __call_once_param<_Callable> __p(__func); __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>); @@ -686,7 +687,7 @@ void call_once(once_flag& __flag, const _Callable& __func) { - if (__libcpp_acquire_load(&__flag.__state_) != ~0ul) + if (__libcpp_acquire_load(&__flag.__state_) != ~uintptr_t(0)) { __call_once_param __p(__func); __call_once(__flag.__state_, &__p, &__call_once_proxy); Index: libcxx/src/mutex.cpp =================================================================== --- libcxx/src/mutex.cpp +++ libcxx/src/mutex.cpp @@ -198,7 +198,7 @@ #endif void -__call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) +__call_once(volatile uintptr_t& flag, void* arg, void(*func)(void*)) { #if defined(_LIBCPP_HAS_NO_THREADS) if (flag == 0) @@ -209,12 +209,12 @@ #endif // _LIBCPP_NO_EXCEPTIONS flag = 1; func(arg); - flag = ~0ul; + flag = ~uintptr_t(0); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { - flag = 0ul; + flag = 0; throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -229,11 +229,11 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS - __libcpp_relaxed_store(&flag, 1ul); + __libcpp_relaxed_store(&flag, uintptr_t(1)); __libcpp_mutex_unlock(&mut); func(arg); __libcpp_mutex_lock(&mut); - __libcpp_atomic_store(&flag, ~0ul, _AO_Release); + __libcpp_atomic_store(&flag, ~uintptr_t(0), _AO_Release); __libcpp_mutex_unlock(&mut); __libcpp_condvar_broadcast(&cv); #ifndef _LIBCPP_NO_EXCEPTIONS @@ -241,7 +241,7 @@ catch (...) { __libcpp_mutex_lock(&mut); - __libcpp_relaxed_store(&flag, 0ul); + __libcpp_relaxed_store(&flag, uintptr_t(0)); __libcpp_mutex_unlock(&mut); __libcpp_condvar_broadcast(&cv); throw;