mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Support/Unix: use ScopedLock wherever possible
Only one function remains a bit too complicated for a simple mutex guard. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216335 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -196,22 +196,23 @@ static RETSIGTYPE SignalHandler(int Sig) {
|
||||
}
|
||||
|
||||
void llvm::sys::RunInterruptHandlers() {
|
||||
SignalsMutex.acquire();
|
||||
sys::SmartScopedLock<true> Guard(SignalsMutex);
|
||||
RemoveFilesToRemove();
|
||||
SignalsMutex.release();
|
||||
}
|
||||
|
||||
void llvm::sys::SetInterruptFunction(void (*IF)()) {
|
||||
SignalsMutex.acquire();
|
||||
{
|
||||
sys::SmartScopedLock<true> Guard(SignalsMutex);
|
||||
InterruptFunction = IF;
|
||||
SignalsMutex.release();
|
||||
}
|
||||
RegisterHandlers();
|
||||
}
|
||||
|
||||
// RemoveFileOnSignal - The public API
|
||||
bool llvm::sys::RemoveFileOnSignal(StringRef Filename,
|
||||
std::string* ErrMsg) {
|
||||
SignalsMutex.acquire();
|
||||
{
|
||||
sys::SmartScopedLock<true> Guard(SignalsMutex);
|
||||
std::string *OldPtr = FilesToRemove.empty() ? nullptr : &FilesToRemove[0];
|
||||
FilesToRemove.push_back(Filename);
|
||||
|
||||
@@ -225,8 +226,7 @@ bool llvm::sys::RemoveFileOnSignal(StringRef Filename,
|
||||
else
|
||||
for (unsigned i = 0, e = FilesToRemove.size(); i != e; ++i)
|
||||
FilesToRemove[i].c_str();
|
||||
|
||||
SignalsMutex.release();
|
||||
}
|
||||
|
||||
RegisterHandlers();
|
||||
return false;
|
||||
@@ -234,7 +234,7 @@ bool llvm::sys::RemoveFileOnSignal(StringRef Filename,
|
||||
|
||||
// DontRemoveFileOnSignal - The public API
|
||||
void llvm::sys::DontRemoveFileOnSignal(StringRef Filename) {
|
||||
SignalsMutex.acquire();
|
||||
sys::SmartScopedLock<true> Guard(SignalsMutex);
|
||||
std::vector<std::string>::reverse_iterator RI =
|
||||
std::find(FilesToRemove.rbegin(), FilesToRemove.rend(), Filename);
|
||||
std::vector<std::string>::iterator I = FilesToRemove.end();
|
||||
@@ -247,8 +247,6 @@ void llvm::sys::DontRemoveFileOnSignal(StringRef Filename) {
|
||||
// made on insertion become invalid by being copied down an element.
|
||||
for (std::vector<std::string>::iterator E = FilesToRemove.end(); I != E; ++I)
|
||||
I->c_str();
|
||||
|
||||
SignalsMutex.release();
|
||||
}
|
||||
|
||||
/// AddSignalHandler - Add a function to be called when a signal is delivered
|
||||
|
Reference in New Issue
Block a user