summaryrefslogtreecommitdiff
path: root/base/intmath.hh
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2004-06-21 01:04:48 -0400
committerAli Saidi <saidi@eecs.umich.edu>2004-06-21 01:04:48 -0400
commit3f7b780af5530cc60228ebd3e895ab26d477614e (patch)
treeecc9052d0fa587e2b48e888705f5df2a80fe401b /base/intmath.hh
parent074969f8f16110680de05fca64a6be48aedcdfd8 (diff)
parentc27139c701e8e61056ebc2cf002c5aa129779c13 (diff)
downloadgem5-3f7b780af5530cc60228ebd3e895ab26d477614e.tar.xz
Merge saidi@zizzer.eecs.umich.edu:/bk/linux
into ali-saidis-computer.local:/research/linux --HG-- extra : convert_revision : 446dc5fad11a6b29954dc5b1e974430853aa2969
Diffstat (limited to 'base/intmath.hh')
-rw-r--r--base/intmath.hh14
1 files changed, 14 insertions, 0 deletions
diff --git a/base/intmath.hh b/base/intmath.hh
index cb5a34107..fc28eecef 100644
--- a/base/intmath.hh
+++ b/base/intmath.hh
@@ -119,6 +119,20 @@ FloorLog2(int64_t x)
return FloorLog2((uint64_t)x);
}
+inline int
+FloorLog2(size_t x)
+{
+ assert(x > 0);
+ assert(sizeof(size_t) == 4 || sizeof(size_t) == 8);
+
+ // It's my hope that this is optimized away?
+ if (sizeof(size_t) == 4)
+ return FloorLog2((uint32_t)x);
+ else if (sizeof(size_t) == 8)
+ return FloorLog2((uint64_t)x);
+
+}
+
template <class T>
inline int
CeilLog2(T n)