Hide members of CXAAtExitElement and make it a callable object. Update iteration to use llvm::reverse and C++11 range based for loop.
This commit is contained in:
parent
baa1cba4d3
commit
5c41b2957c
@ -110,10 +110,8 @@ IncrementalExecutor::~IncrementalExecutor() {}
|
||||
void IncrementalExecutor::shuttingDown() {
|
||||
// No need to protect this access, since hopefully there is no concurrent
|
||||
// shutdown request.
|
||||
for (size_t I = 0, N = m_AtExitFuncs.size(); I < N; ++I) {
|
||||
const CXAAtExitElement& AEE = m_AtExitFuncs[N - I - 1];
|
||||
(*AEE.m_Func)(AEE.m_Arg);
|
||||
}
|
||||
for (auto& AtExit : llvm::reverse(m_AtExitFuncs))
|
||||
AtExit();
|
||||
}
|
||||
|
||||
void IncrementalExecutor::AddAtExitFunc(void (*func) (void*), void* arg,
|
||||
@ -294,7 +292,7 @@ void IncrementalExecutor::runAndRemoveStaticDestructors(Transaction* T) {
|
||||
cling::internal::SpinLockGuard slg(m_AtExitFuncsSpinLock);
|
||||
for (AtExitFunctions::iterator I = m_AtExitFuncs.begin();
|
||||
I != m_AtExitFuncs.end();)
|
||||
if (I->m_FromM == T->getModule()) {
|
||||
if (I->getModule() == T->getModule()) {
|
||||
boundToT.push_back(*I);
|
||||
I = m_AtExitFuncs.erase(I);
|
||||
}
|
||||
@ -303,11 +301,8 @@ void IncrementalExecutor::runAndRemoveStaticDestructors(Transaction* T) {
|
||||
} // end of spin lock lifetime block.
|
||||
|
||||
// 'Unload' the cxa_atexit entities.
|
||||
for (AtExitFunctions::reverse_iterator I = boundToT.rbegin(),
|
||||
E = boundToT.rend(); I != E; ++I) {
|
||||
const CXAAtExitElement& AEE = *I;
|
||||
(*AEE.m_Func)(AEE.m_Arg);
|
||||
}
|
||||
for (auto&& AtExit : llvm::reverse(boundToT))
|
||||
AtExit();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -64,7 +64,20 @@ namespace cling {
|
||||
/// The object is registered first as an CXAAtExitElement and then cling
|
||||
/// takes the control of it's destruction.
|
||||
///
|
||||
struct CXAAtExitElement {
|
||||
class CXAAtExitElement {
|
||||
///\brief The function to be called.
|
||||
///
|
||||
void (*m_Func)(void*);
|
||||
|
||||
///\brief The single argument passed to the function.
|
||||
///
|
||||
void* m_Arg;
|
||||
|
||||
///\brief The module whose unloading will trigger the call to this atexit
|
||||
/// function.
|
||||
///
|
||||
const llvm::Module* m_FromM;
|
||||
public:
|
||||
///\brief Constructs an element, whose destruction time will be managed by
|
||||
/// the interpreter. (By registering a function to be called by exit
|
||||
/// or when a shared library is unloaded.)
|
||||
@ -87,18 +100,8 @@ namespace cling {
|
||||
const llvm::Module* fromM):
|
||||
m_Func(func), m_Arg(arg), m_FromM(fromM) {}
|
||||
|
||||
///\brief The function to be called.
|
||||
///
|
||||
void (*m_Func)(void*);
|
||||
|
||||
///\brief The single argument passed to the function.
|
||||
///
|
||||
void* m_Arg;
|
||||
|
||||
///\brief The module whose unloading will trigger the call to this atexit
|
||||
/// function.
|
||||
///
|
||||
const llvm::Module* m_FromM;
|
||||
void operator () () const { (*m_Func)(m_Arg); }
|
||||
const llvm::Module* getModule() const { return m_FromM; }
|
||||
};
|
||||
|
||||
///\brief Atomic used as a spin lock to protect the access to m_AtExitFuncs
|
||||
|
Loading…
x
Reference in New Issue
Block a user