summaryrefslogtreecommitdiff
path: root/base/intmath.hh
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2004-06-21 00:58:30 -0400
committerAli Saidi <saidi@eecs.umich.edu>2004-06-21 00:58:30 -0400
commitc27139c701e8e61056ebc2cf002c5aa129779c13 (patch)
treeddf8997bbfb5805db6d2c81efc5974b0a800a120 /base/intmath.hh
parentf5c7b1358cf0b27c27c10eae42e09949613e24a9 (diff)
downloadgem5-c27139c701e8e61056ebc2cf002c5aa129779c13.tar.xz
start towards getting m5 endian compliant
base/inifile.cc: Added mac os support and fixed a bug, on error we need to exit the child process not return base/intmath.hh: gcc on macos wanted a seperate function for the size_t type base/loader/elf_object.cc: I'm not sure why this works under linux because it seems to return the wrong value. base/stats/text.cc: added define/include for mac os x cpu/exec_context.hh: cpu/simple_cpu/simple_cpu.cc: added endian conversion code dev/alpha_console.cc: rather than accessing a charecter array of varying size depending on the access, lets actually do this properly. dev/alpha_console.hh: get rid of now nolonger used consoleData dev/disk_image.cc: We have to byte swap the data is some cases, added function to do that dev/ethertap.cc: added preproc directive for mac os --HG-- extra : convert_revision : 2b5685765cfa2844926d7397f363d2788e3d640a
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 77f63fe8d..28e9d5c68 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)