Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/12463
Change subject: systemc: Add some error checks to sc_set_default_time_unit.
......................................................................
systemc: Add some error checks to sc_set_default_time_unit.
Change-Id: I1d21c56d3b39044d91c96c98d242a571c099707c
---
M src/systemc/core/sc_time.cc
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/systemc/core/sc_time.cc b/src/systemc/core/sc_time.cc
index 4ec0a7c..49b99ed 100644
--- a/src/systemc/core/sc_time.cc
+++ b/src/systemc/core/sc_time.cc
@@ -426,7 +426,34 @@
void
sc_set_default_time_unit(double d, sc_time_unit tu)
{
+ if (d < 0.0) {
+ SC_REPORT_ERROR("(E515) set default time unit failed",
+ "value not positive");
+ }
+ double dummy;
+ if (modf(log10(d), &dummy) != 0.0) {
+ SC_REPORT_ERROR("(E515) set default time unit failed",
+ "value not a power of ten");
+ }
+ if (sc_is_running()) {
+ SC_REPORT_ERROR("(E515) set default time unit failed",
+ "simulation running");
+ }
+ static bool specified = false;
+ if (specified) {
+ SC_REPORT_ERROR("(E515) set default time unit failed",
+ "already specified");
+ }
+ // This won't detect the timescale being fixed outside of systemc, but
+ // it's at least some protection.
+ if (timeFixed) {
+ SC_REPORT_ERROR("(E515) set default time unit failed",
+ "sc_time object(s) constructed");
+ }
+
+ // Normalize d to seconds.
defaultUnit = d * TimeUnitScale[tu];
+ specified = true;
}
sc_time
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12463
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I1d21c56d3b39044d91c96c98d242a571c099707c
Gerrit-Change-Number: 12463
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev