diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2005-08-24 10:07:20 +0000 |
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2005-08-24 10:07:20 +0000 |
| commit | f85fabeb7153561b8e77f9f1d9a850417dbf7111 (patch) | |
| tree | 33235cb27e32043a67f5e3d63eeeb27d31d8e892 /llvm/lib/System | |
| parent | 7c1ba938beda6da4082225ffae81a35fc992aa1e (diff) | |
| download | bcm5719-llvm-f85fabeb7153561b8e77f9f1d9a850417dbf7111.tar.gz bcm5719-llvm-f85fabeb7153561b8e77f9f1d9a850417dbf7111.zip | |
For 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.
llvm-svn: 23003
Diffstat (limited to 'llvm/lib/System')
| -rw-r--r-- | llvm/lib/System/Mutex.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/System/Mutex.cpp b/llvm/lib/System/Mutex.cpp index 25c83e848d0..33dff053315 100644 --- a/llvm/lib/System/Mutex.cpp +++ b/llvm/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 |

