#include "llvm/Support/ManagedStatic.h"
#include <cassert>
using namespace llvm;
static const ManagedStaticBase *StaticList = 0;
void ManagedStaticBase::RegisterManagedStatic(void *ObjPtr,
void (*Deleter)(void*)) const {
assert(Ptr == 0 && DeleterFn == 0 && Next == 0 &&
"Partially init static?");
Ptr = ObjPtr;
DeleterFn = Deleter;
Next = StaticList;
StaticList = this;
}
void ManagedStaticBase::destroy() const {
assert(DeleterFn && "ManagedStatic not initialized correctly!");
assert(StaticList == this &&
"Not destroyed in reverse order of construction?");
StaticList = Next;
Next = 0;
DeleterFn(Ptr);
Ptr = 0;
DeleterFn = 0;
}
void llvm::llvm_shutdown() {
while (StaticList)
StaticList->destroy();
}