[llvm-commits] CVS: llvm/lib/System/Mutex.cpp

Reid Spencer reid at x10sys.com
Wed Aug 24 03:07:34 PDT 2005



Changes in directory llvm/lib/System:

Mutex.cpp updated: 1.5 -> 1.6
---
Log message:

For PR616: http://llvm.cs.uiuc.edu/PR616 :
These patches make threading optional in LLVM. The configuration scripts are now
modified to accept a --disable-threads switch. If this is used, the Mutex class
will be implemented with all functions as no-op. Furthermore, linking against
libpthread will not be done. Finally, the ParallelJIT example needs libpthread
so its makefile was changed to always add -lpthread to the link line.


---
Diffs of the changes:  (+17 -3)

 Mutex.cpp |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)


Index: llvm/lib/System/Mutex.cpp
diff -u llvm/lib/System/Mutex.cpp:1.5 llvm/lib/System/Mutex.cpp:1.6
--- llvm/lib/System/Mutex.cpp:1.5	Tue Aug  2 11:04:59 2005
+++ llvm/lib/System/Mutex.cpp	Wed Aug 24 05:07:21 2005
@@ -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 @@
 #else
 #warning Neither LLVM_ON_UNIX nor LLVM_ON_WIN32 was set in System/Mutex.cpp
 #endif
+#endif






More information about the llvm-commits mailing list