mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-11 21:38:19 +00:00
Augment CrashRecoveryContext to have registered "cleanup" objects that can be used to release resources during a crash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127849 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -57,7 +57,18 @@ public:
|
||||
static sys::Mutex gCrashRecoveryContexMutex;
|
||||
static bool gCrashRecoveryEnabled = false;
|
||||
|
||||
CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {}
|
||||
|
||||
CrashRecoveryContext::~CrashRecoveryContext() {
|
||||
// Reclaim registered resources.
|
||||
CrashRecoveryContextCleanup *i = head;
|
||||
while (i) {
|
||||
CrashRecoveryContextCleanup *tmp = i;
|
||||
i = tmp->next;
|
||||
tmp->recoverResources();
|
||||
delete tmp;
|
||||
}
|
||||
|
||||
CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *) Impl;
|
||||
delete CRCI;
|
||||
}
|
||||
@ -70,6 +81,33 @@ CrashRecoveryContext *CrashRecoveryContext::GetCurrent() {
|
||||
return CRCI->CRC;
|
||||
}
|
||||
|
||||
void CrashRecoveryContext::registerCleanup(CrashRecoveryContextCleanup *cleanup)
|
||||
{
|
||||
if (!cleanup)
|
||||
return;
|
||||
if (head)
|
||||
head->prev = cleanup;
|
||||
cleanup->next = head;
|
||||
head = cleanup;
|
||||
}
|
||||
|
||||
void
|
||||
CrashRecoveryContext::unregisterCleanup(CrashRecoveryContextCleanup *cleanup) {
|
||||
if (!cleanup)
|
||||
return;
|
||||
if (cleanup == head) {
|
||||
head = cleanup->next;
|
||||
if (head)
|
||||
head->prev = 0;
|
||||
}
|
||||
else {
|
||||
cleanup->prev->next = cleanup->next;
|
||||
if (cleanup->next)
|
||||
cleanup->next->prev = cleanup->prev;
|
||||
}
|
||||
delete cleanup;
|
||||
}
|
||||
|
||||
#ifdef LLVM_ON_WIN32
|
||||
|
||||
// FIXME: No real Win32 implementation currently.
|
||||
|
Reference in New Issue
Block a user