From: Owen Anderson Date: Thu, 18 Jun 2009 16:54:52 +0000 (+0000) Subject: Move Threading.[h|cpp] from Support to System. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e3cd5ca7e79f4359e8a101c211fc9c117eb62347;p=oota-llvm.git Move Threading.[h|cpp] from Support to System. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73707 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/ManagedStatic.h b/include/llvm/Support/ManagedStatic.h index 412e474ffba..ee335d819a9 100644 --- a/include/llvm/Support/ManagedStatic.h +++ b/include/llvm/Support/ManagedStatic.h @@ -15,7 +15,7 @@ #define LLVM_SUPPORT_MANAGED_STATIC_H #include "llvm/System/Atomic.h" -#include "llvm/Support/Threading.h" +#include "llvm/System/Threading.h" namespace llvm { diff --git a/include/llvm/Support/Threading.h b/include/llvm/Support/Threading.h deleted file mode 100644 index bac11a23800..00000000000 --- a/include/llvm/Support/Threading.h +++ /dev/null @@ -1,45 +0,0 @@ -//===-- llvm/Support/Threading.h - Control multithreading mode --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// TThis file defines llvm_start_multithreaded() and friends. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_THREADING_H -#define LLVM_SUPPORT_THREADING_H - -namespace llvm { - /// llvm_start_multithreaded - Allocate and initialize structures needed to - /// make LLVM safe for multithreading. The return value indicates whether - /// multithreaded initialization succeeded. LLVM will still be operational - /// on "failed" return, and will still be safe for hosting threading - /// applications in the JIT, but will not be safe for concurrent calls to the - /// LLVM APIs. - /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS. - bool llvm_start_multithreaded(); - - /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM - /// safe for multithreading. - /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS. - void llvm_stop_multithreaded(); - - /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe - /// mode or not. - bool llvm_is_multithreaded(); - - /// acquire_global_lock - Acquire the global lock. This is a no-op if called - /// before llvm_start_multithreaded(). - void llvm_acquire_global_lock(); - - /// release_global_lock - Release the global lock. This is a no-op if called - /// before llvm_start_multithreaded(). - void llvm_release_global_lock(); -} - -#endif diff --git a/include/llvm/System/Threading.h b/include/llvm/System/Threading.h new file mode 100644 index 00000000000..42d2f89bcb8 --- /dev/null +++ b/include/llvm/System/Threading.h @@ -0,0 +1,45 @@ +//===-- llvm/System/Threading.h - Control multithreading mode --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// TThis file defines llvm_start_multithreaded() and friends. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SYSTEM_THREADING_H +#define LLVM_SYSTEM_THREADING_H + +namespace llvm { + /// llvm_start_multithreaded - Allocate and initialize structures needed to + /// make LLVM safe for multithreading. The return value indicates whether + /// multithreaded initialization succeeded. LLVM will still be operational + /// on "failed" return, and will still be safe for hosting threading + /// applications in the JIT, but will not be safe for concurrent calls to the + /// LLVM APIs. + /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS. + bool llvm_start_multithreaded(); + + /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM + /// safe for multithreading. + /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS. + void llvm_stop_multithreaded(); + + /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe + /// mode or not. + bool llvm_is_multithreaded(); + + /// acquire_global_lock - Acquire the global lock. This is a no-op if called + /// before llvm_start_multithreaded(). + void llvm_acquire_global_lock(); + + /// release_global_lock - Release the global lock. This is a no-op if called + /// before llvm_start_multithreaded(). + void llvm_release_global_lock(); +} + +#endif diff --git a/lib/Support/Threading.cpp b/lib/Support/Threading.cpp deleted file mode 100644 index 15a4b915d13..00000000000 --- a/lib/Support/Threading.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===-- llvm/Support/Threading.cpp- Control multithreading mode --*- C++ -*-==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements llvm_start_multithreaded() and friends. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/Threading.h" -#include "llvm/System/Atomic.h" -#include "llvm/System/Mutex.h" -#include - -using namespace llvm; - -static bool multithreaded_mode = false; - -static sys::Mutex* global_lock = 0; - -bool llvm::llvm_start_multithreaded() { -#ifdef LLVM_MULTITHREADED - assert(!multithreaded_mode && "Already multithreaded!"); - multithreaded_mode = true; - global_lock = new sys::Mutex(true); - - // We fence here to ensure that all initialization is complete BEFORE we - // return from llvm_start_multithreaded(). - sys::MemoryFence(); - return true; -#else - return false; -#endif -} - -void llvm::llvm_stop_multithreaded() { -#ifdef LLVM_MULTITHREADED - assert(multithreaded_mode && "Not currently multithreaded!"); - - // We fence here to insure that all threaded operations are complete BEFORE we - // return from llvm_stop_multithreaded(). - sys::MemoryFence(); - - multithreaded_mode = false; - delete global_lock; -#endif -} - -bool llvm::llvm_is_multithreaded() { - return multithreaded_mode; -} - -void llvm::llvm_acquire_global_lock() { - if (multithreaded_mode) global_lock->acquire(); -} - -void llvm::llvm_release_global_lock() { - if (multithreaded_mode) global_lock->release(); -} diff --git a/lib/System/Threading.cpp b/lib/System/Threading.cpp new file mode 100644 index 00000000000..a2d7f82715d --- /dev/null +++ b/lib/System/Threading.cpp @@ -0,0 +1,63 @@ +//===-- llvm/System/Threading.cpp- Control multithreading mode --*- C++ -*-==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements llvm_start_multithreaded() and friends. +// +//===----------------------------------------------------------------------===// + +#include "llvm/System/Threading.h" +#include "llvm/System/Atomic.h" +#include "llvm/System/Mutex.h" +#include + +using namespace llvm; + +static bool multithreaded_mode = false; + +static sys::Mutex* global_lock = 0; + +bool llvm::llvm_start_multithreaded() { +#ifdef LLVM_MULTITHREADED + assert(!multithreaded_mode && "Already multithreaded!"); + multithreaded_mode = true; + global_lock = new sys::Mutex(true); + + // We fence here to ensure that all initialization is complete BEFORE we + // return from llvm_start_multithreaded(). + sys::MemoryFence(); + return true; +#else + return false; +#endif +} + +void llvm::llvm_stop_multithreaded() { +#ifdef LLVM_MULTITHREADED + assert(multithreaded_mode && "Not currently multithreaded!"); + + // We fence here to insure that all threaded operations are complete BEFORE we + // return from llvm_stop_multithreaded(). + sys::MemoryFence(); + + multithreaded_mode = false; + delete global_lock; +#endif +} + +bool llvm::llvm_is_multithreaded() { + return multithreaded_mode; +} + +void llvm::llvm_acquire_global_lock() { + if (multithreaded_mode) global_lock->acquire(); +} + +void llvm::llvm_release_global_lock() { + if (multithreaded_mode) global_lock->release(); +} diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 043a30ff47f..8af5b037d11 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -25,8 +25,8 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Support/Threading.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 00f9fa30067..ace54d35b2c 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -18,8 +18,8 @@ #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/StringPool.h" -#include "llvm/Support/Threading.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include "SymbolTableListTraitsImpl.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringExtras.h" diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp index 52a424ee79e..036cb9c616c 100644 --- a/lib/VMCore/LeakDetector.cpp +++ b/lib/VMCore/LeakDetector.cpp @@ -16,8 +16,8 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Streams.h" -#include "llvm/Support/Threading.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include "llvm/Value.h" using namespace llvm; diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 70ec108fa18..3fce83d5a60 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -19,8 +19,8 @@ #include "llvm/ModuleProvider.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Threading.h" #include "llvm/System/Atomic.h" +#include "llvm/System/Threading.h" #include #include #include diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 7cd519483e2..e0ff1845f15 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -20,8 +20,8 @@ #include "llvm/Support/Streams.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Threading.h" #include "llvm/System/Mutex.h" +#include "llvm/System/Threading.h" #include "llvm/Analysis/Dominators.h" #include "llvm-c/Core.h" #include diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index b7adaddd9a1..f5f72be4266 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -23,9 +23,9 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Threading.h" #include "llvm/System/Mutex.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include #include using namespace llvm; diff --git a/lib/VMCore/TypeSymbolTable.cpp b/lib/VMCore/TypeSymbolTable.cpp index 0a88419bc77..0ab6c54a4c8 100644 --- a/lib/VMCore/TypeSymbolTable.cpp +++ b/lib/VMCore/TypeSymbolTable.cpp @@ -16,8 +16,8 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Streams.h" -#include "llvm/Support/Threading.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include using namespace llvm; diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 8bc74528454..8a37b002ba3 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -21,9 +21,9 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Threading.h" #include "llvm/Support/ValueHandle.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include "llvm/ADT/DenseMap.h" #include using namespace llvm;