summaryrefslogtreecommitdiff
path: root/src/systemc/utils/report.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-10-07 03:59:56 -0700
committerGabe Black <gabeblack@google.com>2018-10-16 01:12:26 +0000
commit3420f0e223888bf70cd502efb5a534e651891b5c (patch)
treeb8482805bf9b7febebb9775aa87cc0d82787c1f7 /src/systemc/utils/report.cc
parentb366cbcde953e2adddc10a2825e2803b5f8a9bdd (diff)
downloadgem5-3420f0e223888bf70cd502efb5a534e651891b5c.tar.xz
systemc: Don't depend on the order of static initializers.
STL containers may need to be constructed before they're used. Don't count on being able to insert into them during a static initializer. Change-Id: Icb05d5084a470e1ebd976ae6e1954b1a78aabd6a Reviewed-on: https://gem5-review.googlesource.com/c/13329 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/utils/report.cc')
-rw-r--r--src/systemc/utils/report.cc37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/systemc/utils/report.cc b/src/systemc/utils/report.cc
index 755542fd6..87671f181 100644
--- a/src/systemc/utils/report.cc
+++ b/src/systemc/utils/report.cc
@@ -29,6 +29,8 @@
#include "systemc/utils/report.hh"
+#include "systemc/core/python.hh"
+
namespace sc_gem5
{
@@ -63,11 +65,42 @@ std::unique_ptr<sc_core::sc_report> globalReportCache;
bool reportWarningsAsErrors = false;
-DefaultReportMessages::DefaultReportMessages(
- std::initializer_list<std::pair<int, const char *>> msgs)
+DefaultReportMessages *&
+DefaultReportMessages::top()
+{
+ static DefaultReportMessages *top_ptr = nullptr;
+ return top_ptr;
+}
+
+void
+DefaultReportMessages::install()
{
for (auto &p: msgs)
sc_core::sc_report::register_id(p.first, p.second);
}
+DefaultReportMessages::DefaultReportMessages(
+ std::initializer_list<std::pair<int, const char *>> msgs) :
+ next(top()), msgs(msgs)
+{
+ top() = this;
+}
+
+void
+DefaultReportMessages::installAll()
+{
+ for (DefaultReportMessages *ptr = top(); ptr; ptr = ptr->next)
+ ptr->install();
+}
+
+namespace
+{
+
+struct InstallDefaultReportMessages : public PythonReadyFunc
+{
+ void run() override { DefaultReportMessages::installAll(); }
+} messageInstaller;
+
+} // anonymous namespace
+
} // namespace sc_gem5