diff options
author | Asiri Rathnayake <asiri.rathnayake@arm.com> | 2016-10-13 18:05:19 +0300 |
---|---|---|
committer | Asiri Rathnayake <asiri.rathnayake@arm.com> | 2016-10-13 18:05:19 +0300 |
commit | 6d3ea6831d6fe30683d6b5078ad826fdedc2e946 (patch) | |
tree | 92f3fb6daa13e34459ba54f27f5bad8da3099793 /libcxxabi/src/fallback_malloc.cpp | |
parent | 85874a9360334ddb9619aca6344b8ee53296fa1e (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/fallback_malloc.cpp')
-rw-r--r-- | libcxxabi/src/fallback_malloc.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/libcxxabi/src/fallback_malloc.cpp b/libcxxabi/src/fallback_malloc.cpp index a436ed0ece7a..5f52ece56f4d 100644 --- a/libcxxabi/src/fallback_malloc.cpp +++ b/libcxxabi/src/fallback_malloc.cpp @@ -10,14 +10,11 @@ #include "fallback_malloc.h" #include "config.h" +#include "threading_support.h" #include <cstdlib> // for malloc, calloc, free #include <cstring> // for memset -#ifndef _LIBCXXABI_HAS_NO_THREADS -#include <pthread.h> // for mutexes -#endif - // A small, simple heap manager based (loosely) on // the startup heap manager from FreeBSD, optimized for space. // @@ -32,7 +29,7 @@ namespace { // When POSIX threads are not available, make the mutex operations a nop #ifndef _LIBCXXABI_HAS_NO_THREADS -static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER; +static __libcxxabi_mutex_t heap_mutex = _LIBCXXABI_MUTEX_INITIALIZER; #else static void * heap_mutex = 0; #endif @@ -40,8 +37,8 @@ static void * heap_mutex = 0; class mutexor { public: #ifndef _LIBCXXABI_HAS_NO_THREADS - mutexor ( pthread_mutex_t *m ) : mtx_(m) { pthread_mutex_lock ( mtx_ ); } - ~mutexor () { pthread_mutex_unlock ( mtx_ ); } + mutexor ( __libcxxabi_mutex_t *m ) : mtx_(m) { __libcxxabi_mutex_lock ( mtx_ ); } + ~mutexor () { __libcxxabi_mutex_unlock ( mtx_ ); } #else mutexor ( void * ) {} ~mutexor () {} @@ -50,7 +47,7 @@ private: mutexor ( const mutexor &rhs ); mutexor & operator = ( const mutexor &rhs ); #ifndef _LIBCXXABI_HAS_NO_THREADS - pthread_mutex_t *mtx_; + __libcxxabi_mutex_t *mtx_; #endif }; |