mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
Factor out the handler work from SignalHandler into a helper function,
and change llvm::sys::RunInterruptHandlers to call that function directly instead of calling SignalHandler, because the rest of SignalHandler invokes side effects which aren't appropriate, including raising the signal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104896 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -111,6 +111,14 @@ static void UnregisterHandlers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// RemoveFilesToRemove - Process the FilesToRemove list. This function
|
||||||
|
/// should be called with the SignalsMutex lock held.
|
||||||
|
static void RemoveFilesToRemove() {
|
||||||
|
while (!FilesToRemove.empty()) {
|
||||||
|
FilesToRemove.back().eraseFromDisk(true);
|
||||||
|
FilesToRemove.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// SignalHandler - The signal handler that runs.
|
// SignalHandler - The signal handler that runs.
|
||||||
static RETSIGTYPE SignalHandler(int Sig) {
|
static RETSIGTYPE SignalHandler(int Sig) {
|
||||||
@@ -126,10 +134,7 @@ static RETSIGTYPE SignalHandler(int Sig) {
|
|||||||
sigprocmask(SIG_UNBLOCK, &SigMask, 0);
|
sigprocmask(SIG_UNBLOCK, &SigMask, 0);
|
||||||
|
|
||||||
SignalsMutex.acquire();
|
SignalsMutex.acquire();
|
||||||
while (!FilesToRemove.empty()) {
|
RemoveFilesToRemove();
|
||||||
FilesToRemove.back().eraseFromDisk(true);
|
|
||||||
FilesToRemove.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (std::find(IntSigs, IntSigsEnd, Sig) != IntSigsEnd) {
|
if (std::find(IntSigs, IntSigsEnd, Sig) != IntSigsEnd) {
|
||||||
if (InterruptFunction) {
|
if (InterruptFunction) {
|
||||||
@@ -153,7 +158,9 @@ static RETSIGTYPE SignalHandler(int Sig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void llvm::sys::RunInterruptHandlers() {
|
void llvm::sys::RunInterruptHandlers() {
|
||||||
SignalHandler(SIGINT);
|
SignalsMutex.acquire();
|
||||||
|
RemoveFilesToRemove();
|
||||||
|
SignalsMutex.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void llvm::sys::SetInterruptFunction(void (*IF)()) {
|
void llvm::sys::SetInterruptFunction(void (*IF)()) {
|
||||||
|
Reference in New Issue
Block a user