Threading.cpp (218893) | Threading.cpp (224145) |
---|---|
1//===-- llvm/Support/Threading.cpp- Control multithreading mode --*- C++ -*-==// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 10 unchanged lines hidden (view full) --- 19 20using namespace llvm; 21 22static bool multithreaded_mode = false; 23 24static sys::Mutex* global_lock = 0; 25 26bool llvm::llvm_start_multithreaded() { | 1//===-- llvm/Support/Threading.cpp- Control multithreading mode --*- C++ -*-==// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 10 unchanged lines hidden (view full) --- 19 20using namespace llvm; 21 22static bool multithreaded_mode = false; 23 24static sys::Mutex* global_lock = 0; 25 26bool llvm::llvm_start_multithreaded() { |
27#ifdef LLVM_MULTITHREADED | 27#if defined(LLVM_MULTITHREADED) && LLVM_MULTITHREADED == 1 |
28 assert(!multithreaded_mode && "Already multithreaded!"); 29 multithreaded_mode = true; 30 global_lock = new sys::Mutex(true); 31 32 // We fence here to ensure that all initialization is complete BEFORE we 33 // return from llvm_start_multithreaded(). 34 sys::MemoryFence(); 35 return true; 36#else 37 return false; 38#endif 39} 40 41void llvm::llvm_stop_multithreaded() { | 28 assert(!multithreaded_mode && "Already multithreaded!"); 29 multithreaded_mode = true; 30 global_lock = new sys::Mutex(true); 31 32 // We fence here to ensure that all initialization is complete BEFORE we 33 // return from llvm_start_multithreaded(). 34 sys::MemoryFence(); 35 return true; 36#else 37 return false; 38#endif 39} 40 41void llvm::llvm_stop_multithreaded() { |
42#ifdef LLVM_MULTITHREADED | 42#if defined(LLVM_MULTITHREADED) && LLVM_MULTITHREADED == 1 |
43 assert(multithreaded_mode && "Not currently multithreaded!"); 44 45 // We fence here to insure that all threaded operations are complete BEFORE we 46 // return from llvm_stop_multithreaded(). 47 sys::MemoryFence(); 48 49 multithreaded_mode = false; 50 delete global_lock; --- 7 unchanged lines hidden (view full) --- 58void llvm::llvm_acquire_global_lock() { 59 if (multithreaded_mode) global_lock->acquire(); 60} 61 62void llvm::llvm_release_global_lock() { 63 if (multithreaded_mode) global_lock->release(); 64} 65 | 43 assert(multithreaded_mode && "Not currently multithreaded!"); 44 45 // We fence here to insure that all threaded operations are complete BEFORE we 46 // return from llvm_stop_multithreaded(). 47 sys::MemoryFence(); 48 49 multithreaded_mode = false; 50 delete global_lock; --- 7 unchanged lines hidden (view full) --- 58void llvm::llvm_acquire_global_lock() { 59 if (multithreaded_mode) global_lock->acquire(); 60} 61 62void llvm::llvm_release_global_lock() { 63 if (multithreaded_mode) global_lock->release(); 64} 65 |
66#if defined(LLVM_MULTITHREADED) && defined(HAVE_PTHREAD_H) | 66#if defined(LLVM_MULTITHREADED) && LLVM_MULTITHREADED == 1 && defined(HAVE_PTHREAD_H) |
67#include <pthread.h> 68 69struct ThreadInfo { 70 void (*UserFn)(void *); 71 void *UserData; 72}; 73static void *ExecuteOnThread_Dispatch(void *Arg) { 74 ThreadInfo *TI = reinterpret_cast<ThreadInfo*>(Arg); --- 42 unchanged lines hidden --- | 67#include <pthread.h> 68 69struct ThreadInfo { 70 void (*UserFn)(void *); 71 void *UserData; 72}; 73static void *ExecuteOnThread_Dispatch(void *Arg) { 74 ThreadInfo *TI = reinterpret_cast<ThreadInfo*>(Arg); --- 42 unchanged lines hidden --- |