Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsiri Rathnayake <asiri.rathnayake@arm.com>2016-10-13 18:05:19 +0300
committerAsiri Rathnayake <asiri.rathnayake@arm.com>2016-10-13 18:05:19 +0300
commit6d3ea6831d6fe30683d6b5078ad826fdedc2e946 (patch)
tree92f3fb6daa13e34459ba54f27f5bad8da3099793 /libcxxabi/src/cxa_exception_storage.cpp
parent85874a9360334ddb9619aca6344b8ee53296fa1e (diff)
[libcxxabi] Refactor pthread usage into a separate API
This patch refactors all pthread uses of libc++abi into a separate API. This is the first step towards supporting an externlly-threaded libc++abi library. I've followed the conventions already used in the libc++ library for the same purpose. Patch from: Saleem Abdulrasool and Asiri Rathnayake Reviewed by: compnerd, EricWF Differential revisions: https://reviews.llvm.org/D18482 (original) https://reviews.llvm.org/D24864 (final) llvm-svn: 284128
Diffstat (limited to 'libcxxabi/src/cxa_exception_storage.cpp')
-rw-r--r--libcxxabi/src/cxa_exception_storage.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/libcxxabi/src/cxa_exception_storage.cpp b/libcxxabi/src/cxa_exception_storage.cpp
index ec69094c40cd..d18eb0f84c25 100644
--- a/libcxxabi/src/cxa_exception_storage.cpp
+++ b/libcxxabi/src/cxa_exception_storage.cpp
@@ -14,6 +14,7 @@
#include "cxa_exception.hpp"
#include "config.h"
+#include "threading_support.h"
#if defined(_LIBCXXABI_HAS_NO_THREADS)
@@ -44,28 +45,27 @@ extern "C" {
#else
-#include <pthread.h>
#include "abort_message.h"
#include "fallback_malloc.h"
-// In general, we treat all pthread errors as fatal.
+// In general, we treat all threading errors as fatal.
// We cannot call std::terminate() because that will in turn
// call __cxa_get_globals() and cause infinite recursion.
namespace __cxxabiv1 {
namespace {
- pthread_key_t key_;
- pthread_once_t flag_ = PTHREAD_ONCE_INIT;
+ __libcxxabi_tls_key key_;
+ __libcxxabi_exec_once_flag flag_ = _LIBCXXABI_EXEC_ONCE_INITIALIZER;
void destruct_ (void *p) {
__free_with_fallback ( p );
- if ( 0 != ::pthread_setspecific ( key_, NULL ) )
+ if ( 0 != __libcxxabi_tls_set ( key_, NULL ) )
abort_message("cannot zero out thread value for __cxa_get_globals()");
}
void construct_ () {
- if ( 0 != pthread_key_create ( &key_, destruct_ ) )
- abort_message("cannot create pthread key for __cxa_get_globals()");
+ if ( 0 != __libcxxabi_tls_create ( &key_, destruct_ ) )
+ abort_message("cannot create thread specific key for __cxa_get_globals()");
}
}
@@ -80,8 +80,8 @@ extern "C" {
(__calloc_with_fallback (1, sizeof (__cxa_eh_globals)));
if ( NULL == retVal )
abort_message("cannot allocate __cxa_eh_globals");
- if ( 0 != pthread_setspecific ( key_, retVal ) )
- abort_message("pthread_setspecific failure in __cxa_get_globals()");
+ if ( 0 != __libcxxabi_tls_set ( key_, retVal ) )
+ abort_message("__libcxxabi_tls_set failure in __cxa_get_globals()");
}
return retVal;
}
@@ -92,10 +92,10 @@ extern "C" {
// libc++abi.
__cxa_eh_globals * __cxa_get_globals_fast () {
// First time through, create the key.
- if (0 != pthread_once(&flag_, construct_))
- abort_message("pthread_once failure in __cxa_get_globals_fast()");
+ if (0 != __libcxxabi_execute_once(&flag_, construct_))
+ abort_message("execute once failure in __cxa_get_globals_fast()");
// static int init = construct_();
- return static_cast<__cxa_eh_globals*>(::pthread_getspecific(key_));
+ return static_cast<__cxa_eh_globals*>(__libcxxabi_tls_get(key_));
}
}