From: Gabe Black Date: Wed, 8 Aug 2018 09:03:30 +0000 (-0700) Subject: systemc: Use an std::list to track all modules. X-Git-Tag: v19.0.0.0~1773 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=081af5ec9c6dff33081ccd00f4ec1d494fa6af3c;p=gem5.git systemc: Use an std::list to track all modules. This is less efficient when modules are destroyed since the list isn't sorted, and each module needs to find its own entry to remove. The benefit is that entries added to the end of the list while the list is being iterated over will still be included, and that the order the modules are added will be preserved so that it matches what the order in the regression tests. Change-Id: I5af5d15f316fa58561e8fd9ca77f667ddc8b2c5e Reviewed-on: https://gem5-review.googlesource.com/12077 Reviewed-by: Gabe Black Maintainer: Gabe Black --- diff --git a/src/systemc/core/module.cc b/src/systemc/core/module.cc index 986ad25a7..b13b50d28 100644 --- a/src/systemc/core/module.cc +++ b/src/systemc/core/module.cc @@ -30,7 +30,6 @@ #include "systemc/core/module.hh" #include -#include #include "base/logging.hh" @@ -53,7 +52,7 @@ Module::Module(const char *name) : _name(name), _sc_mod(nullptr), _obj(nullptr) _new_module = this; } -Module::~Module() { allModules.erase(this); } +Module::~Module() { allModules.remove(this); } void Module::finish(Object *this_obj) @@ -65,7 +64,7 @@ Module::finish(Object *this_obj) // This is called from the constructor of this_obj, so it can't use // dynamic cast. sc_mod(static_cast<::sc_core::sc_module *>(this_obj->sc_obj())); - allModules.insert(this); + allModules.emplace_back(this); } void @@ -95,6 +94,6 @@ newModule() void callbackModule(Module *m) { _callbackModule = m; } Module *callbackModule() { return _callbackModule; } -std::set allModules; +std::list allModules; } // namespace sc_gem5 diff --git a/src/systemc/core/module.hh b/src/systemc/core/module.hh index 7e54e29d5..a5bf92975 100644 --- a/src/systemc/core/module.hh +++ b/src/systemc/core/module.hh @@ -31,8 +31,8 @@ #define __SYSTEMC_CORE_MODULE_HH__ #include +#include #include -#include #include #include @@ -109,7 +109,7 @@ Module *newModule(); void callbackModule(Module *m); Module *callbackModule(); -extern std::set allModules; +extern std::list allModules; } // namespace sc_gem5