summaryrefslogtreecommitdiffstats
path: root/libcxx/src/mutex.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-03-20 22:55:03 +0000
committerNico Weber <nicolasweber@gmx.de>2019-03-20 22:55:03 +0000
commit0fd00a581d929c3caa2e92fbd06cdc1ae88fa457 (patch)
treef157e24fca60d7cdeb37b2cb5871023c2a8e6fd2 /libcxx/src/mutex.cpp
parentce3d67009718c7d124bdf540ac830c17d689645b (diff)
downloadbcm5719-llvm-0fd00a581d929c3caa2e92fbd06cdc1ae88fa457.tar.gz
bcm5719-llvm-0fd00a581d929c3caa2e92fbd06cdc1ae88fa457.zip
libc++/win: Make once_flag have the same size as a pointer.
`unsigned long` is 32-bit on 32-bit systems and 64-bit on 64-bit systems on LP64 systems -- which most Unix systems are, but Windows isn't. Windows is LLP64, which means unsigned long is 32-bit even on 64-bit systems. pplwin.h contains static_assert(alignof(void *) == alignof(::std::once_flag), ...) which fails due to this problem. Instead of unsigned long, use uintptr_t, which consistently is 32-bit on 32-bit systems and 64-bit on 64-bit systems. No functional change except on 64-bit Windows. Differential Revision: https://reviews.llvm.org/D59607 llvm-svn: 356624
Diffstat (limited to 'libcxx/src/mutex.cpp')
-rw-r--r--libcxx/src/mutex.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/libcxx/src/mutex.cpp b/libcxx/src/mutex.cpp
index a9ccc9aa9fa..6bb44e0551d 100644
--- a/libcxx/src/mutex.cpp
+++ b/libcxx/src/mutex.cpp
@@ -197,8 +197,8 @@ _LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
_LIBCPP_SAFE_STATIC static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
#endif
-void
-__call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
+void __call_once(volatile once_flag::_State_type& flag, void* arg,
+ void (*func)(void*))
{
#if defined(_LIBCPP_HAS_NO_THREADS)
if (flag == 0)
@@ -209,12 +209,12 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
#endif // _LIBCPP_NO_EXCEPTIONS
flag = 1;
func(arg);
- flag = ~0ul;
+ flag = ~once_flag::_State_type(0);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
- flag = 0ul;
+ flag = 0;
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
@@ -229,11 +229,12 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
- __libcpp_relaxed_store(&flag, 1ul);
+ __libcpp_relaxed_store(&flag, once_flag::_State_type(1));
__libcpp_mutex_unlock(&mut);
func(arg);
__libcpp_mutex_lock(&mut);
- __libcpp_atomic_store(&flag, ~0ul, _AO_Release);
+ __libcpp_atomic_store(&flag, ~once_flag::_State_type(0),
+ _AO_Release);
__libcpp_mutex_unlock(&mut);
__libcpp_condvar_broadcast(&cv);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -241,7 +242,7 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
catch (...)
{
__libcpp_mutex_lock(&mut);
- __libcpp_relaxed_store(&flag, 0ul);
+ __libcpp_relaxed_store(&flag, once_flag::_State_type(0));
__libcpp_mutex_unlock(&mut);
__libcpp_condvar_broadcast(&cv);
throw;
@@ -251,7 +252,6 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
else
__libcpp_mutex_unlock(&mut);
#endif // !_LIBCPP_HAS_NO_THREADS
-
}
_LIBCPP_END_NAMESPACE_STD
OpenPOWER on IntegriCloud