summaryrefslogtreecommitdiff
path: root/base/intmath.hh
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2003-10-10 09:53:16 -0400
committerNathan Binkert <binkertn@umich.edu>2003-10-10 09:53:16 -0400
commitf4e2b3fa77e3bd24f3e5921e5c9616c8a82ce36c (patch)
tree8f23b36f444e730b0d3f5891a872a11000aa462b /base/intmath.hh
parenta2b619df6d4ce403077639e4329ec6ad6cd53735 (diff)
downloadgem5-f4e2b3fa77e3bd24f3e5921e5c9616c8a82ce36c.tar.xz
Stop using omisc.h and move relevant functions to better places
while converting them to C++ base/intmath.hh: Add some functions that were previously defined elsewhere in C base/misc.cc: Use the C++ version of memUsage, and sort #includes sim/prog.cc: Stop using the old macro versions of various functions and use the new ones defined in intmath.hh sim/sim_events.cc: Stop using the old C versions of various functions and use the new ones defined in hostinfo.hh --HG-- extra : convert_revision : 15d1f24d2aff4254c745eea6070cb230dd37b8d2
Diffstat (limited to 'base/intmath.hh')
-rw-r--r--base/intmath.hh23
1 files changed, 23 insertions, 0 deletions
diff --git a/base/intmath.hh b/base/intmath.hh
index 16467426d..a17492728 100644
--- a/base/intmath.hh
+++ b/base/intmath.hh
@@ -107,6 +107,29 @@ CeilPow2(T n)
return (T)1 << CeilLog2(n);
}
+template <class T>
+inline T
+DivCeil(T a, T b)
+{
+ return (a + b - 1) / b;
+}
+
+template <class T>
+inline T
+RoundUp(T val, T align)
+{
+ T mask = align - 1;
+ return (val + mask) & ~mask;
+}
+
+template <class T>
+inline T
+RoundDown(T val, T align)
+{
+ T mask = align - 1;
+ return val & ~mask;
+}
+
inline bool
IsHex(char c)
{