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 | 0a262ba7c3250ef02833fae864459ccc905a2e9b (patch) | |
tree | c9538f3275fedf709ead68ba853ad20ee270ae40 /lib/System/Mutex.cpp | |
parent | 6ef4949a0bea3f22e7572119d3692b1a5866ffe8 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23003 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Mutex.cpp')
-rw-r--r-- | lib/System/Mutex.cpp | 20 |
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 |