summaryrefslogtreecommitdiffstats
path: root/libcxxabi/src/fallback_malloc.ipp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxxabi/src/fallback_malloc.ipp')
-rw-r--r--libcxxabi/src/fallback_malloc.ipp14
1 files changed, 14 insertions, 0 deletions
diff --git a/libcxxabi/src/fallback_malloc.ipp b/libcxxabi/src/fallback_malloc.ipp
index 4f8ce903ed2..a97f3fd45f2 100644
--- a/libcxxabi/src/fallback_malloc.ipp
+++ b/libcxxabi/src/fallback_malloc.ipp
@@ -11,6 +11,8 @@
//
//===----------------------------------------------------------------------===//
+#include "config.h"
+
// A small, simple heap manager based (loosely) on
// the startup heap manager from FreeBSD, optimized for space.
//
@@ -23,16 +25,28 @@
namespace {
+// When POSIX threads are not available, make the mutex operations a nop
+#if LIBCXXABI_SINGLE_THREADED
+static void * heap_mutex = 0;
+#else
static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
class mutexor {
public:
+#if LIBCXXABI_SINGLE_THREADED
+ mutexor ( void * ) {}
+ ~mutexor () {}
+#else
mutexor ( pthread_mutex_t *m ) : mtx_(m) { pthread_mutex_lock ( mtx_ ); }
~mutexor () { pthread_mutex_unlock ( mtx_ ); }
+#endif
private:
mutexor ( const mutexor &rhs );
mutexor & operator = ( const mutexor &rhs );
+#if !LIBCXXABI_SINGLE_THREADED
pthread_mutex_t *mtx_;
+#endif
};
OpenPOWER on IntegriCloud