summaryrefslogtreecommitdiff
path: root/src/fallback_malloc.cpp
diff options
context:
space:
mode:
authorAsiri Rathnayake <asiri.rathnayake@arm.com>2016-10-13 15:05:19 +0000
committerAsiri Rathnayake <asiri.rathnayake@arm.com>2016-10-13 15:05:19 +0000
commit5180673e0abca22cdc611dc869caf82ae728f3d3 (patch)
treef2507c7ac8f13bd632dd1ef31dbd3df9b574669d /src/fallback_malloc.cpp
parent3f7b3700184b818c28ee085e3d629aa5f314169b (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) git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@284128 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src/fallback_malloc.cpp')
-rw-r--r--src/fallback_malloc.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/fallback_malloc.cpp b/src/fallback_malloc.cpp
index a436ed0..5f52ece 100644
--- a/src/fallback_malloc.cpp
+++ b/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
};