summaryrefslogtreecommitdiff
path: root/src/cxa_guard.cpp
diff options
context:
space:
mode:
authorAsiri Rathnayake <asiri.rathnayake@arm.com>2017-01-03 12:58:34 +0000
committerAsiri Rathnayake <asiri.rathnayake@arm.com>2017-01-03 12:58:34 +0000
commit71ba2871943cec379da0585c16f69fb5ac5a884b (patch)
tree88f9cd591439d08f6e4d767409652e66cff99ec4 /src/cxa_guard.cpp
parentcb51028de0ef63c71ec97f51f8858ef6b972cba2 (diff)
[libcxxabi] Introduce an externally threaded libc++abi variant.
r281179 Introduced an externally threaded variant of the libc++ library. This patch adds support for a similar library variant for libc++abi. Differential revision: https://reviews.llvm.org/D27575 Reviewers: EricWF git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@290888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src/cxa_guard.cpp')
-rw-r--r--src/cxa_guard.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/cxa_guard.cpp b/src/cxa_guard.cpp
index 1c468ff..97f2aaa 100644
--- a/src/cxa_guard.cpp
+++ b/src/cxa_guard.cpp
@@ -11,7 +11,7 @@
#include "abort_message.h"
#include "config.h"
-#include "threading_support.h"
+#include <__threading_support>
#include <stdint.h>
@@ -20,8 +20,8 @@
which will turn around and try to call __cxa_guard_acquire reentrantly.
For this reason, the headers of this file are as restricted as possible.
Previous implementations of this code for __APPLE__ have used
- __libcxxabi_mutex_lock and the abort_message utility without problem. This
- implementation also uses __libcxxabi_condvar_wait which has tested
+ std::__libcpp_mutex_lock and the abort_message utility without problem. This
+ implementation also uses std::__libcpp_condvar_wait which has tested
to not be a problem.
*/
@@ -67,8 +67,8 @@ bool is_initialized(guard_type* guard_object) {
#endif
#ifndef _LIBCXXABI_HAS_NO_THREADS
-__libcxxabi_mutex_t guard_mut = _LIBCXXABI_MUTEX_INITIALIZER;
-__libcxxabi_condvar_t guard_cv = _LIBCXXABI_CONDVAR_INITIALIZER;
+std::__libcpp_mutex_t guard_mut = _LIBCPP_MUTEX_INITIALIZER;
+std::__libcpp_condvar_t guard_cv = _LIBCPP_CONDVAR_INITIALIZER;
#endif
#if defined(__APPLE__) && !defined(__arm__)
@@ -173,13 +173,13 @@ extern "C"
#ifndef _LIBCXXABI_HAS_NO_THREADS
_LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type *guard_object) {
char* initialized = (char*)guard_object;
- if (__libcxxabi_mutex_lock(&guard_mut))
+ if (std::__libcpp_mutex_lock(&guard_mut))
abort_message("__cxa_guard_acquire failed to acquire mutex");
int result = *initialized == 0;
if (result)
{
#if defined(__APPLE__) && !defined(__arm__)
- const lock_type id = __libcxxabi_thread_get_port();
+ const lock_type id = std::__libcpp_thread_get_port();
lock_type lock = get_lock(*guard_object);
if (lock)
{
@@ -188,7 +188,7 @@ _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type *guard_object) {
abort_message("__cxa_guard_acquire detected deadlock");
do
{
- if (__libcxxabi_condvar_wait(&guard_cv, &guard_mut))
+ if (std::__libcpp_condvar_wait(&guard_cv, &guard_mut))
abort_message("__cxa_guard_acquire condition variable wait failed");
lock = get_lock(*guard_object);
} while (lock);
@@ -200,36 +200,36 @@ _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type *guard_object) {
set_lock(*guard_object, id);
#else // !__APPLE__ || __arm__
while (get_lock(*guard_object))
- if (__libcxxabi_condvar_wait(&guard_cv, &guard_mut))
+ if (std::__libcpp_condvar_wait(&guard_cv, &guard_mut))
abort_message("__cxa_guard_acquire condition variable wait failed");
result = *initialized == 0;
if (result)
set_lock(*guard_object, true);
#endif // !__APPLE__ || __arm__
}
- if (__libcxxabi_mutex_unlock(&guard_mut))
+ if (std::__libcpp_mutex_unlock(&guard_mut))
abort_message("__cxa_guard_acquire failed to release mutex");
return result;
}
_LIBCXXABI_FUNC_VIS void __cxa_guard_release(guard_type *guard_object) {
- if (__libcxxabi_mutex_lock(&guard_mut))
+ if (std::__libcpp_mutex_lock(&guard_mut))
abort_message("__cxa_guard_release failed to acquire mutex");
*guard_object = 0;
set_initialized(guard_object);
- if (__libcxxabi_mutex_unlock(&guard_mut))
+ if (std::__libcpp_mutex_unlock(&guard_mut))
abort_message("__cxa_guard_release failed to release mutex");
- if (__libcxxabi_condvar_broadcast(&guard_cv))
+ if (std::__libcpp_condvar_broadcast(&guard_cv))
abort_message("__cxa_guard_release failed to broadcast condition variable");
}
_LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *guard_object) {
- if (__libcxxabi_mutex_lock(&guard_mut))
+ if (std::__libcpp_mutex_lock(&guard_mut))
abort_message("__cxa_guard_abort failed to acquire mutex");
*guard_object = 0;
- if (__libcxxabi_mutex_unlock(&guard_mut))
+ if (std::__libcpp_mutex_unlock(&guard_mut))
abort_message("__cxa_guard_abort failed to release mutex");
- if (__libcxxabi_condvar_broadcast(&guard_cv))
+ if (std::__libcpp_condvar_broadcast(&guard_cv))
abort_message("__cxa_guard_abort failed to broadcast condition variable");
}