summaryrefslogtreecommitdiffstats
path: root/libcxxabi/src
diff options
context:
space:
mode:
Diffstat (limited to 'libcxxabi/src')
-rw-r--r--libcxxabi/src/config.h5
-rw-r--r--libcxxabi/src/cxa_exception.cpp2
-rw-r--r--libcxxabi/src/cxa_exception_storage.cpp2
-rw-r--r--libcxxabi/src/cxa_guard.cpp40
-rw-r--r--libcxxabi/src/fallback_malloc.ipp16
5 files changed, 30 insertions, 35 deletions
diff --git a/libcxxabi/src/config.h b/libcxxabi/src/config.h
index ac6d297d113..5d38d4d1465 100644
--- a/libcxxabi/src/config.h
+++ b/libcxxabi/src/config.h
@@ -16,11 +16,6 @@
#include <unistd.h>
-// Set this in the CXXFLAGS when you need it
-#if !defined(LIBCXXABI_HAS_NO_THREADS)
-# define LIBCXXABI_HAS_NO_THREADS 0
-#endif
-
// Set this in the CXXFLAGS when you need it, because otherwise we'd have to
// #if !defined(__linux__) && !defined(__APPLE__) && ...
// and so-on for *every* platform.
diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp
index 50d1a468cea..603f869f988 100644
--- a/libcxxabi/src/cxa_exception.cpp
+++ b/libcxxabi/src/cxa_exception.cpp
@@ -17,7 +17,7 @@
#include <exception> // for std::terminate
#include <cstdlib> // for malloc, free
#include <cstring> // for memset
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
# include <pthread.h> // for fallback_malloc.ipp's mutexes
#endif
#include "cxa_exception.hpp"
diff --git a/libcxxabi/src/cxa_exception_storage.cpp b/libcxxabi/src/cxa_exception_storage.cpp
index a39b6db005f..235b0cf1dd3 100644
--- a/libcxxabi/src/cxa_exception_storage.cpp
+++ b/libcxxabi/src/cxa_exception_storage.cpp
@@ -15,7 +15,7 @@
#include "config.h"
-#if LIBCXXABI_HAS_NO_THREADS
+#if defined(_LIBCXXABI_HAS_NO_THREADS)
namespace __cxxabiv1 {
extern "C" {
diff --git a/libcxxabi/src/cxa_guard.cpp b/libcxxabi/src/cxa_guard.cpp
index 2a01f27ad99..253d5d4ec5c 100644
--- a/libcxxabi/src/cxa_guard.cpp
+++ b/libcxxabi/src/cxa_guard.cpp
@@ -12,7 +12,7 @@
#include "abort_message.h"
#include "config.h"
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
# include <pthread.h>
#endif
#include <stdint.h>
@@ -50,7 +50,7 @@ void set_initialized(guard_type* guard_object) {
}
#endif
-#if LIBCXXABI_HAS_NO_THREADS || (defined(__APPLE__) && !defined(__arm__))
+#if defined(_LIBCXXABI_HAS_NO_THREADS) || (defined(__APPLE__) && !defined(__arm__))
#ifdef __arm__
// Test the lowest bit.
@@ -68,7 +68,7 @@ bool is_initialized(guard_type* guard_object) {
#endif
#endif
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
pthread_mutex_t guard_mut = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t guard_cv = PTHREAD_COND_INITIALIZER;
#endif
@@ -172,22 +172,7 @@ set_lock(uint32_t& x, lock_type y)
extern "C"
{
-#if LIBCXXABI_HAS_NO_THREADS
-_LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type *guard_object) {
- return !is_initialized(guard_object);
-}
-
-_LIBCXXABI_FUNC_VIS void __cxa_guard_release(guard_type *guard_object) {
- *guard_object = 0;
- set_initialized(guard_object);
-}
-
-_LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *guard_object) {
- *guard_object = 0;
-}
-
-#else // !LIBCXXABI_HAS_NO_THREADS
-
+#ifndef _LIBCXXABI_HAS_NO_THREADS
_LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type *guard_object) {
char* initialized = (char*)guard_object;
if (pthread_mutex_lock(&guard_mut))
@@ -250,7 +235,22 @@ _LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *guard_object) {
abort_message("__cxa_guard_abort failed to broadcast condition variable");
}
-#endif // !LIBCXXABI_HAS_NO_THREADS
+#else // _LIBCXXABI_HAS_NO_THREADS
+
+_LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type *guard_object) {
+ return !is_initialized(guard_object);
+}
+
+_LIBCXXABI_FUNC_VIS void __cxa_guard_release(guard_type *guard_object) {
+ *guard_object = 0;
+ set_initialized(guard_object);
+}
+
+_LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *guard_object) {
+ *guard_object = 0;
+}
+
+#endif // !_LIBCXXABI_HAS_NO_THREADS
} // extern "C"
diff --git a/libcxxabi/src/fallback_malloc.ipp b/libcxxabi/src/fallback_malloc.ipp
index 71b65bed888..1d8f8a32ce4 100644
--- a/libcxxabi/src/fallback_malloc.ipp
+++ b/libcxxabi/src/fallback_malloc.ipp
@@ -26,25 +26,25 @@
namespace {
// When POSIX threads are not available, make the mutex operations a nop
-#if LIBCXXABI_HAS_NO_THREADS
-static void * heap_mutex = 0;
-#else
+#ifndef _LIBCXXABI_HAS_NO_THREADS
static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
+#else
+static void * heap_mutex = 0;
#endif
class mutexor {
public:
-#if LIBCXXABI_HAS_NO_THREADS
- mutexor ( void * ) {}
- ~mutexor () {}
-#else
+#ifndef _LIBCXXABI_HAS_NO_THREADS
mutexor ( pthread_mutex_t *m ) : mtx_(m) { pthread_mutex_lock ( mtx_ ); }
~mutexor () { pthread_mutex_unlock ( mtx_ ); }
+#else
+ mutexor ( void * ) {}
+ ~mutexor () {}
#endif
private:
mutexor ( const mutexor &rhs );
mutexor & operator = ( const mutexor &rhs );
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
pthread_mutex_t *mtx_;
#endif
};
OpenPOWER on IntegriCloud