summaryrefslogtreecommitdiff
path: root/lib/System/Mutex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/System/Mutex.cpp')
-rw-r--r--lib/System/Mutex.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/System/Mutex.cpp b/lib/System/Mutex.cpp
index 25c83e848d..33dff05331 100644
--- a/lib/System/Mutex.cpp
+++ b/lib/System/Mutex.cpp
@@ -11,23 +11,36 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/System/Mutex.h"
#include "llvm/Config/config.h"
+#include "llvm/System/Mutex.h"
//===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only TRULY operating system
//=== independent code.
//===----------------------------------------------------------------------===//
-#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
-
+#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0
+// Define all methods as no-ops if threading is explicitly disabled
namespace llvm {
using namespace sys;
+Mutex::Mutex( bool recursive) { }
+Mutex::~Mutex() { }
+bool Mutex::acquire() { return true; }
+bool Mutex::release() { return true; }
+bool Mutex::tryacquire() { return true; }
+}
+#else
+
+#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
#include <cassert>
#include <pthread.h>
#include <stdlib.h>
+namespace llvm {
+using namespace sys;
+
+
// This variable is useful for situations where the pthread library has been
// compiled with weak linkage for its interface symbols. This allows the
// threading support to be turned off by simply not linking against -lpthread.
@@ -143,3 +156,4 @@ Mutex::tryacquire()
#else
#warning Neither LLVM_ON_UNIX nor LLVM_ON_WIN32 was set in System/Mutex.cpp
#endif
+#endif