1 //===-- ManagedStatic.cpp - Static Global wrapper -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Chris Lattner and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the ManagedStatic class and llvm_shutdown().
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/ManagedStatic.h"
18 static const ManagedStaticBase
*StaticList
= 0;
20 void ManagedStaticBase::RegisterManagedStatic(void *ObjPtr
,
21 void (*Deleter
)(void*)) const {
22 assert(Ptr
== 0 && DeleterFn
== 0 && Next
== 0 &&
23 "Partially init static?");
27 // Add to list of managed statics.
32 void ManagedStaticBase::destroy() const {
33 assert(DeleterFn
&& "ManagedStatic not initialized correctly!");
34 assert(StaticList
== this &&
35 "Not destroyed in reverse order of construction?");
48 /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
49 void llvm::llvm_shutdown() {
51 StaticList
->destroy();