Static global object don't work well, if the variables are
accessed during the construction of another static global object because there are no guarantees on ordering of construction, so stick the static global into a function as a static local and return a reference to the variable. This fixes the exit callback stuff on my Mac. --HG-- extra : convert_revision : 63a3844d0b5ee18e2011f1bc7ca7bb703284da94
This commit is contained in:
parent
51c8eab7b3
commit
4142f8f7c0
1 changed files with 9 additions and 4 deletions
|
@ -414,7 +414,12 @@ unserializeAll(const std::string &cpt_dir)
|
||||||
/**
|
/**
|
||||||
* Queue of C++ callbacks to invoke on simulator exit.
|
* Queue of C++ callbacks to invoke on simulator exit.
|
||||||
*/
|
*/
|
||||||
CallbackQueue exitCallbacks;
|
CallbackQueue&
|
||||||
|
exitCallbacks()
|
||||||
|
{
|
||||||
|
static CallbackQueue theQueue;
|
||||||
|
return theQueue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register an exit callback.
|
* Register an exit callback.
|
||||||
|
@ -422,7 +427,7 @@ CallbackQueue exitCallbacks;
|
||||||
void
|
void
|
||||||
registerExitCallback(Callback *callback)
|
registerExitCallback(Callback *callback)
|
||||||
{
|
{
|
||||||
exitCallbacks.add(callback);
|
exitCallbacks().add(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseCPU *
|
BaseCPU *
|
||||||
|
@ -442,8 +447,8 @@ convertToBaseCPUPtr(SimObject *obj)
|
||||||
void
|
void
|
||||||
doExitCleanup()
|
doExitCleanup()
|
||||||
{
|
{
|
||||||
exitCallbacks.process();
|
exitCallbacks().process();
|
||||||
exitCallbacks.clear();
|
exitCallbacks().clear();
|
||||||
|
|
||||||
cout.flush();
|
cout.flush();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue