Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/23455 )

Change subject: sim: Clean up some constants used in some syscalls.
......................................................................

sim: Clean up some constants used in some syscalls.

Having readable constants for these large numbers is good, but they
used incorrect style, were at global scope, and were only used in one
place.

This change centralizes them where they're used, fixes their style, and
rewrites the actual constants in a way that makes it clear what they're
values are.

Change-Id: Ib89c46fce133d4180296d384a61d51d1fe1f8d20
---
M src/sim/syscall_emul.hh
1 file changed, 9 insertions(+), 10 deletions(-)



diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 5537817..27b4a43 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -523,15 +523,10 @@
 SyscallReturn getxgidFunc(SyscallDesc *desc, int num, ThreadContext *tc);


-/// A readable name for 1,000,000, for converting microseconds to seconds.
-const int one_million = 1000000;
-/// A readable name for 1,000,000,000, for converting nanoseconds to seconds.
-const int one_billion = 1000000000;
-
 /// Approximate seconds since the epoch (1/1/1970).  About a billion,
 /// by my reckoning.  We want to keep this a constant (not use the
 /// real-world time) to keep simulations repeatable.
-const unsigned seconds_since_epoch = 1000000000;
+const unsigned seconds_since_epoch = 1000 * 1000 * 1000;

 /// Helper function to convert current elapsed time to seconds and
 /// microseconds.
@@ -539,9 +534,11 @@
 void
 getElapsedTimeMicro(T1 &sec, T2 &usec)
 {
+    static const int OneMillion = 1000 * 1000;
+
     uint64_t elapsed_usecs = curTick() / SimClock::Int::us;
-    sec = elapsed_usecs / one_million;
-    usec = elapsed_usecs % one_million;
+    sec = elapsed_usecs / OneMillion;
+    usec = elapsed_usecs % OneMillion;
 }

 /// Helper function to convert current elapsed time to seconds and
@@ -550,9 +547,11 @@
 void
 getElapsedTimeNano(T1 &sec, T2 &nsec)
 {
+    static const int OneBillion = 1000 * 1000 * 1000;
+
     uint64_t elapsed_nsecs = curTick() / SimClock::Int::ns;
-    sec = elapsed_nsecs / one_billion;
-    nsec = elapsed_nsecs % one_billion;
+    sec = elapsed_nsecs / OneBillion;
+    nsec = elapsed_nsecs % OneBillion;
 }

 //////////////////////////////////////////////////////////////////////

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23455
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: Ib89c46fce133d4180296d384a61d51d1fe1f8d20
Gerrit-Change-Number: 23455
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to